Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ strip = "none"
debug = true

[workspace.dependencies]
sqltk = { version = "0.5.0" }
sqltk-parser = { version = "0.52.0" }
sqltk = { version = "0.6.0" }
thiserror = "2.0.9"
tokio = { version = "1.44", features = ["full"] }
tracing = "0.1"
Expand Down
1 change: 0 additions & 1 deletion packages/cipherstash-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ serde = "1.0"
serde_json = "1.0"
socket2 = "0.5.7"
sqltk = { workspace = true }
sqltk-parser = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tokio-postgres = { version = "0.7", features = [
Expand Down
2 changes: 1 addition & 1 deletion packages/cipherstash-proxy/src/encrypt/schema/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::error::Error;
use crate::{connect, log::SCHEMA};
use arc_swap::ArcSwap;
use eql_mapper::{Column, Schema, Table};
use sqltk_parser::ast::Ident;
use sqltk::parser::ast::Ident;
use std::sync::Arc;
use std::time::Duration;
use tokio::{task::JoinHandle, time};
Expand Down
2 changes: 1 addition & 1 deletion packages/cipherstash-proxy/src/eql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cipherstash_client::{
zerokms::{encrypted_record, EncryptedRecord},
};
use serde::{Deserialize, Serialize};
use sqltk_parser::ast::Ident;
use sqltk::parser::ast::Ident;

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Plaintext {
Expand Down
4 changes: 2 additions & 2 deletions packages/cipherstash-proxy/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ impl From<serde_json::Error> for Error {
}
}

impl From<sqltk_parser::parser::ParserError> for Error {
fn from(e: sqltk_parser::parser::ParserError) -> Self {
impl From<sqltk::parser::parser::ParserError> for Error {
fn from(e: sqltk::parser::parser::ParserError) -> Self {
Error::Mapping(MappingError::InvalidSqlStatement(e.to_string()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cipherstash-proxy/src/postgresql/data/from_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use cipherstash_config::ColumnType;
use postgres_types::FromSql;
use postgres_types::Type;
use rust_decimal::Decimal;
use sqltk_parser::ast::Value;
use sqltk::parser::ast::Value;
use std::str::FromStr;
use tracing::debug;

Expand Down
6 changes: 3 additions & 3 deletions packages/cipherstash-proxy/src/postgresql/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use eql_mapper::{self, EqlMapperError, EqlValue, TableColumn, TypeCheckedStateme
use metrics::{counter, histogram};
use pg_escape::quote_literal;
use serde::Serialize;
use sqltk::parser::ast::{self, Value};
use sqltk::parser::dialect::PostgreSqlDialect;
use sqltk::parser::parser::Parser;
use sqltk::NodeKey;
use sqltk_parser::ast::{self, Value};
use sqltk_parser::dialect::PostgreSqlDialect;
use sqltk_parser::parser::Parser;
use std::collections::HashMap;
use std::time::Instant;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
Expand Down
1 change: 0 additions & 1 deletion packages/eql-mapper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ derive_more = { version = "^1.0", features = ["display", "constructor"] }
impl-trait-for-tuples = "0.2.3"
itertools = "^0.13"
sqltk = { workspace = true }
sqltk-parser = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions packages/eql-mapper/src/display_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::{
fmt::{Debug, Display},
};

use sqltk::NodeKey;
use sqltk_parser::ast::{
use sqltk::parser::ast::{
Delete, Expr, Function, Insert, Query, Select, SelectItem, SetExpr, Statement, Value, Values,
};
use sqltk::NodeKey;

use crate::{EqlValue, Param, Type};

Expand Down Expand Up @@ -108,7 +108,7 @@ impl Display for Fmt<&Vec<(Param, crate::Value)>> {
}
}

impl Display for Fmt<&Vec<(EqlValue, &sqltk_parser::ast::Value)>> {
impl Display for Fmt<&Vec<(EqlValue, &sqltk::parser::ast::Value)>> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let formatted = self
.0
Expand Down
2 changes: 1 addition & 1 deletion packages/eql-mapper/src/eql_mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
DepMut, Fmt, Param, ParamError, ScopeError, ScopeTracker, TableResolver, Type,
TypeCheckedStatement, TypeRegistry, Value,
};
use sqltk::parser::ast::{self as ast, Statement};
use sqltk::{Break, NodeKey, Visitable, Visitor};
use sqltk_parser::ast::{self as ast, Statement};
use std::{
cell::RefCell, collections::HashMap, marker::PhantomData, ops::ControlFlow, rc::Rc, sync::Arc,
};
Expand Down
16 changes: 14 additions & 2 deletions packages/eql-mapper/src/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
unifier::{Projection, ProjectionColumns},
Relation, ScopeError, ScopeTracker,
};
use sqltk::parser::ast::{Cte, Ident, Insert, TableAlias, TableFactor};
use sqltk::{Break, Visitable, Visitor};
use sqltk_parser::ast::{Cte, Ident, Insert, TableAlias, TableFactor};
use std::{cell::RefCell, fmt::Debug, marker::PhantomData, ops::ControlFlow, rc::Rc, sync::Arc};

/// `Importer` is a [`Visitor`] implementation that brings projections (from "FROM" clauses and subqueries) into lexical scope.
Expand Down Expand Up @@ -220,6 +220,18 @@ impl<'ast> Importer<'ast> {
))
}

#[allow(unused_variables)]
TableFactor::OpenJsonTable {
json_expr,
json_path,
columns,
alias,
} => {
return Err(ImportError::UnsupportedTableFactorVariant(
"OpenJsonTable".to_owned(),
))
}

#[allow(unused_variables)]
TableFactor::Pivot {
table,
Expand Down Expand Up @@ -307,7 +319,7 @@ impl<'ast> Visitor<'ast> for Importer<'ast> {
// Most nodes that bring relations into scope use `exit` but in Insert's case we need to use `enter` because
//
// 1. There is no approprate child AST node of [`Insert`] on which to listen for an `exit` from except
// [`sqltk_parser::ast::ObjectName`], and `ObjectName` is used in contexts where it *should not* bring anything in
// [`sqltk::parser::ast::ObjectName`], and `ObjectName` is used in contexts where it *should not* bring anything in
// to scope (it is not only used to identify tables).
//
// 2. Child nodes of the `Insert` need to resolve identifiers in the context of the scope, so exit would be too
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::Delete;
use sqltk::parser::ast::Delete;

use crate::{
inference::unifier::Type,
Expand Down
13 changes: 10 additions & 3 deletions packages/eql-mapper/src/inference/infer_type_impls/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
SqlIdent, TypeInferencer,
};
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::{Array, BinaryOperator, Expr, Ident};
use sqltk::parser::ast::{Array, BinaryOperator, Expr, Ident};

#[trace_infer]
impl<'ast> InferType<'ast, Expr> for TypeInferencer<'ast> {
Expand All @@ -25,12 +25,12 @@ impl<'ast> InferType<'ast, Expr> for TypeInferencer<'ast> {
}

#[allow(unused_variables)]
Expr::Wildcard => {
Expr::Wildcard(_) => {
self.unify_node_with_type(this_expr, self.resolve_wildcard()?)?;
}

#[allow(unused_variables)]
Expr::QualifiedWildcard(object_name) => {
Expr::QualifiedWildcard(object_name, _) => {
self.unify_node_with_type(
this_expr,
self.resolve_qualified_wildcard(&object_name.0)?,
Expand Down Expand Up @@ -345,6 +345,13 @@ impl<'ast> InferType<'ast, Expr> for TypeInferencer<'ast> {
self.unify_node_with_type(this_expr, self.get_node_type(function))?;
}

// `<arbitrary-expr>.<function-call>.<function-call-expr>...`
Expr::Method(_) => {
return Err(TypeError::UnsupportedSqlFeature(
"MSSQL Expression Method".into(),
))
}

// When operand is Some(operand), all conditions must be of type expr and expr must support equality
// When operand is None, all conditions must be native (they are boolean)
// The elements of `results` and else_result must be the same type
Expand Down
20 changes: 18 additions & 2 deletions packages/eql-mapper/src/inference/infer_type_impls/function.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::{Function, FunctionArg, FunctionArgExpr, FunctionArguments, Ident};
use sqltk::parser::ast::{Function, FunctionArg, FunctionArgExpr, FunctionArguments, Ident};

use crate::{
inference::{type_error::TypeError, InferType},
Expand Down Expand Up @@ -44,7 +44,7 @@ impl<'ast> InferType<'ast, Function> for TypeInferencer<'ast> {
FunctionArguments::List(args_list) => {
if args_list.args.len() == 1 {
match &args_list.args[0] {
FunctionArg::Named { .. } => {
FunctionArg::Named { .. } | FunctionArg::ExprNamed { .. } => {
return Err(TypeError::FunctionCall(format!(
"{} cannot be called with named arguments",
fn_name.last().unwrap(),
Expand Down Expand Up @@ -97,6 +97,22 @@ impl<'ast> InferType<'ast, Function> for TypeInferencer<'ast> {
self.unify_node_with_type(function, Type::any_native())?;
for arg in &args_list.args {
match arg {
FunctionArg::ExprNamed {
name,
arg,
operator: _,
} => {
self.unify_node_with_type(name, Type::any_native())?;
match arg {
FunctionArgExpr::Expr(expr) => {
self.unify_node_with_type(expr, Type::any_native())?;
}
// Aggregate functions like COUNT(table.*)
FunctionArgExpr::QualifiedWildcard(_) => {}
// Aggregate functions like COUNT(*)
FunctionArgExpr::Wildcard => {}
}
}
FunctionArg::Named { arg, .. } | FunctionArg::Unnamed(arg) => match arg
{
FunctionArgExpr::Expr(expr) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
ColumnKind, TableColumn, TypeInferencer,
};
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::{Ident, Insert};
use sqltk::parser::ast::{Ident, Insert};

#[trace_infer]
impl<'ast> InferType<'ast, Insert> for TypeInferencer<'ast> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::Query;
use sqltk::parser::ast::Query;

use crate::{
inference::{InferType, TypeError},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::Select;
use sqltk::parser::ast::Select;

use crate::{
inference::{type_error::TypeError, InferType},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::SelectItem;
use sqltk::parser::ast::SelectItem;

use crate::{
inference::{type_error::TypeError, InferType},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::{Expr, Function, SelectItem, WildcardAdditionalOptions};
use sqltk::parser::ast::{Expr, Function, SelectItem, WildcardAdditionalOptions};

use crate::{
inference::{type_error::TypeError, unifier::Type, InferType},
Expand Down Expand Up @@ -39,6 +39,7 @@ impl<'ast> InferType<'ast, Vec<SelectItem>> for TypeInferencer<'ast> {
#[allow(unused_variables)]
SelectItem::QualifiedWildcard(object_name, options) => {
let WildcardAdditionalOptions {
wildcard_token: _,
opt_ilike: None,
opt_exclude: None,
opt_except: None,
Expand All @@ -56,6 +57,7 @@ impl<'ast> InferType<'ast, Vec<SelectItem>> for TypeInferencer<'ast> {

SelectItem::Wildcard(options) => {
let WildcardAdditionalOptions {
wildcard_token: _,
opt_ilike: None,
opt_exclude: None,
opt_except: None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::SetExpr;
use sqltk::parser::ast::SetExpr;

use crate::{inference::type_error::TypeError, inference::InferType, TypeInferencer};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::{AssignmentTarget, Statement};
use sqltk::parser::ast::{AssignmentTarget, Statement};

use crate::{inference::infer_type::InferType, unifier::Type, TypeError, TypeInferencer};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::Value;
use sqltk::parser::ast::Value;

use crate::{
inference::{type_error::TypeError, InferType},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
TypeInferencer,
};
use eql_mapper_macros::trace_infer;
use sqltk_parser::ast::Values;
use sqltk::parser::ast::Values;

#[trace_infer]
impl<'ast> InferType<'ast, Values> for TypeInferencer<'ast> {
Expand Down
6 changes: 3 additions & 3 deletions packages/eql-mapper/src/inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use unifier::{Unifier, *};
use std::{cell::RefCell, fmt::Debug, marker::PhantomData, ops::ControlFlow, rc::Rc, sync::Arc};

use infer_type::InferType;
use sqltk::{into_control_flow, AsNodeKey, Break, Visitable, Visitor};
use sqltk_parser::ast::{
use sqltk::parser::ast::{
Delete, Expr, Function, Ident, Insert, Query, Select, SelectItem, SetExpr, Statement, Values,
};
use sqltk::{into_control_flow, AsNodeKey, Break, Visitable, Visitor};

use crate::{ScopeError, ScopeTracker, TableResolver};

Expand Down Expand Up @@ -188,7 +188,7 @@ macro_rules! dispatch_all {
dispatch!($self, $method, $node, SelectItem);
dispatch!($self, $method, $node, Function);
dispatch!($self, $method, $node, Values);
dispatch!($self, $method, $node, sqltk_parser::ast::Value);
dispatch!($self, $method, $node, sqltk::parser::ast::Value);
};
}

Expand Down
Loading