Skip to content

Commit c731c4b

Browse files
author
aleksei.p
committed
update
1 parent 3d6118d commit c731c4b

File tree

2 files changed

+89
-58
lines changed

2 files changed

+89
-58
lines changed

tests/sqlparser_mssql.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -937,25 +937,10 @@ fn parse_create_table_with_identity_column() {
937937
vec![
938938
ColumnOptionDef {
939939
name: None,
940-
#[cfg(not(feature = "bigdecimal"))]
941940
option: ColumnOption::Identity(Identity::Identity(IdentityProperty {
942941
parameters: Some(IdentityFormat::FunctionCall(IdentityParameters {
943-
seed: Expr::Value(Value::Number("1".to_string(), false)),
944-
increment: Expr::Value(Value::Number("1".to_string(), false)),
945-
})),
946-
order: None,
947-
})),
948-
#[cfg(feature = "bigdecimal")]
949-
option: ColumnOption::Identity(Identity::Identity(IdentityProperty {
950-
parameters: Some(IdentityFormat::FunctionCall(IdentityParameters {
951-
seed: Expr::Value(Value::Number(
952-
bigdecimal::BigDecimal::from(1),
953-
false,
954-
)),
955-
increment: Expr::Value(Value::Number(
956-
bigdecimal::BigDecimal::from(1),
957-
false,
958-
)),
942+
seed: Expr::Value(number("1")),
943+
increment: Expr::Value(number("1")),
959944
})),
960945
order: None,
961946
})),

tests/sqlparser_snowflake.rs

+87-41
Original file line numberDiff line numberDiff line change
@@ -563,30 +563,10 @@ fn test_snowflake_create_table_with_autoincrement_columns() {
563563
name: None,
564564
option: ColumnOption::Identity(Identity::Autoincrement(
565565
IdentityProperty {
566-
#[cfg(not(feature = "bigdecimal"))]
567566
parameters: Some(IdentityFormat::FunctionCall(
568567
IdentityParameters {
569-
seed: Expr::Value(Value::Number(
570-
"100".to_string(),
571-
false
572-
)),
573-
increment: Expr::Value(Value::Number(
574-
"1".to_string(),
575-
false
576-
)),
577-
}
578-
)),
579-
#[cfg(feature = "bigdecimal")]
580-
parameters: Some(IdentityFormat::FunctionCall(
581-
IdentityParameters {
582-
seed: Expr::Value(Value::Number(
583-
bigdecimal::BigDecimal::from(100),
584-
false,
585-
)),
586-
increment: Expr::Value(Value::Number(
587-
bigdecimal::BigDecimal::from(1),
588-
false,
589-
)),
568+
seed: Expr::Value(number("100")),
569+
increment: Expr::Value(number("1")),
590570
}
591571
)),
592572
order: Some(IdentityOrder::NoOrder),
@@ -613,27 +593,10 @@ fn test_snowflake_create_table_with_autoincrement_columns() {
613593
options: vec![ColumnOptionDef {
614594
name: None,
615595
option: ColumnOption::Identity(Identity::Identity(IdentityProperty {
616-
#[cfg(not(feature = "bigdecimal"))]
617-
parameters: Some(IdentityFormat::StartAndIncrement(
618-
IdentityParameters {
619-
seed: Expr::Value(Value::Number("100".to_string(), false)),
620-
increment: Expr::Value(Value::Number(
621-
"1".to_string(),
622-
false
623-
)),
624-
}
625-
)),
626-
#[cfg(feature = "bigdecimal")]
627596
parameters: Some(IdentityFormat::StartAndIncrement(
628597
IdentityParameters {
629-
seed: Expr::Value(Value::Number(
630-
bigdecimal::BigDecimal::from(100),
631-
false,
632-
)),
633-
increment: Expr::Value(Value::Number(
634-
bigdecimal::BigDecimal::from(1),
635-
false,
636-
)),
598+
seed: Expr::Value(number("100")),
599+
increment: Expr::Value(number("1")),
637600
}
638601
)),
639602
order: Some(IdentityOrder::Order),
@@ -788,6 +751,89 @@ fn test_snowflake_create_table_with_columns_tags() {
788751
}
789752
}
790753

754+
#[test]
755+
fn test_snowflake_create_table_with_several_column_options() {
756+
let sql = concat!(
757+
"CREATE TABLE my_table (",
758+
"a INT IDENTITY WITH MASKING POLICY p1 USING (a, b) WITH TAG (A='TAG A', B='TAG B'), ",
759+
"b TEXT COLLATE 'de_DE' PROJECTION POLICY p2 TAG (C='TAG C', D='TAG D')",
760+
")"
761+
);
762+
match snowflake().verified_stmt(sql) {
763+
Statement::CreateTable(CreateTable { columns, .. }) => {
764+
assert_eq!(
765+
columns,
766+
vec![
767+
ColumnDef {
768+
name: "a".into(),
769+
data_type: DataType::Int(None),
770+
collation: None,
771+
options: vec![
772+
ColumnOptionDef {
773+
name: None,
774+
option: ColumnOption::Identity(Identity::Identity(
775+
IdentityProperty {
776+
parameters: None,
777+
order: None
778+
}
779+
)),
780+
},
781+
ColumnOptionDef {
782+
name: None,
783+
option: ColumnOption::Policy(ColumnPolicy::MaskingPolicy(
784+
ColumnPolicyProperty {
785+
with: true,
786+
policy_name: "p1".into(),
787+
using_columns: Some(vec!["a".into(), "b".into()]),
788+
}
789+
)),
790+
},
791+
ColumnOptionDef {
792+
name: None,
793+
option: ColumnOption::Tags(TagsColumnOption {
794+
with: true,
795+
tags: vec![
796+
Tag::new("A".into(), "TAG A".into()),
797+
Tag::new("B".into(), "TAG B".into()),
798+
]
799+
}),
800+
}
801+
],
802+
},
803+
ColumnDef {
804+
name: "b".into(),
805+
data_type: DataType::Text,
806+
collation: Some(ObjectName(vec![Ident::with_quote('\'', "de_DE")])),
807+
options: vec![
808+
ColumnOptionDef {
809+
name: None,
810+
option: ColumnOption::Policy(ColumnPolicy::ProjectionPolicy(
811+
ColumnPolicyProperty {
812+
with: false,
813+
policy_name: "p2".into(),
814+
using_columns: None,
815+
}
816+
)),
817+
},
818+
ColumnOptionDef {
819+
name: None,
820+
option: ColumnOption::Tags(TagsColumnOption {
821+
with: false,
822+
tags: vec![
823+
Tag::new("C".into(), "TAG C".into()),
824+
Tag::new("D".into(), "TAG D".into()),
825+
]
826+
}),
827+
}
828+
],
829+
},
830+
]
831+
);
832+
}
833+
_ => unreachable!(),
834+
}
835+
}
836+
791837
#[test]
792838
fn parse_sf_create_or_replace_view_with_comment_missing_equal() {
793839
assert!(snowflake_and_generic()

0 commit comments

Comments
 (0)