Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
7phs committed Oct 9, 2024
1 parent 3d6118d commit c731c4b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 58 deletions.
19 changes: 2 additions & 17 deletions tests/sqlparser_mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,25 +937,10 @@ fn parse_create_table_with_identity_column() {
vec![
ColumnOptionDef {
name: None,
#[cfg(not(feature = "bigdecimal"))]
option: ColumnOption::Identity(Identity::Identity(IdentityProperty {
parameters: Some(IdentityFormat::FunctionCall(IdentityParameters {
seed: Expr::Value(Value::Number("1".to_string(), false)),
increment: Expr::Value(Value::Number("1".to_string(), false)),
})),
order: None,
})),
#[cfg(feature = "bigdecimal")]
option: ColumnOption::Identity(Identity::Identity(IdentityProperty {
parameters: Some(IdentityFormat::FunctionCall(IdentityParameters {
seed: Expr::Value(Value::Number(
bigdecimal::BigDecimal::from(1),
false,
)),
increment: Expr::Value(Value::Number(
bigdecimal::BigDecimal::from(1),
false,
)),
seed: Expr::Value(number("1")),
increment: Expr::Value(number("1")),
})),
order: None,
})),
Expand Down
128 changes: 87 additions & 41 deletions tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,30 +563,10 @@ fn test_snowflake_create_table_with_autoincrement_columns() {
name: None,
option: ColumnOption::Identity(Identity::Autoincrement(
IdentityProperty {
#[cfg(not(feature = "bigdecimal"))]
parameters: Some(IdentityFormat::FunctionCall(
IdentityParameters {
seed: Expr::Value(Value::Number(
"100".to_string(),
false
)),
increment: Expr::Value(Value::Number(
"1".to_string(),
false
)),
}
)),
#[cfg(feature = "bigdecimal")]
parameters: Some(IdentityFormat::FunctionCall(
IdentityParameters {
seed: Expr::Value(Value::Number(
bigdecimal::BigDecimal::from(100),
false,
)),
increment: Expr::Value(Value::Number(
bigdecimal::BigDecimal::from(1),
false,
)),
seed: Expr::Value(number("100")),
increment: Expr::Value(number("1")),
}
)),
order: Some(IdentityOrder::NoOrder),
Expand All @@ -613,27 +593,10 @@ fn test_snowflake_create_table_with_autoincrement_columns() {
options: vec![ColumnOptionDef {
name: None,
option: ColumnOption::Identity(Identity::Identity(IdentityProperty {
#[cfg(not(feature = "bigdecimal"))]
parameters: Some(IdentityFormat::StartAndIncrement(
IdentityParameters {
seed: Expr::Value(Value::Number("100".to_string(), false)),
increment: Expr::Value(Value::Number(
"1".to_string(),
false
)),
}
)),
#[cfg(feature = "bigdecimal")]
parameters: Some(IdentityFormat::StartAndIncrement(
IdentityParameters {
seed: Expr::Value(Value::Number(
bigdecimal::BigDecimal::from(100),
false,
)),
increment: Expr::Value(Value::Number(
bigdecimal::BigDecimal::from(1),
false,
)),
seed: Expr::Value(number("100")),
increment: Expr::Value(number("1")),
}
)),
order: Some(IdentityOrder::Order),
Expand Down Expand Up @@ -788,6 +751,89 @@ fn test_snowflake_create_table_with_columns_tags() {
}
}

#[test]
fn test_snowflake_create_table_with_several_column_options() {
let sql = concat!(
"CREATE TABLE my_table (",
"a INT IDENTITY WITH MASKING POLICY p1 USING (a, b) WITH TAG (A='TAG A', B='TAG B'), ",
"b TEXT COLLATE 'de_DE' PROJECTION POLICY p2 TAG (C='TAG C', D='TAG D')",
")"
);
match snowflake().verified_stmt(sql) {
Statement::CreateTable(CreateTable { columns, .. }) => {
assert_eq!(
columns,
vec![
ColumnDef {
name: "a".into(),
data_type: DataType::Int(None),
collation: None,
options: vec![
ColumnOptionDef {
name: None,
option: ColumnOption::Identity(Identity::Identity(
IdentityProperty {
parameters: None,
order: None
}
)),
},
ColumnOptionDef {
name: None,
option: ColumnOption::Policy(ColumnPolicy::MaskingPolicy(
ColumnPolicyProperty {
with: true,
policy_name: "p1".into(),
using_columns: Some(vec!["a".into(), "b".into()]),
}
)),
},
ColumnOptionDef {
name: None,
option: ColumnOption::Tags(TagsColumnOption {
with: true,
tags: vec![
Tag::new("A".into(), "TAG A".into()),
Tag::new("B".into(), "TAG B".into()),
]
}),
}
],
},
ColumnDef {
name: "b".into(),
data_type: DataType::Text,
collation: Some(ObjectName(vec![Ident::with_quote('\'', "de_DE")])),
options: vec![
ColumnOptionDef {
name: None,
option: ColumnOption::Policy(ColumnPolicy::ProjectionPolicy(
ColumnPolicyProperty {
with: false,
policy_name: "p2".into(),
using_columns: None,
}
)),
},
ColumnOptionDef {
name: None,
option: ColumnOption::Tags(TagsColumnOption {
with: false,
tags: vec![
Tag::new("C".into(), "TAG C".into()),
Tag::new("D".into(), "TAG D".into()),
]
}),
}
],
},
]
);
}
_ => unreachable!(),
}
}

#[test]
fn parse_sf_create_or_replace_view_with_comment_missing_equal() {
assert!(snowflake_and_generic()
Expand Down

0 comments on commit c731c4b

Please sign in to comment.