From e1ba1542a3dce9e392a5d96db0c57744e8a1dc9e Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Wed, 4 Dec 2024 20:50:56 -0500 Subject: [PATCH] Improve handling of column types Support the following previously unhandled forms - schema.enum_type - schema."enum_type" - "schema"."enum_type" - schema.enum_type[] - schema."enum_type"[] - "schema"."enum_type"[] - char[] Also handle ambiguity between array and settings (both using []) by making the col_type atomic (to not allow whitespace and comments between tokens). Which matches upstream behavior. (all of which are supported by the upstream JS DBML parser) --- src/dbml.pest | 6 +- src/parser/mod.rs | 17 +- tests/dbml/array_type.in.dbml | 4 +- tests/dbml/index_tables.in.dbml | 2 +- .../multiple_schema.out.dbml | 4 +- tests/mod.rs | 64 +- tests/out/array_type.in.ron | 86 +- tests/out/comment.in.ron | 16 +- tests/out/composite_pk.in.ron | 64 +- tests/out/default_tables.in.ron | 52 +- tests/out/enum_tables.in.ron | 20 +- tests/out/general_schema.in.ron | 108 +- tests/out/header_color_tables.in.ron | 16 +- tests/out/index_tables.in.ron | 36 +- .../out/mssql_importer/general_schema.out.ron | 1465 ++++++++ .../mssql_importer/multiple_schema.out.ron | 1687 +++++++++ tests/out/multiline_string.in.ron | 4 +- .../out/mysql_importer/general_schema.out.ron | 3043 +++++++++++++++++ .../mysql_importer/multiple_schema.out.ron | 1279 +++++++ .../postgres_importer/general_schema.out.ron | 1857 ++++++++++ .../postgres_importer/multiple_schema.out.ron | 1169 +++++++ tests/out/project.in.ron | 108 +- tests/out/referential_actions.in.ron | 52 +- tests/out/sample_1.ron | 52 +- tests/out/sea_orm_codegen.ron | 48 +- tests/out/table_element.in.ron | 16 +- tests/out/table_group.in.ron | 36 +- tests/out/table_settings.in.ron | 44 +- 28 files changed, 10986 insertions(+), 369 deletions(-) create mode 100644 tests/out/mssql_importer/general_schema.out.ron create mode 100644 tests/out/mssql_importer/multiple_schema.out.ron create mode 100644 tests/out/mysql_importer/general_schema.out.ron create mode 100644 tests/out/mysql_importer/multiple_schema.out.ron create mode 100644 tests/out/postgres_importer/general_schema.out.ron create mode 100644 tests/out/postgres_importer/multiple_schema.out.ron diff --git a/src/dbml.pest b/src/dbml.pest index 54e1d1d..bd013ed 100644 --- a/src/dbml.pest +++ b/src/dbml.pest @@ -73,9 +73,9 @@ col_attribute = { ref_inline | attribute } col_settings = { "[" ~ (col_attribute ~ ("," ~ col_attribute)*)? ~ "]" } col_type_arg = { "(" ~ (value ~ ("," ~ value)*)? ~ ")" } col_type_array = { "[" ~ integer? ~ "]" } -col_type_unquoted = { var ~ col_type_arg? } -col_type_quoted = { "\"" ~ spaced_var ~ col_type_arg? ~ col_type_array* ~ "\"" } -col_type = { col_type_unquoted | col_type_quoted } +col_type_unquoted = ${ var ~ col_type_arg? ~ col_type_array* } +col_type_quoted = ${ "\"" ~ spaced_var ~ col_type_arg? ~ col_type_array* ~ "\"" ~ col_type_array* } +col_type = ${ (ident ~ ".")? ~ (col_type_quoted | col_type_unquoted ) } table_col = { ident ~ col_type ~ col_settings? } table_block = { "{" ~ (table_col | note_decl | indexes_decl)* ~ "}" } table_alias = { ^"as " ~ ident } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 801f5a4..d4f1017 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -229,6 +229,14 @@ fn parse_table_col(pair: Pair) -> ParserResult { }) } +fn build_type_name_with_schema(schema: Option<&Ident>, type_name: Pair) -> String { + let mut type_name = type_name.as_str().to_string(); + if let Some(schema) = schema { + type_name = format!("{}.{}", schema.to_string, type_name); + } + type_name +} + fn parse_col_type(pair: Pair) -> ParserResult { let mut out = ColumnType { span_range: s2r(pair.as_span()), @@ -236,12 +244,19 @@ fn parse_col_type(pair: Pair) -> ParserResult { ..Default::default() }; + let mut schema = None; + for p1 in pair.into_inner() { match p1.as_rule() { + Rule::ident => { + schema = Some(parse_ident(p1)?); + } Rule::col_type_quoted | Rule::col_type_unquoted => { for p2 in p1.into_inner() { match p2.as_rule() { - Rule::var | Rule::spaced_var => out.type_name = ColumnTypeName::Raw(p2.as_str().to_string()), + Rule::var | Rule::spaced_var => { + out.type_name = ColumnTypeName::Raw(build_type_name_with_schema(schema.as_ref(), p2)) + } Rule::col_type_arg => out.args = parse_col_type_arg(p2)?, Rule::col_type_array => { let val = p2.into_inner().try_fold(None, |_, p3| { diff --git a/tests/dbml/array_type.in.dbml b/tests/dbml/array_type.in.dbml index 1574840..b082d8b 100644 --- a/tests/dbml/array_type.in.dbml +++ b/tests/dbml/array_type.in.dbml @@ -2,8 +2,10 @@ Table sal_emp { name text pay_by_quarter "int[]" [not null] schedule "text[][]" [null] + unquoted text[] [not null] + mixed "character varying"[] } Table tictactoe { squares "integer[3][3]" -} \ No newline at end of file +} diff --git a/tests/dbml/index_tables.in.dbml b/tests/dbml/index_tables.in.dbml index df849b2..00b79de 100644 --- a/tests/dbml/index_tables.in.dbml +++ b/tests/dbml/index_tables.in.dbml @@ -17,4 +17,4 @@ Table users { (`getdate()`, `upper(gender)`) (`reverse(country_code)`) } -} \ No newline at end of file +} diff --git a/tests/dbml/postgres_importer/multiple_schema.out.dbml b/tests/dbml/postgres_importer/multiple_schema.out.dbml index ac46237..56eacf3 100644 --- a/tests/dbml/postgres_importer/multiple_schema.out.dbml +++ b/tests/dbml/postgres_importer/multiple_schema.out.dbml @@ -17,6 +17,8 @@ Table "users" { "pjs2" job_status "pg" schemaB.gender "pg2" gender + "pg3" schemaB."gender" + "pg4" "schemaB"."gender" } Table "products" { @@ -66,4 +68,4 @@ Table "schemaA"."locations" { "id" int [pk] "name" varchar Note: 'This is a note in table "locations"' -} \ No newline at end of file +} diff --git a/tests/mod.rs b/tests/mod.rs index bdfffbd..4d63b56 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -22,10 +22,16 @@ fn read_dbml_dir>(dir_path: P) -> Result> { Ok(out) } -fn create_out_dir() -> Result<()> { +fn create_out_dir(sub_dir: Option<&PathBuf>) -> Result<()> { if fs::metadata(OUT_DIR).is_err() { fs::create_dir(OUT_DIR)?; } + if let Some(sub_dir) = sub_dir { + let path = Path::new(OUT_DIR).join(sub_dir); + if fs::metadata(&path).is_err() { + fs::create_dir(path)?; + } + } Ok(()) } @@ -33,11 +39,25 @@ fn create_out_dir() -> Result<()> { /// Run with UPDATE_DBML_OUTPUT=1 to update the expected output files /// e.g. (on Linux or macOS) /// UPDATE_DBML_OUTPUT=1 cargo test -#[test] -fn parse_dbml_unchecked() -> Result<()> { - create_out_dir()?; +fn update_expected() -> bool { + match std::env::var("UPDATE_DBML_OUTPUT") { + Ok(v) => v == "1", + _ => false, + } +} - let testing_dbml_paths = read_dbml_dir("tests/dbml")?; +fn compare_parsed_with_expected(sub_dir: Option>, update: bool) -> Result<()> { + let sub_dir = sub_dir.map(Into::into); + + create_out_dir(sub_dir.as_ref())?; + let mut source_dir = Path::new("tests/dbml").to_path_buf(); + let mut out_file_dir = Path::new(OUT_DIR).to_path_buf(); + if let Some(sub_dir) = sub_dir { + source_dir.push(&sub_dir); + out_file_dir.push(&sub_dir); + } + + let testing_dbml_paths = read_dbml_dir(source_dir)?; for path in testing_dbml_paths { let content = fs::read_to_string(&path)?; @@ -49,21 +69,15 @@ fn parse_dbml_unchecked() -> Result<()> { let mut out_file_path = path.clone(); out_file_path.set_extension("ron"); let out_file_name = out_file_path.file_name().unwrap().to_str().unwrap(); - let out_file_path = format!("{}/{}", OUT_DIR, out_file_name); + let out_file_path = out_file_dir.join(out_file_name); - let update = match std::env::var("UPDATE_DBML_OUTPUT") { - Ok(v) => v == "1", - _ => false - }; if update { fs::write(out_file_path, out_content)?; } else { let expected = fs::read_to_string(&out_file_path).or_else(|e| { match e.kind() { - std::io::ErrorKind::NotFound => { - Ok("no output file".to_string()) - }, - e => Err(e) + std::io::ErrorKind::NotFound => Ok("no output file".to_string()), + e => Err(e), } })?; assert_eq!(out_content, expected, "Unexpected output for {:?}", path); @@ -72,7 +86,27 @@ fn parse_dbml_unchecked() -> Result<()> { Ok(()) } - + +#[test] +fn parse_dbml_root() -> Result<()> { + compare_parsed_with_expected(None::, update_expected()) +} + +#[test] +fn parse_dbml_mysql_importer() -> Result<()> { + compare_parsed_with_expected(Some("mysql_importer"), update_expected()) +} + +#[test] +fn parse_dbml_mssql_importer() -> Result<()> { + compare_parsed_with_expected(Some("mssql_importer"), update_expected()) +} + +#[test] +fn parse_dbml_pgsql_importer() -> Result<()> { + compare_parsed_with_expected(Some("postgres_importer"), update_expected()) +} + #[test] fn parse_dbml_validator() -> Result<()> { let testing_dbml_paths = read_dbml_dir("tests/dbml/validator")?; diff --git a/tests/out/array_type.in.ron b/tests/out/array_type.in.ron index 663d6ee..e71efe4 100644 --- a/tests/out/array_type.in.ron +++ b/tests/out/array_type.in.ron @@ -1,10 +1,10 @@ SchemaBlock { - span_range: 0..141, - input: "Table sal_emp {\n name text\n pay_by_quarter \"int[]\" [not null]\n schedule \"text[][]\" [null]\n}\n\nTable tictactoe {\n squares \"integer[3][3]\"\n}", + span_range: 0..201, + input: "Table sal_emp {\n name text\n pay_by_quarter \"int[]\" [not null]\n schedule \"text[][]\" [null]\n unquoted text[] [not null]\n mixed \"character varying\"[]\n}\n\nTable tictactoe {\n squares \"integer[3][3]\"\n}\n", blocks: [ Table( TableBlock { - span_range: 0..94, + span_range: 0..153, cols: [ TableColumn { span_range: 18..30, @@ -14,8 +14,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 23..30, - raw: "text\n ", + span_range: 23..27, + raw: "text", type_name: Raw( "text", ), @@ -113,6 +113,70 @@ SchemaBlock { }, ), }, + TableColumn { + span_range: 95..121, + name: Ident { + span_range: 95..103, + raw: "unquoted", + to_string: "unquoted", + }, + type: ColumnType { + span_range: 104..110, + raw: "text[]", + type_name: Raw( + "text", + ), + args: [], + arrays: [ + None, + ], + }, + settings: Some( + ColumnSettings { + span_range: 111..121, + attributes: [ + Attribute { + span_range: 112..120, + key: Ident { + span_range: 112..120, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 124..152, + name: Ident { + span_range: 124..129, + raw: "mixed", + to_string: "mixed", + }, + type: ColumnType { + span_range: 130..151, + raw: "\"character varying\"[]", + type_name: Raw( + "character varying", + ), + args: [], + arrays: [ + None, + ], + }, + settings: None, + }, ], ident: TableIdent { span_range: 6..14, @@ -131,17 +195,17 @@ SchemaBlock { ), Table( TableBlock { - span_range: 96..141, + span_range: 155..200, cols: [ TableColumn { - span_range: 116..140, + span_range: 175..199, name: Ident { - span_range: 116..123, + span_range: 175..182, raw: "squares", to_string: "squares", }, type: ColumnType { - span_range: 124..139, + span_range: 183..198, raw: "\"integer[3][3]\"", type_name: Raw( "integer", @@ -160,9 +224,9 @@ SchemaBlock { }, ], ident: TableIdent { - span_range: 102..112, + span_range: 161..171, name: Ident { - span_range: 102..111, + span_range: 161..170, raw: "tictactoe", to_string: "tictactoe", }, diff --git a/tests/out/comment.in.ron b/tests/out/comment.in.ron index 1d69780..ccfe126 100644 --- a/tests/out/comment.in.ron +++ b/tests/out/comment.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 27..31, - raw: "int ", + span_range: 27..30, + raw: "int", type_name: Raw( "int", ), @@ -54,8 +54,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 61..65, - raw: "int ", + span_range: 61..64, + raw: "int", type_name: Raw( "int", ), @@ -105,8 +105,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 93..101, - raw: "varchar ", + span_range: 93..100, + raw: "varchar", type_name: Raw( "varchar", ), @@ -155,8 +155,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 143..151, - raw: "varchar ", + span_range: 143..150, + raw: "varchar", type_name: Raw( "varchar", ), diff --git a/tests/out/composite_pk.in.ron b/tests/out/composite_pk.in.ron index 0a3782a..a6102e0 100644 --- a/tests/out/composite_pk.in.ron +++ b/tests/out/composite_pk.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 19..23, - raw: "int ", + span_range: 19..22, + raw: "int", type_name: Raw( "int", ), @@ -54,8 +54,8 @@ SchemaBlock { to_string: "full_name", }, type: ColumnType { - span_range: 49..59, - raw: "varchar\n ", + span_range: 49..56, + raw: "varchar", type_name: Raw( "varchar", ), @@ -72,8 +72,8 @@ SchemaBlock { to_string: "email", }, type: ColumnType { - span_range: 65..73, - raw: "varchar ", + span_range: 65..72, + raw: "varchar", type_name: Raw( "varchar", ), @@ -112,8 +112,8 @@ SchemaBlock { to_string: "gender", }, type: ColumnType { - span_range: 91..101, - raw: "varchar\n ", + span_range: 91..98, + raw: "varchar", type_name: Raw( "varchar", ), @@ -130,8 +130,8 @@ SchemaBlock { to_string: "date_of_birth", }, type: ColumnType { - span_range: 115..125, - raw: "varchar\n ", + span_range: 115..122, + raw: "varchar", type_name: Raw( "varchar", ), @@ -148,8 +148,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 136..146, - raw: "varchar\n ", + span_range: 136..143, + raw: "varchar", type_name: Raw( "varchar", ), @@ -166,8 +166,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 159..166, - raw: "int \n ", + span_range: 159..162, + raw: "int", type_name: Raw( "int", ), @@ -184,8 +184,8 @@ SchemaBlock { to_string: "active", }, type: ColumnType { - span_range: 173..181, - raw: "boolean ", + span_range: 173..180, + raw: "boolean", type_name: Raw( "boolean", ), @@ -285,8 +285,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 245..249, - raw: "int ", + span_range: 245..248, + raw: "int", type_name: Raw( "int", ), @@ -325,8 +325,8 @@ SchemaBlock { to_string: "full_name", }, type: ColumnType { - span_range: 275..285, - raw: "varchar\n ", + span_range: 275..282, + raw: "varchar", type_name: Raw( "varchar", ), @@ -343,8 +343,8 @@ SchemaBlock { to_string: "email", }, type: ColumnType { - span_range: 291..299, - raw: "varchar ", + span_range: 291..298, + raw: "varchar", type_name: Raw( "varchar", ), @@ -383,8 +383,8 @@ SchemaBlock { to_string: "gender", }, type: ColumnType { - span_range: 317..327, - raw: "varchar\n ", + span_range: 317..324, + raw: "varchar", type_name: Raw( "varchar", ), @@ -401,8 +401,8 @@ SchemaBlock { to_string: "date_of_birth", }, type: ColumnType { - span_range: 341..351, - raw: "varchar\n ", + span_range: 341..348, + raw: "varchar", type_name: Raw( "varchar", ), @@ -419,8 +419,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 362..372, - raw: "varchar\n ", + span_range: 362..369, + raw: "varchar", type_name: Raw( "varchar", ), @@ -437,8 +437,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 385..392, - raw: "int \n ", + span_range: 385..388, + raw: "int", type_name: Raw( "int", ), @@ -455,8 +455,8 @@ SchemaBlock { to_string: "active", }, type: ColumnType { - span_range: 399..407, - raw: "boolean ", + span_range: 399..406, + raw: "boolean", type_name: Raw( "boolean", ), diff --git a/tests/out/default_tables.in.ron b/tests/out/default_tables.in.ron index 5724bd1..209d23c 100644 --- a/tests/out/default_tables.in.ron +++ b/tests/out/default_tables.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 20..24, - raw: "int ", + span_range: 20..23, + raw: "int", type_name: Raw( "int", ), @@ -75,8 +75,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 53..57, - raw: "int ", + span_range: 53..56, + raw: "int", type_name: Raw( "int", ), @@ -126,8 +126,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 85..93, - raw: "varchar ", + span_range: 85..92, + raw: "varchar", type_name: Raw( "varchar", ), @@ -178,8 +178,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 129..137, - raw: "varchar ", + span_range: 129..136, + raw: "varchar", type_name: Raw( "varchar", ), @@ -250,8 +250,8 @@ SchemaBlock { to_string: "order_id", }, type: ColumnType { - span_range: 190..196, - raw: "int\n ", + span_range: 190..193, + raw: "int", type_name: Raw( "int", ), @@ -268,8 +268,8 @@ SchemaBlock { to_string: "product_id", }, type: ColumnType { - span_range: 207..213, - raw: "int\n ", + span_range: 207..210, + raw: "int", type_name: Raw( "int", ), @@ -286,8 +286,8 @@ SchemaBlock { to_string: "quantity", }, type: ColumnType { - span_range: 222..226, - raw: "int\n", + span_range: 222..225, + raw: "int", type_name: Raw( "int", ), @@ -324,8 +324,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 251..255, - raw: "int ", + span_range: 251..254, + raw: "int", type_name: Raw( "int", ), @@ -364,8 +364,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 267..275, - raw: "varchar ", + span_range: 267..274, + raw: "varchar", type_name: Raw( "varchar", ), @@ -412,8 +412,8 @@ SchemaBlock { to_string: "merchant_id", }, type: ColumnType { - span_range: 305..309, - raw: "int ", + span_range: 305..308, + raw: "int", type_name: Raw( "int", ), @@ -454,8 +454,8 @@ SchemaBlock { to_string: "price", }, type: ColumnType { - span_range: 328..334, - raw: "float ", + span_range: 328..333, + raw: "float", type_name: Raw( "float", ), @@ -506,8 +506,8 @@ SchemaBlock { to_string: "stock", }, type: ColumnType { - span_range: 360..368, - raw: "boolean ", + span_range: 360..367, + raw: "boolean", type_name: Raw( "boolean", ), @@ -558,8 +558,8 @@ SchemaBlock { to_string: "expiration", }, type: ColumnType { - span_range: 397..402, - raw: "date ", + span_range: 397..401, + raw: "date", type_name: Raw( "date", ), diff --git a/tests/out/enum_tables.in.ron b/tests/out/enum_tables.in.ron index 00b8c0c..0c6d503 100644 --- a/tests/out/enum_tables.in.ron +++ b/tests/out/enum_tables.in.ron @@ -153,8 +153,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 218..226, - raw: "integer ", + span_range: 218..225, + raw: "integer", type_name: Raw( "integer", ), @@ -193,8 +193,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 240..251, - raw: "job_status ", + span_range: 240..250, + raw: "job_status", type_name: Raw( "job_status", ), @@ -341,8 +341,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 400..404, - raw: "int ", + span_range: 400..403, + raw: "int", type_name: Raw( "int", ), @@ -359,8 +359,8 @@ SchemaBlock { to_string: "PK", }, type: ColumnType { - span_range: 407..416, - raw: "unique\n ", + span_range: 407..413, + raw: "unique", type_name: Raw( "unique", ), @@ -395,8 +395,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 451..459, - raw: "varchar\n", + span_range: 451..458, + raw: "varchar", type_name: Raw( "varchar", ), diff --git a/tests/out/general_schema.in.ron b/tests/out/general_schema.in.ron index 1487fe3..1c41e42 100644 --- a/tests/out/general_schema.in.ron +++ b/tests/out/general_schema.in.ron @@ -100,8 +100,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 172..176, - raw: "int ", + span_range: 172..175, + raw: "int", type_name: Raw( "int", ), @@ -149,8 +149,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 204..208, - raw: "int ", + span_range: 204..207, + raw: "int", type_name: Raw( "int", ), @@ -200,8 +200,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 238..254, - raw: "orders_status\n ", + span_range: 238..251, + raw: "orders_status", type_name: Raw( "orders_status", ), @@ -218,8 +218,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 267..275, - raw: "varchar\n", + span_range: 267..274, + raw: "varchar", type_name: Raw( "varchar", ), @@ -279,8 +279,8 @@ SchemaBlock { to_string: "order_id", }, type: ColumnType { - span_range: 313..319, - raw: "int\n ", + span_range: 313..316, + raw: "int", type_name: Raw( "int", ), @@ -297,8 +297,8 @@ SchemaBlock { to_string: "product_id", }, type: ColumnType { - span_range: 332..338, - raw: "int\n ", + span_range: 332..335, + raw: "int", type_name: Raw( "int", ), @@ -315,8 +315,8 @@ SchemaBlock { to_string: "quantity", }, type: ColumnType { - span_range: 349..353, - raw: "int ", + span_range: 349..352, + raw: "int", type_name: Raw( "int", ), @@ -387,8 +387,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 395..399, - raw: "int ", + span_range: 395..398, + raw: "int", type_name: Raw( "int", ), @@ -427,8 +427,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 413..423, - raw: "varchar\n ", + span_range: 413..420, + raw: "varchar", type_name: Raw( "varchar", ), @@ -445,8 +445,8 @@ SchemaBlock { to_string: "merchant_id", }, type: ColumnType { - span_range: 437..441, - raw: "int ", + span_range: 437..440, + raw: "int", type_name: Raw( "int", ), @@ -487,8 +487,8 @@ SchemaBlock { to_string: "price", }, type: ColumnType { - span_range: 462..468, - raw: "int\n ", + span_range: 462..465, + raw: "int", type_name: Raw( "int", ), @@ -523,8 +523,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 509..518, - raw: "datetime ", + span_range: 509..517, + raw: "datetime", type_name: Raw( "datetime", ), @@ -703,8 +703,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 660..664, - raw: "int ", + span_range: 660..663, + raw: "int", type_name: Raw( "int", ), @@ -743,8 +743,8 @@ SchemaBlock { to_string: "full_name", }, type: ColumnType { - span_range: 683..693, - raw: "varchar\n ", + span_range: 683..690, + raw: "varchar", type_name: Raw( "varchar", ), @@ -761,8 +761,8 @@ SchemaBlock { to_string: "email", }, type: ColumnType { - span_range: 701..709, - raw: "varchar ", + span_range: 701..708, + raw: "varchar", type_name: Raw( "varchar", ), @@ -801,8 +801,8 @@ SchemaBlock { to_string: "gender", }, type: ColumnType { - span_range: 729..739, - raw: "varchar\n ", + span_range: 729..736, + raw: "varchar", type_name: Raw( "varchar", ), @@ -819,8 +819,8 @@ SchemaBlock { to_string: "date_of_birth", }, type: ColumnType { - span_range: 755..765, - raw: "varchar\n ", + span_range: 755..762, + raw: "varchar", type_name: Raw( "varchar", ), @@ -837,8 +837,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 778..788, - raw: "varchar\n ", + span_range: 778..785, + raw: "varchar", type_name: Raw( "varchar", ), @@ -855,8 +855,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 803..807, - raw: "int\n", + span_range: 803..806, + raw: "int", type_name: Raw( "int", ), @@ -957,8 +957,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 916..920, - raw: "int ", + span_range: 916..919, + raw: "int", type_name: Raw( "int", ), @@ -997,8 +997,8 @@ SchemaBlock { to_string: "merchant_name", }, type: ColumnType { - span_range: 943..953, - raw: "varchar\n ", + span_range: 943..950, + raw: "varchar", type_name: Raw( "varchar", ), @@ -1015,8 +1015,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 968..974, - raw: "int\n ", + span_range: 968..971, + raw: "int", type_name: Raw( "int", ), @@ -1033,8 +1033,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 987..997, - raw: "varchar\n ", + span_range: 987..994, + raw: "varchar", type_name: Raw( "varchar", ), @@ -1051,8 +1051,8 @@ SchemaBlock { to_string: "admin_id", }, type: ColumnType { - span_range: 1008..1012, - raw: "int\n", + span_range: 1008..1011, + raw: "int", type_name: Raw( "int", ), @@ -1089,8 +1089,8 @@ SchemaBlock { to_string: "code", }, type: ColumnType { - span_range: 1044..1048, - raw: "int ", + span_range: 1044..1047, + raw: "int", type_name: Raw( "int", ), @@ -1129,8 +1129,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 1062..1072, - raw: "varchar\n ", + span_range: 1062..1069, + raw: "varchar", type_name: Raw( "varchar", ), @@ -1147,8 +1147,8 @@ SchemaBlock { to_string: "continent_name", }, type: ColumnType { - span_range: 1089..1097, - raw: "varchar\n", + span_range: 1089..1096, + raw: "varchar", type_name: Raw( "varchar", ), diff --git a/tests/out/header_color_tables.in.ron b/tests/out/header_color_tables.in.ron index 893feae..83ce13e 100644 --- a/tests/out/header_color_tables.in.ron +++ b/tests/out/header_color_tables.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 78..93, - raw: "int //columns\n\t", + span_range: 78..81, + raw: "int", type_name: Raw( "int", ), @@ -32,8 +32,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 101..106, - raw: "int\n\t", + span_range: 101..104, + raw: "int", type_name: Raw( "int", ), @@ -50,8 +50,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 113..122, - raw: "varchar\n\t", + span_range: 113..120, + raw: "varchar", type_name: Raw( "varchar", ), @@ -68,8 +68,8 @@ SchemaBlock { to_string: "create_at", }, type: ColumnType { - span_range: 132..142, - raw: "date_time\n", + span_range: 132..141, + raw: "date_time", type_name: Raw( "date_time", ), diff --git a/tests/out/index_tables.in.ron b/tests/out/index_tables.in.ron index 51d5b8c..640bd22 100644 --- a/tests/out/index_tables.in.ron +++ b/tests/out/index_tables.in.ron @@ -1,6 +1,6 @@ SchemaBlock { - span_range: 0..430, - input: "Table users {\n id int [primary key]\n full_name varchar\n email varchar [unique]\n gender varchar\n date_of_birth varchar\n created_at varchar\n country_code int \n active boolean [not null]\n \n indexes {\n (id) [unique, note: 'index note']\n full_name [name: 'User Name']\n (email,created_at) [type: hash]\n `now()`\n (active, `lower(full_name)`)\n (`getdate()`, `upper(gender)`)\n (`reverse(country_code)`)\n }\n}", + span_range: 0..431, + input: "Table users {\n id int [primary key]\n full_name varchar\n email varchar [unique]\n gender varchar\n date_of_birth varchar\n created_at varchar\n country_code int \n active boolean [not null]\n \n indexes {\n (id) [unique, note: 'index note']\n full_name [name: 'User Name']\n (email,created_at) [type: hash]\n `now()`\n (active, `lower(full_name)`)\n (`getdate()`, `upper(gender)`)\n (`reverse(country_code)`)\n }\n}\n", blocks: [ Table( TableBlock { @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 19..23, - raw: "int ", + span_range: 19..22, + raw: "int", type_name: Raw( "int", ), @@ -54,8 +54,8 @@ SchemaBlock { to_string: "full_name", }, type: ColumnType { - span_range: 49..59, - raw: "varchar\n ", + span_range: 49..56, + raw: "varchar", type_name: Raw( "varchar", ), @@ -72,8 +72,8 @@ SchemaBlock { to_string: "email", }, type: ColumnType { - span_range: 65..73, - raw: "varchar ", + span_range: 65..72, + raw: "varchar", type_name: Raw( "varchar", ), @@ -112,8 +112,8 @@ SchemaBlock { to_string: "gender", }, type: ColumnType { - span_range: 91..101, - raw: "varchar\n ", + span_range: 91..98, + raw: "varchar", type_name: Raw( "varchar", ), @@ -130,8 +130,8 @@ SchemaBlock { to_string: "date_of_birth", }, type: ColumnType { - span_range: 115..125, - raw: "varchar\n ", + span_range: 115..122, + raw: "varchar", type_name: Raw( "varchar", ), @@ -148,8 +148,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 136..146, - raw: "varchar\n ", + span_range: 136..143, + raw: "varchar", type_name: Raw( "varchar", ), @@ -166,8 +166,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 159..166, - raw: "int \n ", + span_range: 159..162, + raw: "int", type_name: Raw( "int", ), @@ -184,8 +184,8 @@ SchemaBlock { to_string: "active", }, type: ColumnType { - span_range: 173..181, - raw: "boolean ", + span_range: 173..180, + raw: "boolean", type_name: Raw( "boolean", ), diff --git a/tests/out/mssql_importer/general_schema.out.ron b/tests/out/mssql_importer/general_schema.out.ron new file mode 100644 index 0000000..8d70ab6 --- /dev/null +++ b/tests/out/mssql_importer/general_schema.out.ron @@ -0,0 +1,1465 @@ +SchemaBlock { + span_range: 0..1463, + input: "Enum \"orders_status_enum\" {\n \"created\"\n \"running\"\n \"done\"\n \"failure\"\n}\n\nEnum \"products_status_enum\" {\n \"Out of Stock\"\n \"In Stock\"\n}\n\nTable \"orders\" {\n \"id\" int [pk, increment]\n \"user_id\" int [unique, not null]\n \"status\" orders_status_enum [not null]\n \"created_at\" varchar(255) [note: 'When order created']\n Note: 'This is a note in table \"orders\"'\n}\n\nTable \"order_items\" {\n \"order_id\" int\n \"product_id\" int\n \"quantity\" int [default: 1]\n}\n\nTable \"products\" {\n \"id\" int [pk]\n \"name\" varchar(255)\n \"merchant_id\" int [not null]\n \"price\" int\n \"status\" products_status_enum [not null]\n \"created_at\" datetime [default: `now()`]\n\nIndexes {\n (merchant_id, status) [name: \"product_status\"]\n id [unique, name: \"products_index_1\"]\n}\n}\n\nTable \"users\" {\n \"id\" int [pk]\n \"full_name\" varchar(255)\n \"email\" varchar(255) [unique]\n \"gender\" varchar(255)\n \"date_of_birth\" varchar(255)\n \"created_at\" varchar(255)\n \"country_code\" int\n}\n\nTable \"merchants\" {\n \"id\" int [pk]\n \"merchant_name\" varchar(255)\n \"country_code\" int\n \"created_at\" varchar(255)\n \"admin_id\" int\n}\n\nTable \"countries\" {\n \"code\" int [pk]\n \"name\" varchar(255)\n \"continent_name\" varchar(255)\n}\n\nRef:\"orders\".\"id\" < \"order_items\".\"order_id\"\n\nRef:\"products\".\"id\" < \"order_items\".\"product_id\"\n\nRef:\"countries\".\"code\" < \"users\".\"country_code\"\n\nRef:\"countries\".\"code\" < \"merchants\".\"country_code\"\n\nRef:\"merchants\".\"id\" < \"products\".\"merchant_id\"\n\nRef:\"users\".\"id\" < \"merchants\".\"admin_id\"", + blocks: [ + Enum( + EnumBlock { + span_range: 0..74, + ident: EnumIdent { + span_range: 5..26, + schema: None, + name: Ident { + span_range: 5..25, + raw: "\"orders_status_enum\"", + to_string: "orders_status_enum", + }, + }, + values: [ + EnumValue { + span_range: 30..42, + value: Ident { + span_range: 30..39, + raw: "\"created\"", + to_string: "created", + }, + settings: None, + }, + EnumValue { + span_range: 42..54, + value: Ident { + span_range: 42..51, + raw: "\"running\"", + to_string: "running", + }, + settings: None, + }, + EnumValue { + span_range: 54..63, + value: Ident { + span_range: 54..60, + raw: "\"done\"", + to_string: "done", + }, + settings: None, + }, + EnumValue { + span_range: 63..73, + value: Ident { + span_range: 63..72, + raw: "\"failure\"", + to_string: "failure", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 76..137, + ident: EnumIdent { + span_range: 81..104, + schema: None, + name: Ident { + span_range: 81..103, + raw: "\"products_status_enum\"", + to_string: "products_status_enum", + }, + }, + values: [ + EnumValue { + span_range: 108..125, + value: Ident { + span_range: 108..122, + raw: "\"Out of Stock\"", + to_string: "Out of Stock", + }, + settings: None, + }, + EnumValue { + span_range: 125..136, + value: Ident { + span_range: 125..135, + raw: "\"In Stock\"", + to_string: "In Stock", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 139..360, + cols: [ + TableColumn { + span_range: 158..182, + name: Ident { + span_range: 158..162, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 163..166, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 167..182, + attributes: [ + Attribute { + span_range: 168..170, + key: Ident { + span_range: 168..170, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + Attribute { + span_range: 172..181, + key: Ident { + span_range: 172..181, + raw: "increment", + to_string: "increment", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: true, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 185..217, + name: Ident { + span_range: 185..194, + raw: "\"user_id\"", + to_string: "user_id", + }, + type: ColumnType { + span_range: 195..198, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 199..217, + attributes: [ + Attribute { + span_range: 200..206, + key: Ident { + span_range: 200..206, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + Attribute { + span_range: 208..216, + key: Ident { + span_range: 208..216, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: true, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 220..258, + name: Ident { + span_range: 220..228, + raw: "\"status\"", + to_string: "status", + }, + type: ColumnType { + span_range: 229..247, + raw: "orders_status_enum", + type_name: Raw( + "orders_status_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 248..258, + attributes: [ + Attribute { + span_range: 249..257, + key: Ident { + span_range: 249..257, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 261..315, + name: Ident { + span_range: 261..273, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 274..286, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 287..315, + attributes: [ + Attribute { + span_range: 288..314, + key: Ident { + span_range: 288..292, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 294..314, + raw: "'When order created'", + value: String( + "When order created", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "When order created", + ), + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 145..154, + name: Ident { + span_range: 145..153, + raw: "\"orders\"", + to_string: "orders", + }, + schema: None, + alias: None, + }, + note: Some( + NoteBlock { + span_range: 318..358, + value: Literal { + span_range: 324..358, + raw: "'This is a note in table \"orders\"'", + value: String( + "This is a note in table \"orders\"", + ), + }, + }, + ), + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 362..451, + cols: [ + TableColumn { + span_range: 386..403, + name: Ident { + span_range: 386..396, + raw: "\"order_id\"", + to_string: "order_id", + }, + type: ColumnType { + span_range: 397..400, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 403..422, + name: Ident { + span_range: 403..415, + raw: "\"product_id\"", + to_string: "product_id", + }, + type: ColumnType { + span_range: 416..419, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 422..449, + name: Ident { + span_range: 422..432, + raw: "\"quantity\"", + to_string: "quantity", + }, + type: ColumnType { + span_range: 433..436, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 437..449, + attributes: [ + Attribute { + span_range: 438..448, + key: Ident { + span_range: 438..445, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 447..448, + raw: "1", + value: Integer( + 1, + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Integer( + 1, + ), + ), + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 368..382, + name: Ident { + span_range: 368..381, + raw: "\"order_items\"", + to_string: "order_items", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 453..744, + cols: [ + TableColumn { + span_range: 474..487, + name: Ident { + span_range: 474..478, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 479..482, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 483..487, + attributes: [ + Attribute { + span_range: 484..486, + key: Ident { + span_range: 484..486, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 490..512, + name: Ident { + span_range: 490..496, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 497..509, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 512..540, + name: Ident { + span_range: 512..525, + raw: "\"merchant_id\"", + to_string: "merchant_id", + }, + type: ColumnType { + span_range: 526..529, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 530..540, + attributes: [ + Attribute { + span_range: 531..539, + key: Ident { + span_range: 531..539, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 543..557, + name: Ident { + span_range: 543..550, + raw: "\"price\"", + to_string: "price", + }, + type: ColumnType { + span_range: 551..554, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 557..597, + name: Ident { + span_range: 557..565, + raw: "\"status\"", + to_string: "status", + }, + type: ColumnType { + span_range: 566..586, + raw: "products_status_enum", + type_name: Raw( + "products_status_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 587..597, + attributes: [ + Attribute { + span_range: 588..596, + key: Ident { + span_range: 588..596, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 600..640, + name: Ident { + span_range: 600..612, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 613..621, + raw: "datetime", + type_name: Raw( + "datetime", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 622..640, + attributes: [ + Attribute { + span_range: 623..639, + key: Ident { + span_range: 623..630, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 632..639, + raw: "`now()`", + value: Expr( + "now()", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Expr( + "now()", + ), + ), + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 459..470, + name: Ident { + span_range: 459..469, + raw: "\"products\"", + to_string: "products", + }, + schema: None, + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 650..742, + defs: [ + IndexesDef { + span_range: 654..700, + cols: [ + String( + Ident { + span_range: 655..666, + raw: "merchant_id", + to_string: "merchant_id", + }, + ), + String( + Ident { + span_range: 668..674, + raw: "status", + to_string: "status", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 676..700, + attributes: [ + Attribute { + span_range: 677..699, + key: Ident { + span_range: 677..681, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 683..699, + raw: "\"product_status\"", + value: String( + "product_status", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "product_status", + ), + }, + ), + }, + IndexesDef { + span_range: 703..740, + cols: [ + String( + Ident { + span_range: 703..705, + raw: "id", + to_string: "id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 706..740, + attributes: [ + Attribute { + span_range: 707..713, + key: Ident { + span_range: 707..713, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + Attribute { + span_range: 715..739, + key: Ident { + span_range: 715..719, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 721..739, + raw: "\"products_index_1\"", + value: String( + "products_index_1", + ), + }, + ), + }, + ], + type: None, + is_unique: true, + is_pk: false, + note: None, + name: Some( + "products_index_1", + ), + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 746..942, + cols: [ + TableColumn { + span_range: 764..777, + name: Ident { + span_range: 764..768, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 769..772, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 773..777, + attributes: [ + Attribute { + span_range: 774..776, + key: Ident { + span_range: 774..776, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 780..807, + name: Ident { + span_range: 780..791, + raw: "\"full_name\"", + to_string: "full_name", + }, + type: ColumnType { + span_range: 792..804, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 807..836, + name: Ident { + span_range: 807..814, + raw: "\"email\"", + to_string: "email", + }, + type: ColumnType { + span_range: 815..827, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 828..836, + attributes: [ + Attribute { + span_range: 829..835, + key: Ident { + span_range: 829..835, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + ], + is_pk: false, + is_unique: true, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 839..863, + name: Ident { + span_range: 839..847, + raw: "\"gender\"", + to_string: "gender", + }, + type: ColumnType { + span_range: 848..860, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 863..894, + name: Ident { + span_range: 863..878, + raw: "\"date_of_birth\"", + to_string: "date_of_birth", + }, + type: ColumnType { + span_range: 879..891, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 894..922, + name: Ident { + span_range: 894..906, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 907..919, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 922..941, + name: Ident { + span_range: 922..936, + raw: "\"country_code\"", + to_string: "country_code", + }, + type: ColumnType { + span_range: 937..940, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 752..760, + name: Ident { + span_range: 752..759, + raw: "\"users\"", + to_string: "users", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 944..1078, + cols: [ + TableColumn { + span_range: 966..979, + name: Ident { + span_range: 966..970, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 971..974, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 975..979, + attributes: [ + Attribute { + span_range: 976..978, + key: Ident { + span_range: 976..978, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 982..1013, + name: Ident { + span_range: 982..997, + raw: "\"merchant_name\"", + to_string: "merchant_name", + }, + type: ColumnType { + span_range: 998..1010, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1013..1034, + name: Ident { + span_range: 1013..1027, + raw: "\"country_code\"", + to_string: "country_code", + }, + type: ColumnType { + span_range: 1028..1031, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1034..1062, + name: Ident { + span_range: 1034..1046, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 1047..1059, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1062..1077, + name: Ident { + span_range: 1062..1072, + raw: "\"admin_id\"", + to_string: "admin_id", + }, + type: ColumnType { + span_range: 1073..1076, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 950..962, + name: Ident { + span_range: 950..961, + raw: "\"merchants\"", + to_string: "merchants", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1080..1173, + cols: [ + TableColumn { + span_range: 1102..1117, + name: Ident { + span_range: 1102..1108, + raw: "\"code\"", + to_string: "code", + }, + type: ColumnType { + span_range: 1109..1112, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1113..1117, + attributes: [ + Attribute { + span_range: 1114..1116, + key: Ident { + span_range: 1114..1116, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1120..1142, + name: Ident { + span_range: 1120..1126, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1127..1139, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1142..1172, + name: Ident { + span_range: 1142..1158, + raw: "\"continent_name\"", + to_string: "continent_name", + }, + type: ColumnType { + span_range: 1159..1171, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1086..1098, + name: Ident { + span_range: 1086..1097, + raw: "\"countries\"", + to_string: "countries", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1179..1221, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1179..1192, + schema: None, + table: Ident { + span_range: 1179..1187, + raw: "\"orders\"", + to_string: "orders", + }, + compositions: [ + Ident { + span_range: 1188..1192, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1195..1219, + schema: None, + table: Ident { + span_range: 1195..1208, + raw: "\"order_items\"", + to_string: "order_items", + }, + compositions: [ + Ident { + span_range: 1209..1219, + raw: "\"order_id\"", + to_string: "order_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1225..1271, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1225..1240, + schema: None, + table: Ident { + span_range: 1225..1235, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 1236..1240, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1243..1269, + schema: None, + table: Ident { + span_range: 1243..1256, + raw: "\"order_items\"", + to_string: "order_items", + }, + compositions: [ + Ident { + span_range: 1257..1269, + raw: "\"product_id\"", + to_string: "product_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1275..1320, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1275..1293, + schema: None, + table: Ident { + span_range: 1275..1286, + raw: "\"countries\"", + to_string: "countries", + }, + compositions: [ + Ident { + span_range: 1287..1293, + raw: "\"code\"", + to_string: "code", + }, + ], + }, + rhs: RefIdent { + span_range: 1296..1318, + schema: None, + table: Ident { + span_range: 1296..1303, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1304..1318, + raw: "\"country_code\"", + to_string: "country_code", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1324..1373, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1324..1342, + schema: None, + table: Ident { + span_range: 1324..1335, + raw: "\"countries\"", + to_string: "countries", + }, + compositions: [ + Ident { + span_range: 1336..1342, + raw: "\"code\"", + to_string: "code", + }, + ], + }, + rhs: RefIdent { + span_range: 1345..1371, + schema: None, + table: Ident { + span_range: 1345..1356, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 1357..1371, + raw: "\"country_code\"", + to_string: "country_code", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1377..1422, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1377..1393, + schema: None, + table: Ident { + span_range: 1377..1388, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 1389..1393, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1396..1420, + schema: None, + table: Ident { + span_range: 1396..1406, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 1407..1420, + raw: "\"merchant_id\"", + to_string: "merchant_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1426..1463, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1426..1438, + schema: None, + table: Ident { + span_range: 1426..1433, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1434..1438, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1441..1463, + schema: None, + table: Ident { + span_range: 1441..1452, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 1453..1463, + raw: "\"admin_id\"", + to_string: "admin_id", + }, + ], + }, + settings: None, + }, + ), + ], +} \ No newline at end of file diff --git a/tests/out/mssql_importer/multiple_schema.out.ron b/tests/out/mssql_importer/multiple_schema.out.ron new file mode 100644 index 0000000..5b5ec42 --- /dev/null +++ b/tests/out/mssql_importer/multiple_schema.out.ron @@ -0,0 +1,1687 @@ +SchemaBlock { + span_range: 0..1830, + input: "Enum \"users_pjs_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"users_pjs2_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"users_pg_enum\" {\n \"male\"\n \"female\"\n}\n\nEnum \"users_pg2_enum\" {\n \"male2\"\n \"female2\"\n}\n\nEnum \"ecommerce_users_ejs_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"ecommerce_users_ejs2_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"ecommerce_users_eg_enum\" {\n \"male\"\n \"female\"\n}\n\nEnum \"ecommerce_users_eg2_enum\" {\n \"male2\"\n \"female2\"\n}\n\nTable \"users\" {\n \"id\" int [pk]\n \"name\" nvarchar(255)\n \"pjs\" users_pjs_enum [not null]\n \"pjs2\" users_pjs2_enum [not null]\n \"pg\" users_pg_enum [not null]\n \"pg2\" users_pg2_enum [not null]\n}\n\nTable \"products\" {\n \"id\" int [pk]\n \"name\" nvarchar(255) [note: 'Product name']\n}\n\nRef:\"schemaA\".\"locations\".\"id\" < \"schemaA\".\"products\".\"lid\"\n\nRef \"FK_1\":\"schemaA\".\"locations\".\"id\" < \"schemaA\".\"products\".\"lid2\"\n\nRef:\"users\".\"id\" < \"ecommerce\".\"users\".\"id\"\n\nRef \"name_optional\":\"users\".\"name\" < \"ecommerce\".\"users\".\"id\"\n\nRef:\"ecommerce\".\"users\".\"id\" < \"schemaA\".\"products\".\"name\"\n\nRef:\"users\".\"id\" < \"schemaA\".\"locations\".\"name\"\n\nTable \"ecommerce\".\"users\" {\n \"id\" int [pk]\n \"name\" nvarchar(255)\n \"ejs\" ecommerce_users_ejs_enum [not null]\n \"ejs2\" ecommerce_users_ejs2_enum [not null]\n \"eg\" ecommerce_users_eg_enum [not null]\n \"eg2\" ecommerce_users_eg2_enum [not null]\n\nIndexes {\n (name, ejs) [name: \"idx_1\"]\n}\n Note: 'Note on table users of schema ecommerce'\n}\n\nTable \"schemaA\".\"products\" {\n \"id\" int [pk]\n \"name\" nvarchar(255)\n \"created_at\" varchar(255) [default: `now()`]\n \"lid\" int\n \"lid2\" int\n\nIndexes {\n (lid, lid2) [unique, name: \"unique_lid_lid2\"]\n}\n}\n\nTable \"schemaA\".\"locations\" {\n \"id\" int [pk]\n \"name\" nvarchar(255)\n Note: 'This is a note in table \"schemaA\".\"locations\"'\n}", + blocks: [ + Enum( + EnumBlock { + span_range: 0..74, + ident: EnumIdent { + span_range: 5..22, + schema: None, + name: Ident { + span_range: 5..21, + raw: "\"users_pjs_enum\"", + to_string: "users_pjs_enum", + }, + }, + values: [ + EnumValue { + span_range: 26..39, + value: Ident { + span_range: 26..36, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 39..52, + value: Ident { + span_range: 39..49, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 52..62, + value: Ident { + span_range: 52..59, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 62..73, + value: Ident { + span_range: 62..72, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 76..151, + ident: EnumIdent { + span_range: 81..99, + schema: None, + name: Ident { + span_range: 81..98, + raw: "\"users_pjs2_enum\"", + to_string: "users_pjs2_enum", + }, + }, + values: [ + EnumValue { + span_range: 103..116, + value: Ident { + span_range: 103..113, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 116..129, + value: Ident { + span_range: 116..126, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 129..139, + value: Ident { + span_range: 129..136, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 139..150, + value: Ident { + span_range: 139..149, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 153..197, + ident: EnumIdent { + span_range: 158..174, + schema: None, + name: Ident { + span_range: 158..173, + raw: "\"users_pg_enum\"", + to_string: "users_pg_enum", + }, + }, + values: [ + EnumValue { + span_range: 178..187, + value: Ident { + span_range: 178..184, + raw: "\"male\"", + to_string: "male", + }, + settings: None, + }, + EnumValue { + span_range: 187..196, + value: Ident { + span_range: 187..195, + raw: "\"female\"", + to_string: "female", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 199..246, + ident: EnumIdent { + span_range: 204..221, + schema: None, + name: Ident { + span_range: 204..220, + raw: "\"users_pg2_enum\"", + to_string: "users_pg2_enum", + }, + }, + values: [ + EnumValue { + span_range: 225..235, + value: Ident { + span_range: 225..232, + raw: "\"male2\"", + to_string: "male2", + }, + settings: None, + }, + EnumValue { + span_range: 235..245, + value: Ident { + span_range: 235..244, + raw: "\"female2\"", + to_string: "female2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 248..332, + ident: EnumIdent { + span_range: 253..280, + schema: None, + name: Ident { + span_range: 253..279, + raw: "\"ecommerce_users_ejs_enum\"", + to_string: "ecommerce_users_ejs_enum", + }, + }, + values: [ + EnumValue { + span_range: 284..297, + value: Ident { + span_range: 284..294, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 297..310, + value: Ident { + span_range: 297..307, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 310..320, + value: Ident { + span_range: 310..317, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 320..331, + value: Ident { + span_range: 320..330, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 334..419, + ident: EnumIdent { + span_range: 339..367, + schema: None, + name: Ident { + span_range: 339..366, + raw: "\"ecommerce_users_ejs2_enum\"", + to_string: "ecommerce_users_ejs2_enum", + }, + }, + values: [ + EnumValue { + span_range: 371..384, + value: Ident { + span_range: 371..381, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 384..397, + value: Ident { + span_range: 384..394, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 397..407, + value: Ident { + span_range: 397..404, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 407..418, + value: Ident { + span_range: 407..417, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 421..475, + ident: EnumIdent { + span_range: 426..452, + schema: None, + name: Ident { + span_range: 426..451, + raw: "\"ecommerce_users_eg_enum\"", + to_string: "ecommerce_users_eg_enum", + }, + }, + values: [ + EnumValue { + span_range: 456..465, + value: Ident { + span_range: 456..462, + raw: "\"male\"", + to_string: "male", + }, + settings: None, + }, + EnumValue { + span_range: 465..474, + value: Ident { + span_range: 465..473, + raw: "\"female\"", + to_string: "female", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 477..534, + ident: EnumIdent { + span_range: 482..509, + schema: None, + name: Ident { + span_range: 482..508, + raw: "\"ecommerce_users_eg2_enum\"", + to_string: "ecommerce_users_eg2_enum", + }, + }, + values: [ + EnumValue { + span_range: 513..523, + value: Ident { + span_range: 513..520, + raw: "\"male2\"", + to_string: "male2", + }, + settings: None, + }, + EnumValue { + span_range: 523..533, + value: Ident { + span_range: 523..532, + raw: "\"female2\"", + to_string: "female2", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 536..728, + cols: [ + TableColumn { + span_range: 554..567, + name: Ident { + span_range: 554..558, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 559..562, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 563..567, + attributes: [ + Attribute { + span_range: 564..566, + key: Ident { + span_range: 564..566, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 570..593, + name: Ident { + span_range: 570..576, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 577..590, + raw: "nvarchar(255)", + type_name: Raw( + "nvarchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 593..624, + name: Ident { + span_range: 593..598, + raw: "\"pjs\"", + to_string: "pjs", + }, + type: ColumnType { + span_range: 599..613, + raw: "users_pjs_enum", + type_name: Raw( + "users_pjs_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 614..624, + attributes: [ + Attribute { + span_range: 615..623, + key: Ident { + span_range: 615..623, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 627..660, + name: Ident { + span_range: 627..633, + raw: "\"pjs2\"", + to_string: "pjs2", + }, + type: ColumnType { + span_range: 634..649, + raw: "users_pjs2_enum", + type_name: Raw( + "users_pjs2_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 650..660, + attributes: [ + Attribute { + span_range: 651..659, + key: Ident { + span_range: 651..659, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 663..692, + name: Ident { + span_range: 663..667, + raw: "\"pg\"", + to_string: "pg", + }, + type: ColumnType { + span_range: 668..681, + raw: "users_pg_enum", + type_name: Raw( + "users_pg_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 682..692, + attributes: [ + Attribute { + span_range: 683..691, + key: Ident { + span_range: 683..691, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 695..726, + name: Ident { + span_range: 695..700, + raw: "\"pg2\"", + to_string: "pg2", + }, + type: ColumnType { + span_range: 701..715, + raw: "users_pg2_enum", + type_name: Raw( + "users_pg2_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 716..726, + attributes: [ + Attribute { + span_range: 717..725, + key: Ident { + span_range: 717..725, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 542..550, + name: Ident { + span_range: 542..549, + raw: "\"users\"", + to_string: "users", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 730..812, + cols: [ + TableColumn { + span_range: 751..764, + name: Ident { + span_range: 751..755, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 756..759, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 760..764, + attributes: [ + Attribute { + span_range: 761..763, + key: Ident { + span_range: 761..763, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 767..810, + name: Ident { + span_range: 767..773, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 774..787, + raw: "nvarchar(255)", + type_name: Raw( + "nvarchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 788..810, + attributes: [ + Attribute { + span_range: 789..809, + key: Ident { + span_range: 789..793, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 795..809, + raw: "'Product name'", + value: String( + "Product name", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "Product name", + ), + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 736..747, + name: Ident { + span_range: 736..746, + raw: "\"products\"", + to_string: "products", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 818..875, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 818..844, + schema: Some( + Ident { + span_range: 818..827, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 828..839, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 840..844, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 847..873, + schema: Some( + Ident { + span_range: 847..856, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 857..867, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 868..873, + raw: "\"lid\"", + to_string: "lid", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 886..944, + name: Some( + Ident { + span_range: 879..885, + raw: "\"FK_1\"", + to_string: "FK_1", + }, + ), + rel: One2Many, + lhs: RefIdent { + span_range: 886..912, + schema: Some( + Ident { + span_range: 886..895, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 896..907, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 908..912, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 915..942, + schema: Some( + Ident { + span_range: 915..924, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 925..935, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 936..942, + raw: "\"lid2\"", + to_string: "lid2", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 948..989, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 948..960, + schema: None, + table: Ident { + span_range: 948..955, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 956..960, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 963..987, + schema: Some( + Ident { + span_range: 963..974, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 975..982, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 983..987, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1009..1052, + name: Some( + Ident { + span_range: 993..1008, + raw: "\"name_optional\"", + to_string: "name_optional", + }, + ), + rel: One2Many, + lhs: RefIdent { + span_range: 1009..1023, + schema: None, + table: Ident { + span_range: 1009..1016, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1017..1023, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + rhs: RefIdent { + span_range: 1026..1050, + schema: Some( + Ident { + span_range: 1026..1037, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 1038..1045, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1046..1050, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1056..1112, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1056..1080, + schema: Some( + Ident { + span_range: 1056..1067, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 1068..1075, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1076..1080, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1083..1110, + schema: Some( + Ident { + span_range: 1083..1092, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 1093..1103, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 1104..1110, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1116..1161, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1116..1128, + schema: None, + table: Ident { + span_range: 1116..1123, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1124..1128, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1131..1159, + schema: Some( + Ident { + span_range: 1131..1140, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 1141..1152, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 1153..1159, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1161..1498, + cols: [ + TableColumn { + span_range: 1191..1204, + name: Ident { + span_range: 1191..1195, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1196..1199, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1200..1204, + attributes: [ + Attribute { + span_range: 1201..1203, + key: Ident { + span_range: 1201..1203, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1207..1230, + name: Ident { + span_range: 1207..1213, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1214..1227, + raw: "nvarchar(255)", + type_name: Raw( + "nvarchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1230..1271, + name: Ident { + span_range: 1230..1235, + raw: "\"ejs\"", + to_string: "ejs", + }, + type: ColumnType { + span_range: 1236..1260, + raw: "ecommerce_users_ejs_enum", + type_name: Raw( + "ecommerce_users_ejs_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1261..1271, + attributes: [ + Attribute { + span_range: 1262..1270, + key: Ident { + span_range: 1262..1270, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1274..1317, + name: Ident { + span_range: 1274..1280, + raw: "\"ejs2\"", + to_string: "ejs2", + }, + type: ColumnType { + span_range: 1281..1306, + raw: "ecommerce_users_ejs2_enum", + type_name: Raw( + "ecommerce_users_ejs2_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1307..1317, + attributes: [ + Attribute { + span_range: 1308..1316, + key: Ident { + span_range: 1308..1316, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1320..1359, + name: Ident { + span_range: 1320..1324, + raw: "\"eg\"", + to_string: "eg", + }, + type: ColumnType { + span_range: 1325..1348, + raw: "ecommerce_users_eg_enum", + type_name: Raw( + "ecommerce_users_eg_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1349..1359, + attributes: [ + Attribute { + span_range: 1350..1358, + key: Ident { + span_range: 1350..1358, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1362..1403, + name: Ident { + span_range: 1362..1367, + raw: "\"eg2\"", + to_string: "eg2", + }, + type: ColumnType { + span_range: 1368..1392, + raw: "ecommerce_users_eg2_enum", + type_name: Raw( + "ecommerce_users_eg2_enum", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1393..1403, + attributes: [ + Attribute { + span_range: 1394..1402, + key: Ident { + span_range: 1394..1402, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 1167..1186, + name: Ident { + span_range: 1179..1186, + raw: "\"users\"", + to_string: "users", + }, + schema: Some( + Ident { + span_range: 1167..1178, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + alias: None, + }, + note: Some( + NoteBlock { + span_range: 1449..1496, + value: Literal { + span_range: 1455..1496, + raw: "'Note on table users of schema ecommerce'", + value: String( + "Note on table users of schema ecommerce", + ), + }, + }, + ), + indexes: Some( + IndexesBlock { + span_range: 1413..1446, + defs: [ + IndexesDef { + span_range: 1417..1444, + cols: [ + String( + Ident { + span_range: 1418..1422, + raw: "name", + to_string: "name", + }, + ), + String( + Ident { + span_range: 1424..1427, + raw: "ejs", + to_string: "ejs", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1429..1444, + attributes: [ + Attribute { + span_range: 1430..1443, + key: Ident { + span_range: 1430..1434, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1436..1443, + raw: "\"idx_1\"", + value: String( + "idx_1", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "idx_1", + ), + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1500..1702, + cols: [ + TableColumn { + span_range: 1531..1544, + name: Ident { + span_range: 1531..1535, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1536..1539, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1540..1544, + attributes: [ + Attribute { + span_range: 1541..1543, + key: Ident { + span_range: 1541..1543, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1547..1570, + name: Ident { + span_range: 1547..1553, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1554..1567, + raw: "nvarchar(255)", + type_name: Raw( + "nvarchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1570..1614, + name: Ident { + span_range: 1570..1582, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 1583..1595, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1596..1614, + attributes: [ + Attribute { + span_range: 1597..1613, + key: Ident { + span_range: 1597..1604, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 1606..1613, + raw: "`now()`", + value: Expr( + "now()", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Expr( + "now()", + ), + ), + refs: [], + }, + ), + }, + TableColumn { + span_range: 1617..1629, + name: Ident { + span_range: 1617..1622, + raw: "\"lid\"", + to_string: "lid", + }, + type: ColumnType { + span_range: 1623..1626, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1629..1641, + name: Ident { + span_range: 1629..1635, + raw: "\"lid2\"", + to_string: "lid2", + }, + type: ColumnType { + span_range: 1636..1639, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1506..1526, + name: Ident { + span_range: 1516..1526, + raw: "\"products\"", + to_string: "products", + }, + schema: Some( + Ident { + span_range: 1506..1515, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 1649..1700, + defs: [ + IndexesDef { + span_range: 1653..1698, + cols: [ + String( + Ident { + span_range: 1654..1657, + raw: "lid", + to_string: "lid", + }, + ), + String( + Ident { + span_range: 1659..1663, + raw: "lid2", + to_string: "lid2", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1665..1698, + attributes: [ + Attribute { + span_range: 1666..1672, + key: Ident { + span_range: 1666..1672, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + Attribute { + span_range: 1674..1697, + key: Ident { + span_range: 1674..1678, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1680..1697, + raw: "\"unique_lid_lid2\"", + value: String( + "unique_lid_lid2", + ), + }, + ), + }, + ], + type: None, + is_unique: true, + is_pk: false, + note: None, + name: Some( + "unique_lid_lid2", + ), + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1704..1830, + cols: [ + TableColumn { + span_range: 1736..1749, + name: Ident { + span_range: 1736..1740, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1741..1744, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1745..1749, + attributes: [ + Attribute { + span_range: 1746..1748, + key: Ident { + span_range: 1746..1748, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1752..1775, + name: Ident { + span_range: 1752..1758, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1759..1772, + raw: "nvarchar(255)", + type_name: Raw( + "nvarchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1710..1731, + name: Ident { + span_range: 1720..1731, + raw: "\"locations\"", + to_string: "locations", + }, + schema: Some( + Ident { + span_range: 1710..1719, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + alias: None, + }, + note: Some( + NoteBlock { + span_range: 1775..1828, + value: Literal { + span_range: 1781..1828, + raw: "'This is a note in table \"schemaA\".\"locations\"'", + value: String( + "This is a note in table \"schemaA\".\"locations\"", + ), + }, + }, + ), + indexes: None, + settings: None, + }, + ), + ], +} \ No newline at end of file diff --git a/tests/out/multiline_string.in.ron b/tests/out/multiline_string.in.ron index 93dc299..159f7b7 100644 --- a/tests/out/multiline_string.in.ron +++ b/tests/out/multiline_string.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 19..23, - raw: "int ", + span_range: 19..22, + raw: "int", type_name: Raw( "int", ), diff --git a/tests/out/mysql_importer/general_schema.out.ron b/tests/out/mysql_importer/general_schema.out.ron new file mode 100644 index 0000000..e1f6d2a --- /dev/null +++ b/tests/out/mysql_importer/general_schema.out.ron @@ -0,0 +1,3043 @@ +SchemaBlock { + span_range: 0..2999, + input: "Enum \"orders_status_enum\" {\n \"created\"\n \"running\"\n \"done\"\n \"failure\"\n}\n\nEnum \"products_status_enum\" {\n \"Out of Stock\"\n \"In Stock\"\n}\n\nTable \"orders\" {\n \"id\" int [pk, increment]\n \"user_id\" int [unique, not null]\n \"status\" orders_status_enum\n \"created_at\" varchar(255)\n}\n\nTable \"order_items\" {\n \"order_id\" int\n \"product_id\" int\n \"quantity\" int [default: 1]\n}\n\nTable \"products\" {\n \"id\" int\n \"name\" varchar(255)\n \"merchant_id\" int [not null]\n \"price\" int [note: 'Products price field']\n \"status\" products_status_enum\n \"created_at\" datetime [default: `now()`]\n\nIndexes {\n (id, price) [pk]\n (merchant_id, status) [name: \"product_status\"]\n id [type: hash, unique, name: \"products_index_1\"]\n}\n Note: 'Notes about products table'\n}\n\nTable \"users\" {\n \"id\" int [pk]\n \"full_name\" varchar(255)\n \"email\" varchar(255) [unique]\n \"gender\" varchar(255)\n \"date_of_birth\" varchar(255)\n \"created_at\" varchar(255)\n \"country_code\" int\n Note: 'User basic information'\n}\n\nTable \"merchants\" {\n \"id\" int [pk]\n \"merchant_name\" varchar(255)\n \"country_code\" int\n \"created_at\" varchar(255)\n \"admin_id\" int\n}\n\nTable \"countries\" {\n \"code\" int [pk]\n \"name\" varchar(255)\n \"continent_name\" varchar(255)\n}\n\nTable \"composite_service_item\" {\n \"composite_service_item_id\" int(11) [pk, not null]\n \"service_id\" int(11) [not null]\n \"ticket_item_id\" int(11) [not null]\n \"discount\" decimal(10,0) [not null]\n \"original_price\" decimal(10,0) [not null]\n \"patient_price\" decimal(10,0) [not null]\n \"insurance_price\" decimal(10,0) [not null]\n\nIndexes {\n ticket_item_id [name: \"ticket_item_id\"]\n service_id [name: \"service_id\"]\n (service_id, ticket_item_id) [type: hash, name: \"service_id, ticket_item_id\"]\n composite_service_item_id [type: btree, name: \"composite_service_item_id\"]\n (service_id, patient_price) [type: hash, name: \"test test test key\"]\n}\n}\n\nTable \"Countries\" {\n \"Id\" int [pk, not null]\n \"Name\" varchar(32) [not null]\n}\n\nTable \"States\" {\n \"Id\" int [not null]\n \"CountryId\" int [not null]\n \"Name\" varchar(32) [not null]\n\nIndexes {\n CountryId [name: \"IX_States_CountryId\"]\n (Id, CountryId) [pk]\n}\n}\n\nTable \"Cities\" {\n \"Id\" int [not null]\n \"CountryId\" int [not null]\n \"StateId\" int [not null]\n \"Name\" varchar(32) [not null]\n\nIndexes {\n CountryId [name: \"IX_Cities_CountryId\"]\n (StateId, CountryId) [name: \"IX_Cities_StateId_CountryId\"]\n (Id, StateId, CountryId) [pk]\n}\n}\n\nRef \"FK_States_Countries_CountryId\":\"Countries\".\"Id\" < \"States\".\"CountryId\" [delete: cascade]\n\nRef \"FK_Cities_Countries_CountryId\":\"Countries\".\"Id\" < \"Cities\".\"CountryId\" [delete: cascade]\n\nRef \"FK_Cities_States_StateId_CountryId\":\"States\".(\"Id\", \"CountryId\") < \"Cities\".(\"StateId\", \"CountryId\") [delete: cascade]\n\nRef:\"orders\".\"id\" < \"order_items\".\"order_id\"\n\nRef:\"products\".\"id\" < \"order_items\".\"product_id\"\n\nRef:\"countries\".\"code\" < \"users\".\"country_code\"\n\nRef:\"countries\".\"code\" < \"merchants\".\"country_code\"\n\nRef:\"merchants\".\"id\" < \"products\".\"merchant_id\"\n\nRef:\"users\".\"id\" < \"merchants\".\"admin_id\"", + blocks: [ + Enum( + EnumBlock { + span_range: 0..74, + ident: EnumIdent { + span_range: 5..26, + schema: None, + name: Ident { + span_range: 5..25, + raw: "\"orders_status_enum\"", + to_string: "orders_status_enum", + }, + }, + values: [ + EnumValue { + span_range: 30..42, + value: Ident { + span_range: 30..39, + raw: "\"created\"", + to_string: "created", + }, + settings: None, + }, + EnumValue { + span_range: 42..54, + value: Ident { + span_range: 42..51, + raw: "\"running\"", + to_string: "running", + }, + settings: None, + }, + EnumValue { + span_range: 54..63, + value: Ident { + span_range: 54..60, + raw: "\"done\"", + to_string: "done", + }, + settings: None, + }, + EnumValue { + span_range: 63..73, + value: Ident { + span_range: 63..72, + raw: "\"failure\"", + to_string: "failure", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 76..137, + ident: EnumIdent { + span_range: 81..104, + schema: None, + name: Ident { + span_range: 81..103, + raw: "\"products_status_enum\"", + to_string: "products_status_enum", + }, + }, + values: [ + EnumValue { + span_range: 108..125, + value: Ident { + span_range: 108..122, + raw: "\"Out of Stock\"", + to_string: "Out of Stock", + }, + settings: None, + }, + EnumValue { + span_range: 125..136, + value: Ident { + span_range: 125..135, + raw: "\"In Stock\"", + to_string: "In Stock", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 139..277, + cols: [ + TableColumn { + span_range: 158..182, + name: Ident { + span_range: 158..162, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 163..166, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 167..182, + attributes: [ + Attribute { + span_range: 168..170, + key: Ident { + span_range: 168..170, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + Attribute { + span_range: 172..181, + key: Ident { + span_range: 172..181, + raw: "increment", + to_string: "increment", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: true, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 185..217, + name: Ident { + span_range: 185..194, + raw: "\"user_id\"", + to_string: "user_id", + }, + type: ColumnType { + span_range: 195..198, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 199..217, + attributes: [ + Attribute { + span_range: 200..206, + key: Ident { + span_range: 200..206, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + Attribute { + span_range: 208..216, + key: Ident { + span_range: 208..216, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: true, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 220..250, + name: Ident { + span_range: 220..228, + raw: "\"status\"", + to_string: "status", + }, + type: ColumnType { + span_range: 229..247, + raw: "orders_status_enum", + type_name: Raw( + "orders_status_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 250..276, + name: Ident { + span_range: 250..262, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 263..275, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 145..154, + name: Ident { + span_range: 145..153, + raw: "\"orders\"", + to_string: "orders", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 279..368, + cols: [ + TableColumn { + span_range: 303..320, + name: Ident { + span_range: 303..313, + raw: "\"order_id\"", + to_string: "order_id", + }, + type: ColumnType { + span_range: 314..317, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 320..339, + name: Ident { + span_range: 320..332, + raw: "\"product_id\"", + to_string: "product_id", + }, + type: ColumnType { + span_range: 333..336, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 339..366, + name: Ident { + span_range: 339..349, + raw: "\"quantity\"", + to_string: "quantity", + }, + type: ColumnType { + span_range: 350..353, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 354..366, + attributes: [ + Attribute { + span_range: 355..365, + key: Ident { + span_range: 355..362, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 364..365, + raw: "1", + value: Integer( + 1, + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Integer( + 1, + ), + ), + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 285..299, + name: Ident { + span_range: 285..298, + raw: "\"order_items\"", + to_string: "order_items", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 370..744, + cols: [ + TableColumn { + span_range: 391..402, + name: Ident { + span_range: 391..395, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 396..399, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 402..424, + name: Ident { + span_range: 402..408, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 409..421, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 424..452, + name: Ident { + span_range: 424..437, + raw: "\"merchant_id\"", + to_string: "merchant_id", + }, + type: ColumnType { + span_range: 438..441, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 442..452, + attributes: [ + Attribute { + span_range: 443..451, + key: Ident { + span_range: 443..451, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 455..497, + name: Ident { + span_range: 455..462, + raw: "\"price\"", + to_string: "price", + }, + type: ColumnType { + span_range: 463..466, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 467..497, + attributes: [ + Attribute { + span_range: 468..496, + key: Ident { + span_range: 468..472, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 474..496, + raw: "'Products price field'", + value: String( + "Products price field", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "Products price field", + ), + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 500..532, + name: Ident { + span_range: 500..508, + raw: "\"status\"", + to_string: "status", + }, + type: ColumnType { + span_range: 509..529, + raw: "products_status_enum", + type_name: Raw( + "products_status_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 532..572, + name: Ident { + span_range: 532..544, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 545..553, + raw: "datetime", + type_name: Raw( + "datetime", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 554..572, + attributes: [ + Attribute { + span_range: 555..571, + key: Ident { + span_range: 555..562, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 564..571, + raw: "`now()`", + value: Expr( + "now()", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Expr( + "now()", + ), + ), + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 376..387, + name: Ident { + span_range: 376..386, + raw: "\"products\"", + to_string: "products", + }, + schema: None, + alias: None, + }, + note: Some( + NoteBlock { + span_range: 708..742, + value: Literal { + span_range: 714..742, + raw: "'Notes about products table'", + value: String( + "Notes about products table", + ), + }, + }, + ), + indexes: Some( + IndexesBlock { + span_range: 582..705, + defs: [ + IndexesDef { + span_range: 586..602, + cols: [ + String( + Ident { + span_range: 587..589, + raw: "id", + to_string: "id", + }, + ), + String( + Ident { + span_range: 591..596, + raw: "price", + to_string: "price", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 598..602, + attributes: [ + Attribute { + span_range: 599..601, + key: Ident { + span_range: 599..601, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + type: None, + is_unique: false, + is_pk: true, + note: None, + name: None, + }, + ), + }, + IndexesDef { + span_range: 605..651, + cols: [ + String( + Ident { + span_range: 606..617, + raw: "merchant_id", + to_string: "merchant_id", + }, + ), + String( + Ident { + span_range: 619..625, + raw: "status", + to_string: "status", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 627..651, + attributes: [ + Attribute { + span_range: 628..650, + key: Ident { + span_range: 628..632, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 634..650, + raw: "\"product_status\"", + value: String( + "product_status", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "product_status", + ), + }, + ), + }, + IndexesDef { + span_range: 654..703, + cols: [ + String( + Ident { + span_range: 654..656, + raw: "id", + to_string: "id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 657..703, + attributes: [ + Attribute { + span_range: 658..668, + key: Ident { + span_range: 658..662, + raw: "type", + to_string: "type", + }, + value: Some( + Literal { + span_range: 664..668, + raw: "hash", + value: Enum( + "hash", + ), + }, + ), + }, + Attribute { + span_range: 670..676, + key: Ident { + span_range: 670..676, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + Attribute { + span_range: 678..702, + key: Ident { + span_range: 678..682, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 684..702, + raw: "\"products_index_1\"", + value: String( + "products_index_1", + ), + }, + ), + }, + ], + type: Some( + Hash, + ), + is_unique: true, + is_pk: false, + note: None, + name: Some( + "products_index_1", + ), + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 746..975, + cols: [ + TableColumn { + span_range: 764..777, + name: Ident { + span_range: 764..768, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 769..772, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 773..777, + attributes: [ + Attribute { + span_range: 774..776, + key: Ident { + span_range: 774..776, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 780..807, + name: Ident { + span_range: 780..791, + raw: "\"full_name\"", + to_string: "full_name", + }, + type: ColumnType { + span_range: 792..804, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 807..836, + name: Ident { + span_range: 807..814, + raw: "\"email\"", + to_string: "email", + }, + type: ColumnType { + span_range: 815..827, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 828..836, + attributes: [ + Attribute { + span_range: 829..835, + key: Ident { + span_range: 829..835, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + ], + is_pk: false, + is_unique: true, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 839..863, + name: Ident { + span_range: 839..847, + raw: "\"gender\"", + to_string: "gender", + }, + type: ColumnType { + span_range: 848..860, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 863..894, + name: Ident { + span_range: 863..878, + raw: "\"date_of_birth\"", + to_string: "date_of_birth", + }, + type: ColumnType { + span_range: 879..891, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 894..922, + name: Ident { + span_range: 894..906, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 907..919, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 922..943, + name: Ident { + span_range: 922..936, + raw: "\"country_code\"", + to_string: "country_code", + }, + type: ColumnType { + span_range: 937..940, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 752..760, + name: Ident { + span_range: 752..759, + raw: "\"users\"", + to_string: "users", + }, + schema: None, + alias: None, + }, + note: Some( + NoteBlock { + span_range: 943..973, + value: Literal { + span_range: 949..973, + raw: "'User basic information'", + value: String( + "User basic information", + ), + }, + }, + ), + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 977..1111, + cols: [ + TableColumn { + span_range: 999..1012, + name: Ident { + span_range: 999..1003, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1004..1007, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1008..1012, + attributes: [ + Attribute { + span_range: 1009..1011, + key: Ident { + span_range: 1009..1011, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1015..1046, + name: Ident { + span_range: 1015..1030, + raw: "\"merchant_name\"", + to_string: "merchant_name", + }, + type: ColumnType { + span_range: 1031..1043, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1046..1067, + name: Ident { + span_range: 1046..1060, + raw: "\"country_code\"", + to_string: "country_code", + }, + type: ColumnType { + span_range: 1061..1064, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1067..1095, + name: Ident { + span_range: 1067..1079, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 1080..1092, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1095..1110, + name: Ident { + span_range: 1095..1105, + raw: "\"admin_id\"", + to_string: "admin_id", + }, + type: ColumnType { + span_range: 1106..1109, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 983..995, + name: Ident { + span_range: 983..994, + raw: "\"merchants\"", + to_string: "merchants", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1113..1206, + cols: [ + TableColumn { + span_range: 1135..1150, + name: Ident { + span_range: 1135..1141, + raw: "\"code\"", + to_string: "code", + }, + type: ColumnType { + span_range: 1142..1145, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1146..1150, + attributes: [ + Attribute { + span_range: 1147..1149, + key: Ident { + span_range: 1147..1149, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1153..1175, + name: Ident { + span_range: 1153..1159, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1160..1172, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1175..1205, + name: Ident { + span_range: 1175..1191, + raw: "\"continent_name\"", + to_string: "continent_name", + }, + type: ColumnType { + span_range: 1192..1204, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1119..1131, + name: Ident { + span_range: 1119..1130, + raw: "\"countries\"", + to_string: "countries", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1208..1854, + cols: [ + TableColumn { + span_range: 1243..1293, + name: Ident { + span_range: 1243..1270, + raw: "\"composite_service_item_id\"", + to_string: "composite_service_item_id", + }, + type: ColumnType { + span_range: 1271..1278, + raw: "int(11)", + type_name: Raw( + "int", + ), + args: [ + Integer( + 11, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1279..1293, + attributes: [ + Attribute { + span_range: 1280..1282, + key: Ident { + span_range: 1280..1282, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + Attribute { + span_range: 1284..1292, + key: Ident { + span_range: 1284..1292, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1296..1327, + name: Ident { + span_range: 1296..1308, + raw: "\"service_id\"", + to_string: "service_id", + }, + type: ColumnType { + span_range: 1309..1316, + raw: "int(11)", + type_name: Raw( + "int", + ), + args: [ + Integer( + 11, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1317..1327, + attributes: [ + Attribute { + span_range: 1318..1326, + key: Ident { + span_range: 1318..1326, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1330..1365, + name: Ident { + span_range: 1330..1346, + raw: "\"ticket_item_id\"", + to_string: "ticket_item_id", + }, + type: ColumnType { + span_range: 1347..1354, + raw: "int(11)", + type_name: Raw( + "int", + ), + args: [ + Integer( + 11, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1355..1365, + attributes: [ + Attribute { + span_range: 1356..1364, + key: Ident { + span_range: 1356..1364, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1368..1403, + name: Ident { + span_range: 1368..1378, + raw: "\"discount\"", + to_string: "discount", + }, + type: ColumnType { + span_range: 1379..1392, + raw: "decimal(10,0)", + type_name: Raw( + "decimal", + ), + args: [ + Integer( + 10, + ), + Integer( + 0, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1393..1403, + attributes: [ + Attribute { + span_range: 1394..1402, + key: Ident { + span_range: 1394..1402, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1406..1447, + name: Ident { + span_range: 1406..1422, + raw: "\"original_price\"", + to_string: "original_price", + }, + type: ColumnType { + span_range: 1423..1436, + raw: "decimal(10,0)", + type_name: Raw( + "decimal", + ), + args: [ + Integer( + 10, + ), + Integer( + 0, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1437..1447, + attributes: [ + Attribute { + span_range: 1438..1446, + key: Ident { + span_range: 1438..1446, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1450..1490, + name: Ident { + span_range: 1450..1465, + raw: "\"patient_price\"", + to_string: "patient_price", + }, + type: ColumnType { + span_range: 1466..1479, + raw: "decimal(10,0)", + type_name: Raw( + "decimal", + ), + args: [ + Integer( + 10, + ), + Integer( + 0, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1480..1490, + attributes: [ + Attribute { + span_range: 1481..1489, + key: Ident { + span_range: 1481..1489, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1493..1535, + name: Ident { + span_range: 1493..1510, + raw: "\"insurance_price\"", + to_string: "insurance_price", + }, + type: ColumnType { + span_range: 1511..1524, + raw: "decimal(10,0)", + type_name: Raw( + "decimal", + ), + args: [ + Integer( + 10, + ), + Integer( + 0, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1525..1535, + attributes: [ + Attribute { + span_range: 1526..1534, + key: Ident { + span_range: 1526..1534, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 1214..1239, + name: Ident { + span_range: 1214..1238, + raw: "\"composite_service_item\"", + to_string: "composite_service_item", + }, + schema: None, + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 1545..1852, + defs: [ + IndexesDef { + span_range: 1549..1588, + cols: [ + String( + Ident { + span_range: 1549..1563, + raw: "ticket_item_id", + to_string: "ticket_item_id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1564..1588, + attributes: [ + Attribute { + span_range: 1565..1587, + key: Ident { + span_range: 1565..1569, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1571..1587, + raw: "\"ticket_item_id\"", + value: String( + "ticket_item_id", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "ticket_item_id", + ), + }, + ), + }, + IndexesDef { + span_range: 1591..1622, + cols: [ + String( + Ident { + span_range: 1591..1601, + raw: "service_id", + to_string: "service_id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1602..1622, + attributes: [ + Attribute { + span_range: 1603..1621, + key: Ident { + span_range: 1603..1607, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1609..1621, + raw: "\"service_id\"", + value: String( + "service_id", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "service_id", + ), + }, + ), + }, + IndexesDef { + span_range: 1625..1702, + cols: [ + String( + Ident { + span_range: 1626..1636, + raw: "service_id", + to_string: "service_id", + }, + ), + String( + Ident { + span_range: 1638..1652, + raw: "ticket_item_id", + to_string: "ticket_item_id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1654..1702, + attributes: [ + Attribute { + span_range: 1655..1665, + key: Ident { + span_range: 1655..1659, + raw: "type", + to_string: "type", + }, + value: Some( + Literal { + span_range: 1661..1665, + raw: "hash", + value: Enum( + "hash", + ), + }, + ), + }, + Attribute { + span_range: 1667..1701, + key: Ident { + span_range: 1667..1671, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1673..1701, + raw: "\"service_id, ticket_item_id\"", + value: String( + "service_id, ticket_item_id", + ), + }, + ), + }, + ], + type: Some( + Hash, + ), + is_unique: false, + is_pk: false, + note: None, + name: Some( + "service_id, ticket_item_id", + ), + }, + ), + }, + IndexesDef { + span_range: 1705..1779, + cols: [ + String( + Ident { + span_range: 1705..1730, + raw: "composite_service_item_id", + to_string: "composite_service_item_id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1731..1779, + attributes: [ + Attribute { + span_range: 1732..1743, + key: Ident { + span_range: 1732..1736, + raw: "type", + to_string: "type", + }, + value: Some( + Literal { + span_range: 1738..1743, + raw: "btree", + value: Enum( + "btree", + ), + }, + ), + }, + Attribute { + span_range: 1745..1778, + key: Ident { + span_range: 1745..1749, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1751..1778, + raw: "\"composite_service_item_id\"", + value: String( + "composite_service_item_id", + ), + }, + ), + }, + ], + type: Some( + BTree, + ), + is_unique: false, + is_pk: false, + note: None, + name: Some( + "composite_service_item_id", + ), + }, + ), + }, + IndexesDef { + span_range: 1782..1850, + cols: [ + String( + Ident { + span_range: 1783..1793, + raw: "service_id", + to_string: "service_id", + }, + ), + String( + Ident { + span_range: 1795..1808, + raw: "patient_price", + to_string: "patient_price", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1810..1850, + attributes: [ + Attribute { + span_range: 1811..1821, + key: Ident { + span_range: 1811..1815, + raw: "type", + to_string: "type", + }, + value: Some( + Literal { + span_range: 1817..1821, + raw: "hash", + value: Enum( + "hash", + ), + }, + ), + }, + Attribute { + span_range: 1823..1849, + key: Ident { + span_range: 1823..1827, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1829..1849, + raw: "\"test test test key\"", + value: String( + "test test test key", + ), + }, + ), + }, + ], + type: Some( + Hash, + ), + is_unique: false, + is_pk: false, + note: None, + name: Some( + "test test test key", + ), + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1856..1935, + cols: [ + TableColumn { + span_range: 1878..1901, + name: Ident { + span_range: 1878..1882, + raw: "\"Id\"", + to_string: "Id", + }, + type: ColumnType { + span_range: 1883..1886, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1887..1901, + attributes: [ + Attribute { + span_range: 1888..1890, + key: Ident { + span_range: 1888..1890, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + Attribute { + span_range: 1892..1900, + key: Ident { + span_range: 1892..1900, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1904..1933, + name: Ident { + span_range: 1904..1910, + raw: "\"Name\"", + to_string: "Name", + }, + type: ColumnType { + span_range: 1911..1922, + raw: "varchar(32)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 32, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1923..1933, + attributes: [ + Attribute { + span_range: 1924..1932, + key: Ident { + span_range: 1924..1932, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 1862..1874, + name: Ident { + span_range: 1862..1873, + raw: "\"Countries\"", + to_string: "Countries", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1937..2116, + cols: [ + TableColumn { + span_range: 1956..1975, + name: Ident { + span_range: 1956..1960, + raw: "\"Id\"", + to_string: "Id", + }, + type: ColumnType { + span_range: 1961..1964, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1965..1975, + attributes: [ + Attribute { + span_range: 1966..1974, + key: Ident { + span_range: 1966..1974, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1978..2004, + name: Ident { + span_range: 1978..1989, + raw: "\"CountryId\"", + to_string: "CountryId", + }, + type: ColumnType { + span_range: 1990..1993, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1994..2004, + attributes: [ + Attribute { + span_range: 1995..2003, + key: Ident { + span_range: 1995..2003, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 2007..2036, + name: Ident { + span_range: 2007..2013, + raw: "\"Name\"", + to_string: "Name", + }, + type: ColumnType { + span_range: 2014..2025, + raw: "varchar(32)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 32, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 2026..2036, + attributes: [ + Attribute { + span_range: 2027..2035, + key: Ident { + span_range: 2027..2035, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 1943..1952, + name: Ident { + span_range: 1943..1951, + raw: "\"States\"", + to_string: "States", + }, + schema: None, + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 2046..2114, + defs: [ + IndexesDef { + span_range: 2050..2089, + cols: [ + String( + Ident { + span_range: 2050..2059, + raw: "CountryId", + to_string: "CountryId", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 2060..2089, + attributes: [ + Attribute { + span_range: 2061..2088, + key: Ident { + span_range: 2061..2065, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 2067..2088, + raw: "\"IX_States_CountryId\"", + value: String( + "IX_States_CountryId", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "IX_States_CountryId", + ), + }, + ), + }, + IndexesDef { + span_range: 2092..2112, + cols: [ + String( + Ident { + span_range: 2093..2095, + raw: "Id", + to_string: "Id", + }, + ), + String( + Ident { + span_range: 2097..2106, + raw: "CountryId", + to_string: "CountryId", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 2108..2112, + attributes: [ + Attribute { + span_range: 2109..2111, + key: Ident { + span_range: 2109..2111, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + type: None, + is_unique: false, + is_pk: true, + note: None, + name: None, + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 2118..2394, + cols: [ + TableColumn { + span_range: 2137..2156, + name: Ident { + span_range: 2137..2141, + raw: "\"Id\"", + to_string: "Id", + }, + type: ColumnType { + span_range: 2142..2145, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 2146..2156, + attributes: [ + Attribute { + span_range: 2147..2155, + key: Ident { + span_range: 2147..2155, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 2159..2185, + name: Ident { + span_range: 2159..2170, + raw: "\"CountryId\"", + to_string: "CountryId", + }, + type: ColumnType { + span_range: 2171..2174, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 2175..2185, + attributes: [ + Attribute { + span_range: 2176..2184, + key: Ident { + span_range: 2176..2184, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 2188..2212, + name: Ident { + span_range: 2188..2197, + raw: "\"StateId\"", + to_string: "StateId", + }, + type: ColumnType { + span_range: 2198..2201, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 2202..2212, + attributes: [ + Attribute { + span_range: 2203..2211, + key: Ident { + span_range: 2203..2211, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 2215..2244, + name: Ident { + span_range: 2215..2221, + raw: "\"Name\"", + to_string: "Name", + }, + type: ColumnType { + span_range: 2222..2233, + raw: "varchar(32)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 32, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 2234..2244, + attributes: [ + Attribute { + span_range: 2235..2243, + key: Ident { + span_range: 2235..2243, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 2124..2133, + name: Ident { + span_range: 2124..2132, + raw: "\"Cities\"", + to_string: "Cities", + }, + schema: None, + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 2254..2392, + defs: [ + IndexesDef { + span_range: 2258..2297, + cols: [ + String( + Ident { + span_range: 2258..2267, + raw: "CountryId", + to_string: "CountryId", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 2268..2297, + attributes: [ + Attribute { + span_range: 2269..2296, + key: Ident { + span_range: 2269..2273, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 2275..2296, + raw: "\"IX_Cities_CountryId\"", + value: String( + "IX_Cities_CountryId", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "IX_Cities_CountryId", + ), + }, + ), + }, + IndexesDef { + span_range: 2300..2358, + cols: [ + String( + Ident { + span_range: 2301..2308, + raw: "StateId", + to_string: "StateId", + }, + ), + String( + Ident { + span_range: 2310..2319, + raw: "CountryId", + to_string: "CountryId", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 2321..2358, + attributes: [ + Attribute { + span_range: 2322..2357, + key: Ident { + span_range: 2322..2326, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 2328..2357, + raw: "\"IX_Cities_StateId_CountryId\"", + value: String( + "IX_Cities_StateId_CountryId", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "IX_Cities_StateId_CountryId", + ), + }, + ), + }, + IndexesDef { + span_range: 2361..2390, + cols: [ + String( + Ident { + span_range: 2362..2364, + raw: "Id", + to_string: "Id", + }, + ), + String( + Ident { + span_range: 2366..2373, + raw: "StateId", + to_string: "StateId", + }, + ), + String( + Ident { + span_range: 2375..2384, + raw: "CountryId", + to_string: "CountryId", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 2386..2390, + attributes: [ + Attribute { + span_range: 2387..2389, + key: Ident { + span_range: 2387..2389, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + type: None, + is_unique: false, + is_pk: true, + note: None, + name: None, + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 2432..2489, + name: Some( + Ident { + span_range: 2400..2431, + raw: "\"FK_States_Countries_CountryId\"", + to_string: "FK_States_Countries_CountryId", + }, + ), + rel: One2Many, + lhs: RefIdent { + span_range: 2432..2448, + schema: None, + table: Ident { + span_range: 2432..2443, + raw: "\"Countries\"", + to_string: "Countries", + }, + compositions: [ + Ident { + span_range: 2444..2448, + raw: "\"Id\"", + to_string: "Id", + }, + ], + }, + rhs: RefIdent { + span_range: 2451..2471, + schema: None, + table: Ident { + span_range: 2451..2459, + raw: "\"States\"", + to_string: "States", + }, + compositions: [ + Ident { + span_range: 2460..2471, + raw: "\"CountryId\"", + to_string: "CountryId", + }, + ], + }, + settings: Some( + RefSettings { + span_range: 2472..2489, + attributes: [ + Attribute { + span_range: 2473..2488, + key: Ident { + span_range: 2473..2479, + raw: "delete", + to_string: "delete", + }, + value: Some( + Literal { + span_range: 2481..2488, + raw: "cascade", + value: Enum( + "cascade", + ), + }, + ), + }, + ], + on_delete: Some( + Cascade, + ), + on_update: None, + }, + ), + }, + ), + Ref( + RefBlock { + span_range: 2527..2584, + name: Some( + Ident { + span_range: 2495..2526, + raw: "\"FK_Cities_Countries_CountryId\"", + to_string: "FK_Cities_Countries_CountryId", + }, + ), + rel: One2Many, + lhs: RefIdent { + span_range: 2527..2543, + schema: None, + table: Ident { + span_range: 2527..2538, + raw: "\"Countries\"", + to_string: "Countries", + }, + compositions: [ + Ident { + span_range: 2539..2543, + raw: "\"Id\"", + to_string: "Id", + }, + ], + }, + rhs: RefIdent { + span_range: 2546..2566, + schema: None, + table: Ident { + span_range: 2546..2554, + raw: "\"Cities\"", + to_string: "Cities", + }, + compositions: [ + Ident { + span_range: 2555..2566, + raw: "\"CountryId\"", + to_string: "CountryId", + }, + ], + }, + settings: Some( + RefSettings { + span_range: 2567..2584, + attributes: [ + Attribute { + span_range: 2568..2583, + key: Ident { + span_range: 2568..2574, + raw: "delete", + to_string: "delete", + }, + value: Some( + Literal { + span_range: 2576..2583, + raw: "cascade", + value: Enum( + "cascade", + ), + }, + ), + }, + ], + on_delete: Some( + Cascade, + ), + on_update: None, + }, + ), + }, + ), + Ref( + RefBlock { + span_range: 2627..2709, + name: Some( + Ident { + span_range: 2590..2626, + raw: "\"FK_Cities_States_StateId_CountryId\"", + to_string: "FK_Cities_States_StateId_CountryId", + }, + ), + rel: One2Many, + lhs: RefIdent { + span_range: 2627..2655, + schema: None, + table: Ident { + span_range: 2627..2635, + raw: "\"States\"", + to_string: "States", + }, + compositions: [ + Ident { + span_range: 2637..2641, + raw: "\"Id\"", + to_string: "Id", + }, + Ident { + span_range: 2643..2654, + raw: "\"CountryId\"", + to_string: "CountryId", + }, + ], + }, + rhs: RefIdent { + span_range: 2658..2691, + schema: None, + table: Ident { + span_range: 2658..2666, + raw: "\"Cities\"", + to_string: "Cities", + }, + compositions: [ + Ident { + span_range: 2668..2677, + raw: "\"StateId\"", + to_string: "StateId", + }, + Ident { + span_range: 2679..2690, + raw: "\"CountryId\"", + to_string: "CountryId", + }, + ], + }, + settings: Some( + RefSettings { + span_range: 2692..2709, + attributes: [ + Attribute { + span_range: 2693..2708, + key: Ident { + span_range: 2693..2699, + raw: "delete", + to_string: "delete", + }, + value: Some( + Literal { + span_range: 2701..2708, + raw: "cascade", + value: Enum( + "cascade", + ), + }, + ), + }, + ], + on_delete: Some( + Cascade, + ), + on_update: None, + }, + ), + }, + ), + Ref( + RefBlock { + span_range: 2715..2757, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 2715..2728, + schema: None, + table: Ident { + span_range: 2715..2723, + raw: "\"orders\"", + to_string: "orders", + }, + compositions: [ + Ident { + span_range: 2724..2728, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 2731..2755, + schema: None, + table: Ident { + span_range: 2731..2744, + raw: "\"order_items\"", + to_string: "order_items", + }, + compositions: [ + Ident { + span_range: 2745..2755, + raw: "\"order_id\"", + to_string: "order_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 2761..2807, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 2761..2776, + schema: None, + table: Ident { + span_range: 2761..2771, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 2772..2776, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 2779..2805, + schema: None, + table: Ident { + span_range: 2779..2792, + raw: "\"order_items\"", + to_string: "order_items", + }, + compositions: [ + Ident { + span_range: 2793..2805, + raw: "\"product_id\"", + to_string: "product_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 2811..2856, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 2811..2829, + schema: None, + table: Ident { + span_range: 2811..2822, + raw: "\"countries\"", + to_string: "countries", + }, + compositions: [ + Ident { + span_range: 2823..2829, + raw: "\"code\"", + to_string: "code", + }, + ], + }, + rhs: RefIdent { + span_range: 2832..2854, + schema: None, + table: Ident { + span_range: 2832..2839, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 2840..2854, + raw: "\"country_code\"", + to_string: "country_code", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 2860..2909, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 2860..2878, + schema: None, + table: Ident { + span_range: 2860..2871, + raw: "\"countries\"", + to_string: "countries", + }, + compositions: [ + Ident { + span_range: 2872..2878, + raw: "\"code\"", + to_string: "code", + }, + ], + }, + rhs: RefIdent { + span_range: 2881..2907, + schema: None, + table: Ident { + span_range: 2881..2892, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 2893..2907, + raw: "\"country_code\"", + to_string: "country_code", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 2913..2958, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 2913..2929, + schema: None, + table: Ident { + span_range: 2913..2924, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 2925..2929, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 2932..2956, + schema: None, + table: Ident { + span_range: 2932..2942, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 2943..2956, + raw: "\"merchant_id\"", + to_string: "merchant_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 2962..2999, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 2962..2974, + schema: None, + table: Ident { + span_range: 2962..2969, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 2970..2974, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 2977..2999, + schema: None, + table: Ident { + span_range: 2977..2988, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 2989..2999, + raw: "\"admin_id\"", + to_string: "admin_id", + }, + ], + }, + settings: None, + }, + ), + ], +} \ No newline at end of file diff --git a/tests/out/mysql_importer/multiple_schema.out.ron b/tests/out/mysql_importer/multiple_schema.out.ron new file mode 100644 index 0000000..f48d829 --- /dev/null +++ b/tests/out/mysql_importer/multiple_schema.out.ron @@ -0,0 +1,1279 @@ +SchemaBlock { + span_range: 0..1458, + input: "Enum \"users_pjs_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"users_pjs2_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"users_pg_enum\" {\n \"male\"\n \"female\"\n}\n\nEnum \"users_pg2_enum\" {\n \"male2\"\n \"female2\"\n}\n\nEnum \"ecommerce_users_ejs_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"ecommerce_users_ejs2_enum\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"ecommerce_users_eg_enum\" {\n \"male\"\n \"female\"\n}\n\nEnum \"ecommerce_users_eg2_enum\" {\n \"male2\"\n \"female2\"\n}\n\nTable \"users\" {\n \"id\" int [pk]\n \"name\" varchar(255)\n \"pjs\" users_pjs_enum\n \"pjs2\" users_pjs2_enum\n \"pg\" users_pg_enum\n \"pg2\" users_pg2_enum\n}\n\nTable \"products\" {\n \"id\" int [pk]\n \"name\" varchar(255) [note: 'Product name']\n}\n\nRef \"FK_1\":\"schemaA\".\"locations\".\"id\" < \"schemaA\".\"products\".\"lid\" [delete: cascade]\n\nRef:\"users\".\"id\" < \"ecommerce\".\"users\".\"id\"\n\nRef:\"users\".\"name\" < \"ecommerce\".\"users\".\"id\"\n\nRef:\"ecommerce\".\"users\".\"id\" < \"schemaA\".\"products\".\"name\"\n\nRef:\"users\".\"id\" < \"schemaA\".\"locations\".\"name\"\n\nTable \"ecommerce\".\"users\" {\n \"id\" int [pk]\n \"name\" varchar(255)\n \"ejs\" ecommerce_users_ejs_enum\n \"ejs2\" ecommerce_users_ejs2_enum\n \"eg\" ecommerce_users_eg_enum\n \"eg2\" ecommerce_users_eg2_enum\n}\n\nTable \"schemaA\".\"products\" {\n \"id\" int [pk]\n \"name\" varchar(255) [note: 'Sample field comment on multiples schema']\n \"lid\" int\n}\n\nTable \"schemaA\".\"locations\" {\n \"id\" int [pk]\n \"name\" varchar(255)\n}", + blocks: [ + Enum( + EnumBlock { + span_range: 0..74, + ident: EnumIdent { + span_range: 5..22, + schema: None, + name: Ident { + span_range: 5..21, + raw: "\"users_pjs_enum\"", + to_string: "users_pjs_enum", + }, + }, + values: [ + EnumValue { + span_range: 26..39, + value: Ident { + span_range: 26..36, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 39..52, + value: Ident { + span_range: 39..49, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 52..62, + value: Ident { + span_range: 52..59, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 62..73, + value: Ident { + span_range: 62..72, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 76..151, + ident: EnumIdent { + span_range: 81..99, + schema: None, + name: Ident { + span_range: 81..98, + raw: "\"users_pjs2_enum\"", + to_string: "users_pjs2_enum", + }, + }, + values: [ + EnumValue { + span_range: 103..116, + value: Ident { + span_range: 103..113, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 116..129, + value: Ident { + span_range: 116..126, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 129..139, + value: Ident { + span_range: 129..136, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 139..150, + value: Ident { + span_range: 139..149, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 153..197, + ident: EnumIdent { + span_range: 158..174, + schema: None, + name: Ident { + span_range: 158..173, + raw: "\"users_pg_enum\"", + to_string: "users_pg_enum", + }, + }, + values: [ + EnumValue { + span_range: 178..187, + value: Ident { + span_range: 178..184, + raw: "\"male\"", + to_string: "male", + }, + settings: None, + }, + EnumValue { + span_range: 187..196, + value: Ident { + span_range: 187..195, + raw: "\"female\"", + to_string: "female", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 199..246, + ident: EnumIdent { + span_range: 204..221, + schema: None, + name: Ident { + span_range: 204..220, + raw: "\"users_pg2_enum\"", + to_string: "users_pg2_enum", + }, + }, + values: [ + EnumValue { + span_range: 225..235, + value: Ident { + span_range: 225..232, + raw: "\"male2\"", + to_string: "male2", + }, + settings: None, + }, + EnumValue { + span_range: 235..245, + value: Ident { + span_range: 235..244, + raw: "\"female2\"", + to_string: "female2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 248..332, + ident: EnumIdent { + span_range: 253..280, + schema: None, + name: Ident { + span_range: 253..279, + raw: "\"ecommerce_users_ejs_enum\"", + to_string: "ecommerce_users_ejs_enum", + }, + }, + values: [ + EnumValue { + span_range: 284..297, + value: Ident { + span_range: 284..294, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 297..310, + value: Ident { + span_range: 297..307, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 310..320, + value: Ident { + span_range: 310..317, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 320..331, + value: Ident { + span_range: 320..330, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 334..419, + ident: EnumIdent { + span_range: 339..367, + schema: None, + name: Ident { + span_range: 339..366, + raw: "\"ecommerce_users_ejs2_enum\"", + to_string: "ecommerce_users_ejs2_enum", + }, + }, + values: [ + EnumValue { + span_range: 371..384, + value: Ident { + span_range: 371..381, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 384..397, + value: Ident { + span_range: 384..394, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 397..407, + value: Ident { + span_range: 397..404, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 407..418, + value: Ident { + span_range: 407..417, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 421..475, + ident: EnumIdent { + span_range: 426..452, + schema: None, + name: Ident { + span_range: 426..451, + raw: "\"ecommerce_users_eg_enum\"", + to_string: "ecommerce_users_eg_enum", + }, + }, + values: [ + EnumValue { + span_range: 456..465, + value: Ident { + span_range: 456..462, + raw: "\"male\"", + to_string: "male", + }, + settings: None, + }, + EnumValue { + span_range: 465..474, + value: Ident { + span_range: 465..473, + raw: "\"female\"", + to_string: "female", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 477..534, + ident: EnumIdent { + span_range: 482..509, + schema: None, + name: Ident { + span_range: 482..508, + raw: "\"ecommerce_users_eg2_enum\"", + to_string: "ecommerce_users_eg2_enum", + }, + }, + values: [ + EnumValue { + span_range: 513..523, + value: Ident { + span_range: 513..520, + raw: "\"male2\"", + to_string: "male2", + }, + settings: None, + }, + EnumValue { + span_range: 523..533, + value: Ident { + span_range: 523..532, + raw: "\"female2\"", + to_string: "female2", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 536..683, + cols: [ + TableColumn { + span_range: 554..567, + name: Ident { + span_range: 554..558, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 559..562, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 563..567, + attributes: [ + Attribute { + span_range: 564..566, + key: Ident { + span_range: 564..566, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 570..592, + name: Ident { + span_range: 570..576, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 577..589, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 592..615, + name: Ident { + span_range: 592..597, + raw: "\"pjs\"", + to_string: "pjs", + }, + type: ColumnType { + span_range: 598..612, + raw: "users_pjs_enum", + type_name: Raw( + "users_pjs_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 615..640, + name: Ident { + span_range: 615..621, + raw: "\"pjs2\"", + to_string: "pjs2", + }, + type: ColumnType { + span_range: 622..637, + raw: "users_pjs2_enum", + type_name: Raw( + "users_pjs2_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 640..661, + name: Ident { + span_range: 640..644, + raw: "\"pg\"", + to_string: "pg", + }, + type: ColumnType { + span_range: 645..658, + raw: "users_pg_enum", + type_name: Raw( + "users_pg_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 661..682, + name: Ident { + span_range: 661..666, + raw: "\"pg2\"", + to_string: "pg2", + }, + type: ColumnType { + span_range: 667..681, + raw: "users_pg2_enum", + type_name: Raw( + "users_pg2_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 542..550, + name: Ident { + span_range: 542..549, + raw: "\"users\"", + to_string: "users", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 685..766, + cols: [ + TableColumn { + span_range: 706..719, + name: Ident { + span_range: 706..710, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 711..714, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 715..719, + attributes: [ + Attribute { + span_range: 716..718, + key: Ident { + span_range: 716..718, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 722..764, + name: Ident { + span_range: 722..728, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 729..741, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 742..764, + attributes: [ + Attribute { + span_range: 743..763, + key: Ident { + span_range: 743..747, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 749..763, + raw: "'Product name'", + value: String( + "Product name", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "Product name", + ), + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 691..702, + name: Ident { + span_range: 691..701, + raw: "\"products\"", + to_string: "products", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 779..852, + name: Some( + Ident { + span_range: 772..778, + raw: "\"FK_1\"", + to_string: "FK_1", + }, + ), + rel: One2Many, + lhs: RefIdent { + span_range: 779..805, + schema: Some( + Ident { + span_range: 779..788, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 789..800, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 801..805, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 808..834, + schema: Some( + Ident { + span_range: 808..817, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 818..828, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 829..834, + raw: "\"lid\"", + to_string: "lid", + }, + ], + }, + settings: Some( + RefSettings { + span_range: 835..852, + attributes: [ + Attribute { + span_range: 836..851, + key: Ident { + span_range: 836..842, + raw: "delete", + to_string: "delete", + }, + value: Some( + Literal { + span_range: 844..851, + raw: "cascade", + value: Enum( + "cascade", + ), + }, + ), + }, + ], + on_delete: Some( + Cascade, + ), + on_update: None, + }, + ), + }, + ), + Ref( + RefBlock { + span_range: 858..899, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 858..870, + schema: None, + table: Ident { + span_range: 858..865, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 866..870, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 873..897, + schema: Some( + Ident { + span_range: 873..884, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 885..892, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 893..897, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 903..946, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 903..917, + schema: None, + table: Ident { + span_range: 903..910, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 911..917, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + rhs: RefIdent { + span_range: 920..944, + schema: Some( + Ident { + span_range: 920..931, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 932..939, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 940..944, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 950..1006, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 950..974, + schema: Some( + Ident { + span_range: 950..961, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 962..969, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 970..974, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 977..1004, + schema: Some( + Ident { + span_range: 977..986, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 987..997, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 998..1004, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1010..1055, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1010..1022, + schema: None, + table: Ident { + span_range: 1010..1017, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1018..1022, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1025..1053, + schema: Some( + Ident { + span_range: 1025..1034, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 1035..1046, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 1047..1053, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1055..1254, + cols: [ + TableColumn { + span_range: 1085..1098, + name: Ident { + span_range: 1085..1089, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1090..1093, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1094..1098, + attributes: [ + Attribute { + span_range: 1095..1097, + key: Ident { + span_range: 1095..1097, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1101..1123, + name: Ident { + span_range: 1101..1107, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1108..1120, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1123..1156, + name: Ident { + span_range: 1123..1128, + raw: "\"ejs\"", + to_string: "ejs", + }, + type: ColumnType { + span_range: 1129..1153, + raw: "ecommerce_users_ejs_enum", + type_name: Raw( + "ecommerce_users_ejs_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1156..1191, + name: Ident { + span_range: 1156..1162, + raw: "\"ejs2\"", + to_string: "ejs2", + }, + type: ColumnType { + span_range: 1163..1188, + raw: "ecommerce_users_ejs2_enum", + type_name: Raw( + "ecommerce_users_ejs2_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1191..1222, + name: Ident { + span_range: 1191..1195, + raw: "\"eg\"", + to_string: "eg", + }, + type: ColumnType { + span_range: 1196..1219, + raw: "ecommerce_users_eg_enum", + type_name: Raw( + "ecommerce_users_eg_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1222..1253, + name: Ident { + span_range: 1222..1227, + raw: "\"eg2\"", + to_string: "eg2", + }, + type: ColumnType { + span_range: 1228..1252, + raw: "ecommerce_users_eg2_enum", + type_name: Raw( + "ecommerce_users_eg2_enum", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1061..1080, + name: Ident { + span_range: 1073..1080, + raw: "\"users\"", + to_string: "users", + }, + schema: Some( + Ident { + span_range: 1061..1072, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1256..1387, + cols: [ + TableColumn { + span_range: 1287..1300, + name: Ident { + span_range: 1287..1291, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1292..1295, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1296..1300, + attributes: [ + Attribute { + span_range: 1297..1299, + key: Ident { + span_range: 1297..1299, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1303..1373, + name: Ident { + span_range: 1303..1309, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1310..1322, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1323..1373, + attributes: [ + Attribute { + span_range: 1324..1372, + key: Ident { + span_range: 1324..1328, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 1330..1372, + raw: "'Sample field comment on multiples schema'", + value: String( + "Sample field comment on multiples schema", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "Sample field comment on multiples schema", + ), + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1376..1386, + name: Ident { + span_range: 1376..1381, + raw: "\"lid\"", + to_string: "lid", + }, + type: ColumnType { + span_range: 1382..1385, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1262..1282, + name: Ident { + span_range: 1272..1282, + raw: "\"products\"", + to_string: "products", + }, + schema: Some( + Ident { + span_range: 1262..1271, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1389..1458, + cols: [ + TableColumn { + span_range: 1421..1434, + name: Ident { + span_range: 1421..1425, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1426..1429, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1430..1434, + attributes: [ + Attribute { + span_range: 1431..1433, + key: Ident { + span_range: 1431..1433, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1437..1457, + name: Ident { + span_range: 1437..1443, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1444..1456, + raw: "varchar(255)", + type_name: Raw( + "varchar", + ), + args: [ + Integer( + 255, + ), + ], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1395..1416, + name: Ident { + span_range: 1405..1416, + raw: "\"locations\"", + to_string: "locations", + }, + schema: Some( + Ident { + span_range: 1395..1404, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + ], +} \ No newline at end of file diff --git a/tests/out/postgres_importer/general_schema.out.ron b/tests/out/postgres_importer/general_schema.out.ron new file mode 100644 index 0000000..a36b486 --- /dev/null +++ b/tests/out/postgres_importer/general_schema.out.ron @@ -0,0 +1,1857 @@ +SchemaBlock { + span_range: 0..1873, + input: "Enum \"orders_status\" {\n \"created\"\n \"running\"\n \"done\"\n \"failure\"\n}\n\nEnum \"product status\" {\n \"Out of Stock\"\n \"In Stock\"\n}\n\nTable \"orders\" {\n \"id\" int [pk, increment]\n \"user_id\" int [unique, not null]\n \"status\" orders_status\n \"created_at\" varchar\n \"modified_at\" timestamp(2)\n}\n\nTable \"order_items\" {\n \"order_id\" int\n \"product_id\" int\n \"quantity\" int [default: 1]\n \"created_at\" timestamp\n \"modified_at\" time\n}\n\nTable \"products\" {\n \"id\" int\n \"name\" varchar\n \"merchant_id\" int [not null]\n \"price\" int\n \"status\" \"product status\"\n \"created_at\" datetime [default: `now()`]\n \"modified_at\" timestamp\n\nIndexes {\n (id, name) [pk]\n (merchant_id, status) [name: \"product_status\"]\n id [type: hash, unique]\n}\n Note: 'Products table comment'\n}\n\nTable \"users\" {\n \"id\" int [pk]\n \"full_name\" varchar\n \"email\" varchar [unique]\n \"gender\" varchar\n \"date_of_birth\" varchar\n \"created_at\" varchar\n \"modified_at\" time(2)\n \"country_code\" int\n Note: 'Store user data'\n}\n\nTable \"merchants\" {\n \"id\" int [pk]\n \"merchant_name\" varchar\n \"country_code\" int\n \"created_at\" varchar\n \"modified_at\" time\n \"admin_id\" int\n}\n\nTable \"countries\" {\n \"code\" int [pk]\n \"name\" varchar\n \"continent_name\" varchar\n}\n\nTable \"foo\" {\n \"bar\" \"text[]\"\n \"bar2\" \"int[1]\"\n \"bar3\" \"int[2][3]\"\n \"bar4\" \"int[]\"\n \"bar5\" \"int[2]\"\n \"bar6\" \"text[8]\"\n \"bar7\" \"text[100]\"\n \"bar8\" \"time(2)[]\"\n \"bar9\" \"time(1)[1]\"\n \"bar10\" \"time(1)[]\"\n \"bar11\" \"time[5]\"\n \"bar12\" \"timestamp(2)[10][2][5]\"\n \"bar13\" \"character varying[]\"\n \"bar14\" \"character varying(25)[][2][]\"\n \"bar15\" \"character varying[76]\"\n}\n\nRef:\"orders\".\"id\" < \"order_items\".\"order_id\"\n\nRef:\"products\".\"id\" < \"order_items\".\"product_id\"\n\nRef:\"countries\".\"code\" < \"users\".\"country_code\"\n\nRef:\"countries\".\"code\" < \"merchants\".\"country_code\"\n\nRef:\"merchants\".\"id\" < \"products\".\"merchant_id\"\n\nRef:\"users\".\"id\" < \"merchants\".\"admin_id\"", + blocks: [ + Enum( + EnumBlock { + span_range: 0..69, + ident: EnumIdent { + span_range: 5..21, + schema: None, + name: Ident { + span_range: 5..20, + raw: "\"orders_status\"", + to_string: "orders_status", + }, + }, + values: [ + EnumValue { + span_range: 25..37, + value: Ident { + span_range: 25..34, + raw: "\"created\"", + to_string: "created", + }, + settings: None, + }, + EnumValue { + span_range: 37..49, + value: Ident { + span_range: 37..46, + raw: "\"running\"", + to_string: "running", + }, + settings: None, + }, + EnumValue { + span_range: 49..58, + value: Ident { + span_range: 49..55, + raw: "\"done\"", + to_string: "done", + }, + settings: None, + }, + EnumValue { + span_range: 58..68, + value: Ident { + span_range: 58..67, + raw: "\"failure\"", + to_string: "failure", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 71..126, + ident: EnumIdent { + span_range: 76..93, + schema: None, + name: Ident { + span_range: 76..92, + raw: "\"product status\"", + to_string: "product status", + }, + }, + values: [ + EnumValue { + span_range: 97..114, + value: Ident { + span_range: 97..111, + raw: "\"Out of Stock\"", + to_string: "Out of Stock", + }, + settings: None, + }, + EnumValue { + span_range: 114..125, + value: Ident { + span_range: 114..124, + raw: "\"In Stock\"", + to_string: "In Stock", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 128..285, + cols: [ + TableColumn { + span_range: 147..171, + name: Ident { + span_range: 147..151, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 152..155, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 156..171, + attributes: [ + Attribute { + span_range: 157..159, + key: Ident { + span_range: 157..159, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + Attribute { + span_range: 161..170, + key: Ident { + span_range: 161..170, + raw: "increment", + to_string: "increment", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: true, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 174..206, + name: Ident { + span_range: 174..183, + raw: "\"user_id\"", + to_string: "user_id", + }, + type: ColumnType { + span_range: 184..187, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 188..206, + attributes: [ + Attribute { + span_range: 189..195, + key: Ident { + span_range: 189..195, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + Attribute { + span_range: 197..205, + key: Ident { + span_range: 197..205, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: true, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 209..234, + name: Ident { + span_range: 209..217, + raw: "\"status\"", + to_string: "status", + }, + type: ColumnType { + span_range: 218..231, + raw: "orders_status", + type_name: Raw( + "orders_status", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 234..257, + name: Ident { + span_range: 234..246, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 247..254, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 257..284, + name: Ident { + span_range: 257..270, + raw: "\"modified_at\"", + to_string: "modified_at", + }, + type: ColumnType { + span_range: 271..283, + raw: "timestamp(2)", + type_name: Raw( + "timestamp", + ), + args: [ + Integer( + 2, + ), + ], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 134..143, + name: Ident { + span_range: 134..142, + raw: "\"orders\"", + to_string: "orders", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 287..422, + cols: [ + TableColumn { + span_range: 311..328, + name: Ident { + span_range: 311..321, + raw: "\"order_id\"", + to_string: "order_id", + }, + type: ColumnType { + span_range: 322..325, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 328..347, + name: Ident { + span_range: 328..340, + raw: "\"product_id\"", + to_string: "product_id", + }, + type: ColumnType { + span_range: 341..344, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 347..374, + name: Ident { + span_range: 347..357, + raw: "\"quantity\"", + to_string: "quantity", + }, + type: ColumnType { + span_range: 358..361, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 362..374, + attributes: [ + Attribute { + span_range: 363..373, + key: Ident { + span_range: 363..370, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 372..373, + raw: "1", + value: Integer( + 1, + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Integer( + 1, + ), + ), + refs: [], + }, + ), + }, + TableColumn { + span_range: 377..402, + name: Ident { + span_range: 377..389, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 390..399, + raw: "timestamp", + type_name: Raw( + "timestamp", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 402..421, + name: Ident { + span_range: 402..415, + raw: "\"modified_at\"", + to_string: "modified_at", + }, + type: ColumnType { + span_range: 416..420, + raw: "time", + type_name: Raw( + "time", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 293..307, + name: Ident { + span_range: 293..306, + raw: "\"order_items\"", + to_string: "order_items", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 424..753, + cols: [ + TableColumn { + span_range: 445..456, + name: Ident { + span_range: 445..449, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 450..453, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 456..473, + name: Ident { + span_range: 456..462, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 463..470, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 473..501, + name: Ident { + span_range: 473..486, + raw: "\"merchant_id\"", + to_string: "merchant_id", + }, + type: ColumnType { + span_range: 487..490, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 491..501, + attributes: [ + Attribute { + span_range: 492..500, + key: Ident { + span_range: 492..500, + raw: "not null", + to_string: "not null", + }, + value: None, + }, + ], + is_pk: false, + is_unique: false, + nullable: Some( + NotNull, + ), + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 504..518, + name: Ident { + span_range: 504..511, + raw: "\"price\"", + to_string: "price", + }, + type: ColumnType { + span_range: 512..515, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 518..546, + name: Ident { + span_range: 518..526, + raw: "\"status\"", + to_string: "status", + }, + type: ColumnType { + span_range: 527..543, + raw: "\"product status\"", + type_name: Raw( + "product status", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 546..586, + name: Ident { + span_range: 546..558, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 559..567, + raw: "datetime", + type_name: Raw( + "datetime", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 568..586, + attributes: [ + Attribute { + span_range: 569..585, + key: Ident { + span_range: 569..576, + raw: "default", + to_string: "default", + }, + value: Some( + Literal { + span_range: 578..585, + raw: "`now()`", + value: Expr( + "now()", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: Some( + Expr( + "now()", + ), + ), + refs: [], + }, + ), + }, + TableColumn { + span_range: 589..614, + name: Ident { + span_range: 589..602, + raw: "\"modified_at\"", + to_string: "modified_at", + }, + type: ColumnType { + span_range: 603..612, + raw: "timestamp", + type_name: Raw( + "timestamp", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 430..441, + name: Ident { + span_range: 430..440, + raw: "\"products\"", + to_string: "products", + }, + schema: None, + alias: None, + }, + note: Some( + NoteBlock { + span_range: 721..751, + value: Literal { + span_range: 727..751, + raw: "'Products table comment'", + value: String( + "Products table comment", + ), + }, + }, + ), + indexes: Some( + IndexesBlock { + span_range: 622..718, + defs: [ + IndexesDef { + span_range: 626..641, + cols: [ + String( + Ident { + span_range: 627..629, + raw: "id", + to_string: "id", + }, + ), + String( + Ident { + span_range: 631..635, + raw: "name", + to_string: "name", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 637..641, + attributes: [ + Attribute { + span_range: 638..640, + key: Ident { + span_range: 638..640, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + type: None, + is_unique: false, + is_pk: true, + note: None, + name: None, + }, + ), + }, + IndexesDef { + span_range: 644..690, + cols: [ + String( + Ident { + span_range: 645..656, + raw: "merchant_id", + to_string: "merchant_id", + }, + ), + String( + Ident { + span_range: 658..664, + raw: "status", + to_string: "status", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 666..690, + attributes: [ + Attribute { + span_range: 667..689, + key: Ident { + span_range: 667..671, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 673..689, + raw: "\"product_status\"", + value: String( + "product_status", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "product_status", + ), + }, + ), + }, + IndexesDef { + span_range: 693..716, + cols: [ + String( + Ident { + span_range: 693..695, + raw: "id", + to_string: "id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 696..716, + attributes: [ + Attribute { + span_range: 697..707, + key: Ident { + span_range: 697..701, + raw: "type", + to_string: "type", + }, + value: Some( + Literal { + span_range: 703..707, + raw: "hash", + value: Enum( + "hash", + ), + }, + ), + }, + Attribute { + span_range: 709..715, + key: Ident { + span_range: 709..715, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + ], + type: Some( + Hash, + ), + is_unique: true, + is_pk: false, + note: None, + name: None, + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 755..976, + cols: [ + TableColumn { + span_range: 773..786, + name: Ident { + span_range: 773..777, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 778..781, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 782..786, + attributes: [ + Attribute { + span_range: 783..785, + key: Ident { + span_range: 783..785, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 789..811, + name: Ident { + span_range: 789..800, + raw: "\"full_name\"", + to_string: "full_name", + }, + type: ColumnType { + span_range: 801..808, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 811..835, + name: Ident { + span_range: 811..818, + raw: "\"email\"", + to_string: "email", + }, + type: ColumnType { + span_range: 819..826, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 827..835, + attributes: [ + Attribute { + span_range: 828..834, + key: Ident { + span_range: 828..834, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + ], + is_pk: false, + is_unique: true, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 838..857, + name: Ident { + span_range: 838..846, + raw: "\"gender\"", + to_string: "gender", + }, + type: ColumnType { + span_range: 847..854, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 857..883, + name: Ident { + span_range: 857..872, + raw: "\"date_of_birth\"", + to_string: "date_of_birth", + }, + type: ColumnType { + span_range: 873..880, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 883..906, + name: Ident { + span_range: 883..895, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 896..903, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 906..930, + name: Ident { + span_range: 906..919, + raw: "\"modified_at\"", + to_string: "modified_at", + }, + type: ColumnType { + span_range: 920..927, + raw: "time(2)", + type_name: Raw( + "time", + ), + args: [ + Integer( + 2, + ), + ], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 930..951, + name: Ident { + span_range: 930..944, + raw: "\"country_code\"", + to_string: "country_code", + }, + type: ColumnType { + span_range: 945..948, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 761..769, + name: Ident { + span_range: 761..768, + raw: "\"users\"", + to_string: "users", + }, + schema: None, + alias: None, + }, + note: Some( + NoteBlock { + span_range: 951..974, + value: Literal { + span_range: 957..974, + raw: "'Store user data'", + value: String( + "Store user data", + ), + }, + }, + ), + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 978..1123, + cols: [ + TableColumn { + span_range: 1000..1013, + name: Ident { + span_range: 1000..1004, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1005..1008, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1009..1013, + attributes: [ + Attribute { + span_range: 1010..1012, + key: Ident { + span_range: 1010..1012, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1016..1042, + name: Ident { + span_range: 1016..1031, + raw: "\"merchant_name\"", + to_string: "merchant_name", + }, + type: ColumnType { + span_range: 1032..1039, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1042..1063, + name: Ident { + span_range: 1042..1056, + raw: "\"country_code\"", + to_string: "country_code", + }, + type: ColumnType { + span_range: 1057..1060, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1063..1086, + name: Ident { + span_range: 1063..1075, + raw: "\"created_at\"", + to_string: "created_at", + }, + type: ColumnType { + span_range: 1076..1083, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1086..1107, + name: Ident { + span_range: 1086..1099, + raw: "\"modified_at\"", + to_string: "modified_at", + }, + type: ColumnType { + span_range: 1100..1104, + raw: "time", + type_name: Raw( + "time", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1107..1122, + name: Ident { + span_range: 1107..1117, + raw: "\"admin_id\"", + to_string: "admin_id", + }, + type: ColumnType { + span_range: 1118..1121, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 984..996, + name: Ident { + span_range: 984..995, + raw: "\"merchants\"", + to_string: "merchants", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1125..1208, + cols: [ + TableColumn { + span_range: 1147..1162, + name: Ident { + span_range: 1147..1153, + raw: "\"code\"", + to_string: "code", + }, + type: ColumnType { + span_range: 1154..1157, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1158..1162, + attributes: [ + Attribute { + span_range: 1159..1161, + key: Ident { + span_range: 1159..1161, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1165..1182, + name: Ident { + span_range: 1165..1171, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1172..1179, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 1182..1207, + name: Ident { + span_range: 1182..1198, + raw: "\"continent_name\"", + to_string: "continent_name", + }, + type: ColumnType { + span_range: 1199..1206, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1131..1143, + name: Ident { + span_range: 1131..1142, + raw: "\"countries\"", + to_string: "countries", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1210..1583, + cols: [ + TableColumn { + span_range: 1226..1243, + name: Ident { + span_range: 1226..1231, + raw: "\"bar\"", + to_string: "bar", + }, + type: ColumnType { + span_range: 1232..1240, + raw: "\"text[]\"", + type_name: Raw( + "text", + ), + args: [], + arrays: [ + None, + ], + }, + settings: None, + }, + TableColumn { + span_range: 1243..1261, + name: Ident { + span_range: 1243..1249, + raw: "\"bar2\"", + to_string: "bar2", + }, + type: ColumnType { + span_range: 1250..1258, + raw: "\"int[1]\"", + type_name: Raw( + "int", + ), + args: [], + arrays: [ + Some( + 1, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1261..1282, + name: Ident { + span_range: 1261..1267, + raw: "\"bar3\"", + to_string: "bar3", + }, + type: ColumnType { + span_range: 1268..1279, + raw: "\"int[2][3]\"", + type_name: Raw( + "int", + ), + args: [], + arrays: [ + Some( + 2, + ), + Some( + 3, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1282..1299, + name: Ident { + span_range: 1282..1288, + raw: "\"bar4\"", + to_string: "bar4", + }, + type: ColumnType { + span_range: 1289..1296, + raw: "\"int[]\"", + type_name: Raw( + "int", + ), + args: [], + arrays: [ + None, + ], + }, + settings: None, + }, + TableColumn { + span_range: 1299..1317, + name: Ident { + span_range: 1299..1305, + raw: "\"bar5\"", + to_string: "bar5", + }, + type: ColumnType { + span_range: 1306..1314, + raw: "\"int[2]\"", + type_name: Raw( + "int", + ), + args: [], + arrays: [ + Some( + 2, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1317..1336, + name: Ident { + span_range: 1317..1323, + raw: "\"bar6\"", + to_string: "bar6", + }, + type: ColumnType { + span_range: 1324..1333, + raw: "\"text[8]\"", + type_name: Raw( + "text", + ), + args: [], + arrays: [ + Some( + 8, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1336..1357, + name: Ident { + span_range: 1336..1342, + raw: "\"bar7\"", + to_string: "bar7", + }, + type: ColumnType { + span_range: 1343..1354, + raw: "\"text[100]\"", + type_name: Raw( + "text", + ), + args: [], + arrays: [ + Some( + 100, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1357..1378, + name: Ident { + span_range: 1357..1363, + raw: "\"bar8\"", + to_string: "bar8", + }, + type: ColumnType { + span_range: 1364..1375, + raw: "\"time(2)[]\"", + type_name: Raw( + "time", + ), + args: [ + Integer( + 2, + ), + ], + arrays: [ + None, + ], + }, + settings: None, + }, + TableColumn { + span_range: 1378..1400, + name: Ident { + span_range: 1378..1384, + raw: "\"bar9\"", + to_string: "bar9", + }, + type: ColumnType { + span_range: 1385..1397, + raw: "\"time(1)[1]\"", + type_name: Raw( + "time", + ), + args: [ + Integer( + 1, + ), + ], + arrays: [ + Some( + 1, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1400..1422, + name: Ident { + span_range: 1400..1407, + raw: "\"bar10\"", + to_string: "bar10", + }, + type: ColumnType { + span_range: 1408..1419, + raw: "\"time(1)[]\"", + type_name: Raw( + "time", + ), + args: [ + Integer( + 1, + ), + ], + arrays: [ + None, + ], + }, + settings: None, + }, + TableColumn { + span_range: 1422..1442, + name: Ident { + span_range: 1422..1429, + raw: "\"bar11\"", + to_string: "bar11", + }, + type: ColumnType { + span_range: 1430..1439, + raw: "\"time[5]\"", + type_name: Raw( + "time", + ), + args: [], + arrays: [ + Some( + 5, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1442..1477, + name: Ident { + span_range: 1442..1449, + raw: "\"bar12\"", + to_string: "bar12", + }, + type: ColumnType { + span_range: 1450..1474, + raw: "\"timestamp(2)[10][2][5]\"", + type_name: Raw( + "timestamp", + ), + args: [ + Integer( + 2, + ), + ], + arrays: [ + Some( + 10, + ), + Some( + 2, + ), + Some( + 5, + ), + ], + }, + settings: None, + }, + TableColumn { + span_range: 1477..1509, + name: Ident { + span_range: 1477..1484, + raw: "\"bar13\"", + to_string: "bar13", + }, + type: ColumnType { + span_range: 1485..1506, + raw: "\"character varying[]\"", + type_name: Raw( + "character varying", + ), + args: [], + arrays: [ + None, + ], + }, + settings: None, + }, + TableColumn { + span_range: 1509..1550, + name: Ident { + span_range: 1509..1516, + raw: "\"bar14\"", + to_string: "bar14", + }, + type: ColumnType { + span_range: 1517..1547, + raw: "\"character varying(25)[][2][]\"", + type_name: Raw( + "character varying", + ), + args: [ + Integer( + 25, + ), + ], + arrays: [ + None, + Some( + 2, + ), + None, + ], + }, + settings: None, + }, + TableColumn { + span_range: 1550..1582, + name: Ident { + span_range: 1550..1557, + raw: "\"bar15\"", + to_string: "bar15", + }, + type: ColumnType { + span_range: 1558..1581, + raw: "\"character varying[76]\"", + type_name: Raw( + "character varying", + ), + args: [], + arrays: [ + Some( + 76, + ), + ], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1216..1222, + name: Ident { + span_range: 1216..1221, + raw: "\"foo\"", + to_string: "foo", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1589..1631, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1589..1602, + schema: None, + table: Ident { + span_range: 1589..1597, + raw: "\"orders\"", + to_string: "orders", + }, + compositions: [ + Ident { + span_range: 1598..1602, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1605..1629, + schema: None, + table: Ident { + span_range: 1605..1618, + raw: "\"order_items\"", + to_string: "order_items", + }, + compositions: [ + Ident { + span_range: 1619..1629, + raw: "\"order_id\"", + to_string: "order_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1635..1681, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1635..1650, + schema: None, + table: Ident { + span_range: 1635..1645, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 1646..1650, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1653..1679, + schema: None, + table: Ident { + span_range: 1653..1666, + raw: "\"order_items\"", + to_string: "order_items", + }, + compositions: [ + Ident { + span_range: 1667..1679, + raw: "\"product_id\"", + to_string: "product_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1685..1730, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1685..1703, + schema: None, + table: Ident { + span_range: 1685..1696, + raw: "\"countries\"", + to_string: "countries", + }, + compositions: [ + Ident { + span_range: 1697..1703, + raw: "\"code\"", + to_string: "code", + }, + ], + }, + rhs: RefIdent { + span_range: 1706..1728, + schema: None, + table: Ident { + span_range: 1706..1713, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1714..1728, + raw: "\"country_code\"", + to_string: "country_code", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1734..1783, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1734..1752, + schema: None, + table: Ident { + span_range: 1734..1745, + raw: "\"countries\"", + to_string: "countries", + }, + compositions: [ + Ident { + span_range: 1746..1752, + raw: "\"code\"", + to_string: "code", + }, + ], + }, + rhs: RefIdent { + span_range: 1755..1781, + schema: None, + table: Ident { + span_range: 1755..1766, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 1767..1781, + raw: "\"country_code\"", + to_string: "country_code", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1787..1832, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1787..1803, + schema: None, + table: Ident { + span_range: 1787..1798, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 1799..1803, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1806..1830, + schema: None, + table: Ident { + span_range: 1806..1816, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 1817..1830, + raw: "\"merchant_id\"", + to_string: "merchant_id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 1836..1873, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 1836..1848, + schema: None, + table: Ident { + span_range: 1836..1843, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 1844..1848, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 1851..1873, + schema: None, + table: Ident { + span_range: 1851..1862, + raw: "\"merchants\"", + to_string: "merchants", + }, + compositions: [ + Ident { + span_range: 1863..1873, + raw: "\"admin_id\"", + to_string: "admin_id", + }, + ], + }, + settings: None, + }, + ), + ], +} \ No newline at end of file diff --git a/tests/out/postgres_importer/multiple_schema.out.ron b/tests/out/postgres_importer/multiple_schema.out.ron new file mode 100644 index 0000000..4143c02 --- /dev/null +++ b/tests/out/postgres_importer/multiple_schema.out.ron @@ -0,0 +1,1169 @@ +SchemaBlock { + span_range: 0..1151, + input: "Enum \"job_status\" {\n \"created2\"\n \"running2\"\n \"done2\"\n \"failure2\"\n}\n\nEnum \"gender\" {\n \"male2\"\n \"female2\"\n}\n\nTable \"users\" {\n \"id\" int [pk]\n \"name\" varchar\n \"pjs\" job_status\n \"pjs2\" job_status\n \"pg\" schemaB.gender\n \"pg2\" gender\n \"pg3\" schemaB.\"gender\"\n \"pg4\" \"schemaB\".\"gender\"\n}\n\nTable \"products\" {\n \"id\" int [pk]\n \"name\" varchar [note: 'Product name of public schema']\n\nIndexes {\n id [type: hash, unique]\n}\n}\n\nRef:\"schemaA\".\"locations\".\"id\" < \"schemaA\".\"products\".\"lid\"\n\nRef:\"users\".\"id\" < \"ecommerce\".\"users\".\"id\"\n\nRef:\"users\".\"name\" < \"ecommerce\".\"users\".\"id\"\n\nRef:\"ecommerce\".\"users\".\"id\" < \"schemaA\".\"products\".\"name\"\n\nRef:\"users\".\"id\" < \"schemaA\".\"locations\".\"name\"\n\nEnum \"schemaB\".\"gender\" {\n \"male\"\n \"female\"\n}\n\nTable \"ecommerce\".\"users\" {\n \"id\" int [pk]\n \"name\" varchar\n \"ejs\" job_status\n \"ejs2\" job_status\n \"eg\" schemaB.gender\n \"eg2\" gender\n}\n\nTable \"schemaA\".\"products\" {\n \"id\" int [pk]\n \"name\" varchar [note: 'Product name of schemaA']\n \"lid\" int\n\nIndexes {\n (id, name) [name: \"product_status\"]\n}\n}\n\nTable \"schemaA\".\"locations\" {\n \"id\" int [pk]\n \"name\" varchar\n Note: 'This is a note in table \"locations\"'\n}\n", + blocks: [ + Enum( + EnumBlock { + span_range: 0..70, + ident: EnumIdent { + span_range: 5..18, + schema: None, + name: Ident { + span_range: 5..17, + raw: "\"job_status\"", + to_string: "job_status", + }, + }, + values: [ + EnumValue { + span_range: 22..35, + value: Ident { + span_range: 22..32, + raw: "\"created2\"", + to_string: "created2", + }, + settings: None, + }, + EnumValue { + span_range: 35..48, + value: Ident { + span_range: 35..45, + raw: "\"running2\"", + to_string: "running2", + }, + settings: None, + }, + EnumValue { + span_range: 48..58, + value: Ident { + span_range: 48..55, + raw: "\"done2\"", + to_string: "done2", + }, + settings: None, + }, + EnumValue { + span_range: 58..69, + value: Ident { + span_range: 58..68, + raw: "\"failure2\"", + to_string: "failure2", + }, + settings: None, + }, + ], + }, + ), + Enum( + EnumBlock { + span_range: 72..111, + ident: EnumIdent { + span_range: 77..86, + schema: None, + name: Ident { + span_range: 77..85, + raw: "\"gender\"", + to_string: "gender", + }, + }, + values: [ + EnumValue { + span_range: 90..100, + value: Ident { + span_range: 90..97, + raw: "\"male2\"", + to_string: "male2", + }, + settings: None, + }, + EnumValue { + span_range: 100..110, + value: Ident { + span_range: 100..109, + raw: "\"female2\"", + to_string: "female2", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 113..291, + cols: [ + TableColumn { + span_range: 131..144, + name: Ident { + span_range: 131..135, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 136..139, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 140..144, + attributes: [ + Attribute { + span_range: 141..143, + key: Ident { + span_range: 141..143, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 147..164, + name: Ident { + span_range: 147..153, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 154..161, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 164..183, + name: Ident { + span_range: 164..169, + raw: "\"pjs\"", + to_string: "pjs", + }, + type: ColumnType { + span_range: 170..180, + raw: "job_status", + type_name: Raw( + "job_status", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 183..203, + name: Ident { + span_range: 183..189, + raw: "\"pjs2\"", + to_string: "pjs2", + }, + type: ColumnType { + span_range: 190..200, + raw: "job_status", + type_name: Raw( + "job_status", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 203..225, + name: Ident { + span_range: 203..207, + raw: "\"pg\"", + to_string: "pg", + }, + type: ColumnType { + span_range: 208..222, + raw: "schemaB.gender", + type_name: Raw( + "schemaB.gender", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 225..240, + name: Ident { + span_range: 225..230, + raw: "\"pg2\"", + to_string: "pg2", + }, + type: ColumnType { + span_range: 231..237, + raw: "gender", + type_name: Raw( + "gender", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 240..265, + name: Ident { + span_range: 240..245, + raw: "\"pg3\"", + to_string: "pg3", + }, + type: ColumnType { + span_range: 246..262, + raw: "schemaB.\"gender\"", + type_name: Raw( + "schemaB.gender", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 265..290, + name: Ident { + span_range: 265..270, + raw: "\"pg4\"", + to_string: "pg4", + }, + type: ColumnType { + span_range: 271..289, + raw: "\"schemaB\".\"gender\"", + type_name: Raw( + "schemaB.gender", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 119..127, + name: Ident { + span_range: 119..126, + raw: "\"users\"", + to_string: "users", + }, + schema: None, + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 293..425, + cols: [ + TableColumn { + span_range: 314..327, + name: Ident { + span_range: 314..318, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 319..322, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 323..327, + attributes: [ + Attribute { + span_range: 324..326, + key: Ident { + span_range: 324..326, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 330..384, + name: Ident { + span_range: 330..336, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 337..344, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 345..384, + attributes: [ + Attribute { + span_range: 346..383, + key: Ident { + span_range: 346..350, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 352..383, + raw: "'Product name of public schema'", + value: String( + "Product name of public schema", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "Product name of public schema", + ), + default: None, + refs: [], + }, + ), + }, + ], + ident: TableIdent { + span_range: 299..310, + name: Ident { + span_range: 299..309, + raw: "\"products\"", + to_string: "products", + }, + schema: None, + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 394..423, + defs: [ + IndexesDef { + span_range: 398..421, + cols: [ + String( + Ident { + span_range: 398..400, + raw: "id", + to_string: "id", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 401..421, + attributes: [ + Attribute { + span_range: 402..412, + key: Ident { + span_range: 402..406, + raw: "type", + to_string: "type", + }, + value: Some( + Literal { + span_range: 408..412, + raw: "hash", + value: Enum( + "hash", + ), + }, + ), + }, + Attribute { + span_range: 414..420, + key: Ident { + span_range: 414..420, + raw: "unique", + to_string: "unique", + }, + value: None, + }, + ], + type: Some( + Hash, + ), + is_unique: true, + is_pk: false, + note: None, + name: None, + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 431..488, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 431..457, + schema: Some( + Ident { + span_range: 431..440, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 441..452, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 453..457, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 460..486, + schema: Some( + Ident { + span_range: 460..469, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 470..480, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 481..486, + raw: "\"lid\"", + to_string: "lid", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 492..533, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 492..504, + schema: None, + table: Ident { + span_range: 492..499, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 500..504, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 507..531, + schema: Some( + Ident { + span_range: 507..518, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 519..526, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 527..531, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 537..580, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 537..551, + schema: None, + table: Ident { + span_range: 537..544, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 545..551, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + rhs: RefIdent { + span_range: 554..578, + schema: Some( + Ident { + span_range: 554..565, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 566..573, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 574..578, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 584..640, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 584..608, + schema: Some( + Ident { + span_range: 584..595, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + table: Ident { + span_range: 596..603, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 604..608, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 611..638, + schema: Some( + Ident { + span_range: 611..620, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 621..631, + raw: "\"products\"", + to_string: "products", + }, + compositions: [ + Ident { + span_range: 632..638, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + settings: None, + }, + ), + Ref( + RefBlock { + span_range: 644..689, + name: None, + rel: One2Many, + lhs: RefIdent { + span_range: 644..656, + schema: None, + table: Ident { + span_range: 644..651, + raw: "\"users\"", + to_string: "users", + }, + compositions: [ + Ident { + span_range: 652..656, + raw: "\"id\"", + to_string: "id", + }, + ], + }, + rhs: RefIdent { + span_range: 659..687, + schema: Some( + Ident { + span_range: 659..668, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + table: Ident { + span_range: 669..680, + raw: "\"locations\"", + to_string: "locations", + }, + compositions: [ + Ident { + span_range: 681..687, + raw: "\"name\"", + to_string: "name", + }, + ], + }, + settings: None, + }, + ), + Enum( + EnumBlock { + span_range: 689..736, + ident: EnumIdent { + span_range: 694..712, + schema: Some( + Ident { + span_range: 694..703, + raw: "\"schemaB\"", + to_string: "schemaB", + }, + ), + name: Ident { + span_range: 704..712, + raw: "\"gender\"", + to_string: "gender", + }, + }, + values: [ + EnumValue { + span_range: 717..726, + value: Ident { + span_range: 717..723, + raw: "\"male\"", + to_string: "male", + }, + settings: None, + }, + EnumValue { + span_range: 726..735, + value: Ident { + span_range: 726..734, + raw: "\"female\"", + to_string: "female", + }, + settings: None, + }, + ], + }, + ), + Table( + TableBlock { + span_range: 738..876, + cols: [ + TableColumn { + span_range: 768..781, + name: Ident { + span_range: 768..772, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 773..776, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 777..781, + attributes: [ + Attribute { + span_range: 778..780, + key: Ident { + span_range: 778..780, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 784..801, + name: Ident { + span_range: 784..790, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 791..798, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 801..820, + name: Ident { + span_range: 801..806, + raw: "\"ejs\"", + to_string: "ejs", + }, + type: ColumnType { + span_range: 807..817, + raw: "job_status", + type_name: Raw( + "job_status", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 820..840, + name: Ident { + span_range: 820..826, + raw: "\"ejs2\"", + to_string: "ejs2", + }, + type: ColumnType { + span_range: 827..837, + raw: "job_status", + type_name: Raw( + "job_status", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 840..862, + name: Ident { + span_range: 840..844, + raw: "\"eg\"", + to_string: "eg", + }, + type: ColumnType { + span_range: 845..859, + raw: "schemaB.gender", + type_name: Raw( + "schemaB.gender", + ), + args: [], + arrays: [], + }, + settings: None, + }, + TableColumn { + span_range: 862..875, + name: Ident { + span_range: 862..867, + raw: "\"eg2\"", + to_string: "eg2", + }, + type: ColumnType { + span_range: 868..874, + raw: "gender", + type_name: Raw( + "gender", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 744..763, + name: Ident { + span_range: 756..763, + raw: "\"users\"", + to_string: "users", + }, + schema: Some( + Ident { + span_range: 744..755, + raw: "\"ecommerce\"", + to_string: "ecommerce", + }, + ), + alias: None, + }, + note: None, + indexes: None, + settings: None, + }, + ), + Table( + TableBlock { + span_range: 878..1038, + cols: [ + TableColumn { + span_range: 909..922, + name: Ident { + span_range: 909..913, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 914..917, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 918..922, + attributes: [ + Attribute { + span_range: 919..921, + key: Ident { + span_range: 919..921, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 925..973, + name: Ident { + span_range: 925..931, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 932..939, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 940..973, + attributes: [ + Attribute { + span_range: 941..972, + key: Ident { + span_range: 941..945, + raw: "note", + to_string: "note", + }, + value: Some( + Literal { + span_range: 947..972, + raw: "'Product name of schemaA'", + value: String( + "Product name of schemaA", + ), + }, + ), + }, + ], + is_pk: false, + is_unique: false, + nullable: None, + is_incremental: false, + note: Some( + "Product name of schemaA", + ), + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 976..987, + name: Ident { + span_range: 976..981, + raw: "\"lid\"", + to_string: "lid", + }, + type: ColumnType { + span_range: 982..985, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 884..904, + name: Ident { + span_range: 894..904, + raw: "\"products\"", + to_string: "products", + }, + schema: Some( + Ident { + span_range: 884..893, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + alias: None, + }, + note: None, + indexes: Some( + IndexesBlock { + span_range: 995..1036, + defs: [ + IndexesDef { + span_range: 999..1034, + cols: [ + String( + Ident { + span_range: 1000..1002, + raw: "id", + to_string: "id", + }, + ), + String( + Ident { + span_range: 1004..1008, + raw: "name", + to_string: "name", + }, + ), + ], + settings: Some( + IndexesSettings { + span_range: 1010..1034, + attributes: [ + Attribute { + span_range: 1011..1033, + key: Ident { + span_range: 1011..1015, + raw: "name", + to_string: "name", + }, + value: Some( + Literal { + span_range: 1017..1033, + raw: "\"product_status\"", + value: String( + "product_status", + ), + }, + ), + }, + ], + type: None, + is_unique: false, + is_pk: false, + note: None, + name: Some( + "product_status", + ), + }, + ), + }, + ], + }, + ), + settings: None, + }, + ), + Table( + TableBlock { + span_range: 1040..1150, + cols: [ + TableColumn { + span_range: 1072..1085, + name: Ident { + span_range: 1072..1076, + raw: "\"id\"", + to_string: "id", + }, + type: ColumnType { + span_range: 1077..1080, + raw: "int", + type_name: Raw( + "int", + ), + args: [], + arrays: [], + }, + settings: Some( + ColumnSettings { + span_range: 1081..1085, + attributes: [ + Attribute { + span_range: 1082..1084, + key: Ident { + span_range: 1082..1084, + raw: "pk", + to_string: "pk", + }, + value: None, + }, + ], + is_pk: true, + is_unique: false, + nullable: None, + is_incremental: false, + note: None, + default: None, + refs: [], + }, + ), + }, + TableColumn { + span_range: 1088..1105, + name: Ident { + span_range: 1088..1094, + raw: "\"name\"", + to_string: "name", + }, + type: ColumnType { + span_range: 1095..1102, + raw: "varchar", + type_name: Raw( + "varchar", + ), + args: [], + arrays: [], + }, + settings: None, + }, + ], + ident: TableIdent { + span_range: 1046..1067, + name: Ident { + span_range: 1056..1067, + raw: "\"locations\"", + to_string: "locations", + }, + schema: Some( + Ident { + span_range: 1046..1055, + raw: "\"schemaA\"", + to_string: "schemaA", + }, + ), + alias: None, + }, + note: Some( + NoteBlock { + span_range: 1105..1148, + value: Literal { + span_range: 1111..1148, + raw: "'This is a note in table \"locations\"'", + value: String( + "This is a note in table \"locations\"", + ), + }, + }, + ), + indexes: None, + settings: None, + }, + ), + ], +} \ No newline at end of file diff --git a/tests/out/project.in.ron b/tests/out/project.in.ron index 2db980a..b42ed4a 100644 --- a/tests/out/project.in.ron +++ b/tests/out/project.in.ron @@ -140,8 +140,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 322..326, - raw: "int ", + span_range: 322..325, + raw: "int", type_name: Raw( "int", ), @@ -189,8 +189,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 354..358, - raw: "int ", + span_range: 354..357, + raw: "int", type_name: Raw( "int", ), @@ -240,8 +240,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 388..404, - raw: "orders_status\n ", + span_range: 388..401, + raw: "orders_status", type_name: Raw( "orders_status", ), @@ -258,8 +258,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 417..425, - raw: "varchar\n", + span_range: 417..424, + raw: "varchar", type_name: Raw( "varchar", ), @@ -319,8 +319,8 @@ SchemaBlock { to_string: "order_id", }, type: ColumnType { - span_range: 463..469, - raw: "int\n ", + span_range: 463..466, + raw: "int", type_name: Raw( "int", ), @@ -337,8 +337,8 @@ SchemaBlock { to_string: "product_id", }, type: ColumnType { - span_range: 482..488, - raw: "int\n ", + span_range: 482..485, + raw: "int", type_name: Raw( "int", ), @@ -355,8 +355,8 @@ SchemaBlock { to_string: "quantity", }, type: ColumnType { - span_range: 499..503, - raw: "int ", + span_range: 499..502, + raw: "int", type_name: Raw( "int", ), @@ -427,8 +427,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 545..549, - raw: "int ", + span_range: 545..548, + raw: "int", type_name: Raw( "int", ), @@ -467,8 +467,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 563..573, - raw: "varchar\n ", + span_range: 563..570, + raw: "varchar", type_name: Raw( "varchar", ), @@ -485,8 +485,8 @@ SchemaBlock { to_string: "merchant_id", }, type: ColumnType { - span_range: 587..591, - raw: "int ", + span_range: 587..590, + raw: "int", type_name: Raw( "int", ), @@ -527,8 +527,8 @@ SchemaBlock { to_string: "price", }, type: ColumnType { - span_range: 612..618, - raw: "int\n ", + span_range: 612..615, + raw: "int", type_name: Raw( "int", ), @@ -563,8 +563,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 659..668, - raw: "datetime ", + span_range: 659..667, + raw: "datetime", type_name: Raw( "datetime", ), @@ -743,8 +743,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 810..814, - raw: "int ", + span_range: 810..813, + raw: "int", type_name: Raw( "int", ), @@ -783,8 +783,8 @@ SchemaBlock { to_string: "full_name", }, type: ColumnType { - span_range: 833..843, - raw: "varchar\n ", + span_range: 833..840, + raw: "varchar", type_name: Raw( "varchar", ), @@ -801,8 +801,8 @@ SchemaBlock { to_string: "email", }, type: ColumnType { - span_range: 851..859, - raw: "varchar ", + span_range: 851..858, + raw: "varchar", type_name: Raw( "varchar", ), @@ -841,8 +841,8 @@ SchemaBlock { to_string: "gender", }, type: ColumnType { - span_range: 879..889, - raw: "varchar\n ", + span_range: 879..886, + raw: "varchar", type_name: Raw( "varchar", ), @@ -859,8 +859,8 @@ SchemaBlock { to_string: "date_of_birth", }, type: ColumnType { - span_range: 905..915, - raw: "varchar\n ", + span_range: 905..912, + raw: "varchar", type_name: Raw( "varchar", ), @@ -877,8 +877,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 928..938, - raw: "varchar\n ", + span_range: 928..935, + raw: "varchar", type_name: Raw( "varchar", ), @@ -895,8 +895,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 953..957, - raw: "int\n", + span_range: 953..956, + raw: "int", type_name: Raw( "int", ), @@ -997,8 +997,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 1066..1070, - raw: "int ", + span_range: 1066..1069, + raw: "int", type_name: Raw( "int", ), @@ -1037,8 +1037,8 @@ SchemaBlock { to_string: "merchant_name", }, type: ColumnType { - span_range: 1093..1103, - raw: "varchar\n ", + span_range: 1093..1100, + raw: "varchar", type_name: Raw( "varchar", ), @@ -1055,8 +1055,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 1118..1124, - raw: "int\n ", + span_range: 1118..1121, + raw: "int", type_name: Raw( "int", ), @@ -1073,8 +1073,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 1137..1147, - raw: "varchar\n ", + span_range: 1137..1144, + raw: "varchar", type_name: Raw( "varchar", ), @@ -1091,8 +1091,8 @@ SchemaBlock { to_string: "admin_id", }, type: ColumnType { - span_range: 1158..1162, - raw: "int\n", + span_range: 1158..1161, + raw: "int", type_name: Raw( "int", ), @@ -1129,8 +1129,8 @@ SchemaBlock { to_string: "code", }, type: ColumnType { - span_range: 1194..1198, - raw: "int ", + span_range: 1194..1197, + raw: "int", type_name: Raw( "int", ), @@ -1169,8 +1169,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 1212..1222, - raw: "varchar\n ", + span_range: 1212..1219, + raw: "varchar", type_name: Raw( "varchar", ), @@ -1187,8 +1187,8 @@ SchemaBlock { to_string: "continent_name", }, type: ColumnType { - span_range: 1239..1247, - raw: "varchar\n", + span_range: 1239..1246, + raw: "varchar", type_name: Raw( "varchar", ), diff --git a/tests/out/referential_actions.in.ron b/tests/out/referential_actions.in.ron index 792696c..73af6e6 100644 --- a/tests/out/referential_actions.in.ron +++ b/tests/out/referential_actions.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 24..28, - raw: "int ", + span_range: 24..27, + raw: "int", type_name: Raw( "int", ), @@ -63,8 +63,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 56..60, - raw: "int ", + span_range: 56..59, + raw: "int", type_name: Raw( "int", ), @@ -114,8 +114,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 90..111, - raw: "orders_status_enum\n ", + span_range: 90..108, + raw: "orders_status_enum", type_name: Raw( "orders_status_enum", ), @@ -174,8 +174,8 @@ SchemaBlock { to_string: "order_id", }, type: ColumnType { - span_range: 175..181, - raw: "int\n ", + span_range: 175..178, + raw: "int", type_name: Raw( "int", ), @@ -192,8 +192,8 @@ SchemaBlock { to_string: "product_id", }, type: ColumnType { - span_range: 194..200, - raw: "int\n ", + span_range: 194..197, + raw: "int", type_name: Raw( "int", ), @@ -232,8 +232,8 @@ SchemaBlock { to_string: "quantity", }, type: ColumnType { - span_range: 241..245, - raw: "int ", + span_range: 241..244, + raw: "int", type_name: Raw( "int", ), @@ -304,8 +304,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 287..293, - raw: "int\n ", + span_range: 287..290, + raw: "int", type_name: Raw( "int", ), @@ -369,8 +369,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 352..361, - raw: "datetime ", + span_range: 352..360, + raw: "datetime", type_name: Raw( "datetime", ), @@ -487,8 +487,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 437..441, - raw: "int ", + span_range: 437..440, + raw: "int", type_name: Raw( "int", ), @@ -602,8 +602,8 @@ SchemaBlock { to_string: "date_of_birth", }, type: ColumnType { - span_range: 529..540, - raw: "datetime\n ", + span_range: 529..537, + raw: "datetime", type_name: Raw( "datetime", ), @@ -620,8 +620,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 553..562, - raw: "datetime ", + span_range: 553..561, + raw: "datetime", type_name: Raw( "datetime", ), @@ -672,8 +672,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 598..602, - raw: "int ", + span_range: 598..601, + raw: "int", type_name: Raw( "int", ), @@ -734,8 +734,8 @@ SchemaBlock { to_string: "code", }, type: ColumnType { - span_range: 645..649, - raw: "int ", + span_range: 645..648, + raw: "int", type_name: Raw( "int", ), diff --git a/tests/out/sample_1.ron b/tests/out/sample_1.ron index 939d27d..46bdcaa 100644 --- a/tests/out/sample_1.ron +++ b/tests/out/sample_1.ron @@ -113,8 +113,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 236..244, - raw: "integer ", + span_range: 236..243, + raw: "integer", type_name: Raw( "integer", ), @@ -153,8 +153,8 @@ SchemaBlock { to_string: "age", }, type: ColumnType { - span_range: 255..263, - raw: "integer ", + span_range: 255..262, + raw: "integer", type_name: Raw( "integer", ), @@ -225,8 +225,8 @@ SchemaBlock { to_string: "role", }, type: ColumnType { - span_range: 317..327, - raw: "varchar\n ", + span_range: 317..324, + raw: "varchar", type_name: Raw( "varchar", ), @@ -243,8 +243,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 338..350, - raw: "timestamp\n ", + span_range: 338..347, + raw: "timestamp", type_name: Raw( "timestamp", ), @@ -261,8 +261,8 @@ SchemaBlock { to_string: "referral_id", }, type: ColumnType { - span_range: 362..370, - raw: "integer ", + span_range: 362..369, + raw: "integer", type_name: Raw( "integer", ), @@ -350,8 +350,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 421..429, - raw: "integer ", + span_range: 421..428, + raw: "integer", type_name: Raw( "integer", ), @@ -390,8 +390,8 @@ SchemaBlock { to_string: "title", }, type: ColumnType { - span_range: 442..452, - raw: "varchar\n ", + span_range: 442..449, + raw: "varchar", type_name: Raw( "varchar", ), @@ -408,8 +408,8 @@ SchemaBlock { to_string: "body", }, type: ColumnType { - span_range: 457..462, - raw: "text ", + span_range: 457..461, + raw: "text", type_name: Raw( "text", ), @@ -458,8 +458,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 502..510, - raw: "integer ", + span_range: 502..509, + raw: "integer", type_name: Raw( "integer", ), @@ -509,8 +509,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 537..549, - raw: "post_status ", + span_range: 537..548, + raw: "post_status", type_name: Raw( "post_status", ), @@ -561,8 +561,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 579..589, - raw: "timestamp\n", + span_range: 579..588, + raw: "timestamp", type_name: Raw( "timestamp", ), @@ -605,8 +605,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 612..620, - raw: "integer ", + span_range: 612..619, + raw: "integer", type_name: Raw( "integer", ), @@ -645,8 +645,8 @@ SchemaBlock { to_string: "status", }, type: ColumnType { - span_range: 634..642, - raw: "varchar ", + span_range: 634..641, + raw: "varchar", type_name: Raw( "varchar", ), diff --git a/tests/out/sea_orm_codegen.ron b/tests/out/sea_orm_codegen.ron index aff2d4c..43415e2 100644 --- a/tests/out/sea_orm_codegen.ron +++ b/tests/out/sea_orm_codegen.ron @@ -43,8 +43,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 77..81, - raw: "int ", + span_range: 77..80, + raw: "int", type_name: Raw( "int", ), @@ -92,8 +92,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 104..109, - raw: "text ", + span_range: 104..108, + raw: "text", type_name: Raw( "text", ), @@ -154,8 +154,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 139..143, - raw: "int ", + span_range: 139..142, + raw: "int", type_name: Raw( "int", ), @@ -203,8 +203,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 166..176, - raw: "varchar\n ", + span_range: 166..173, + raw: "varchar", type_name: Raw( "varchar", ), @@ -221,8 +221,8 @@ SchemaBlock { to_string: "fruit_id", }, type: ColumnType { - span_range: 185..190, - raw: "text ", + span_range: 185..189, + raw: "text", type_name: Raw( "text", ), @@ -304,8 +304,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 236..240, - raw: "int ", + span_range: 236..239, + raw: "int", type_name: Raw( "int", ), @@ -353,8 +353,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 263..273, - raw: "varchar\n ", + span_range: 263..270, + raw: "varchar", type_name: Raw( "varchar", ), @@ -371,8 +371,8 @@ SchemaBlock { to_string: "cake_id", }, type: ColumnType { - span_range: 281..285, - raw: "int ", + span_range: 281..284, + raw: "int", type_name: Raw( "int", ), @@ -454,8 +454,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 332..336, - raw: "int ", + span_range: 332..335, + raw: "int", type_name: Raw( "int", ), @@ -503,8 +503,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 359..367, - raw: "varchar\n", + span_range: 359..366, + raw: "varchar", type_name: Raw( "varchar", ), @@ -541,8 +541,8 @@ SchemaBlock { to_string: "cake_id", }, type: ColumnType { - span_range: 401..407, - raw: "int\n ", + span_range: 401..404, + raw: "int", type_name: Raw( "int", ), @@ -559,8 +559,8 @@ SchemaBlock { to_string: "filling_id", }, type: ColumnType { - span_range: 418..425, - raw: "int\n\n ", + span_range: 418..421, + raw: "int", type_name: Raw( "int", ), diff --git a/tests/out/table_element.in.ron b/tests/out/table_element.in.ron index aef2b8c..f5b42f9 100644 --- a/tests/out/table_element.in.ron +++ b/tests/out/table_element.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 52..56, - raw: "int ", + span_range: 52..55, + raw: "int", type_name: Raw( "int", ), @@ -54,8 +54,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 68..76, - raw: "varchar ", + span_range: 68..75, + raw: "varchar", type_name: Raw( "varchar", ), @@ -94,8 +94,8 @@ SchemaBlock { to_string: "gender", }, type: ColumnType { - span_range: 90..100, - raw: "varchar\n ", + span_range: 90..97, + raw: "varchar", type_name: Raw( "varchar", ), @@ -112,8 +112,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 111..123, - raw: "datetime\n\n ", + span_range: 111..119, + raw: "datetime", type_name: Raw( "datetime", ), diff --git a/tests/out/table_group.in.ron b/tests/out/table_group.in.ron index 8f11d3d..4f51f7c 100644 --- a/tests/out/table_group.in.ron +++ b/tests/out/table_group.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 24..29, - raw: "int\n\t", + span_range: 24..27, + raw: "int", type_name: Raw( "int", ), @@ -32,8 +32,8 @@ SchemaBlock { to_string: "full_name", }, type: ColumnType { - span_range: 39..49, - raw: "varchar\n ", + span_range: 39..46, + raw: "varchar", type_name: Raw( "varchar", ), @@ -50,8 +50,8 @@ SchemaBlock { to_string: "created_at", }, type: ColumnType { - span_range: 60..72, - raw: "timestamp\n ", + span_range: 60..69, + raw: "timestamp", type_name: Raw( "timestamp", ), @@ -68,8 +68,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 85..89, - raw: "int\n", + span_range: 85..88, + raw: "int", type_name: Raw( "int", ), @@ -112,8 +112,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 115..122, - raw: "int \n ", + span_range: 115..118, + raw: "int", type_name: Raw( "int", ), @@ -130,8 +130,8 @@ SchemaBlock { to_string: "merchant_name", }, type: ColumnType { - span_range: 136..145, - raw: "varchar\n\t", + span_range: 136..143, + raw: "varchar", type_name: Raw( "varchar", ), @@ -148,8 +148,8 @@ SchemaBlock { to_string: "country_code", }, type: ColumnType { - span_range: 158..164, - raw: "int\n ", + span_range: 158..161, + raw: "int", type_name: Raw( "int", ), @@ -166,8 +166,8 @@ SchemaBlock { to_string: "created at", }, type: ColumnType { - span_range: 177..187, - raw: "varchar\n ", + span_range: 177..184, + raw: "varchar", type_name: Raw( "varchar", ), @@ -184,8 +184,8 @@ SchemaBlock { to_string: "admin_id", }, type: ColumnType { - span_range: 196..200, - raw: "int ", + span_range: 196..199, + raw: "int", type_name: Raw( "int", ), diff --git a/tests/out/table_settings.in.ron b/tests/out/table_settings.in.ron index 089c557..cf50ab0 100644 --- a/tests/out/table_settings.in.ron +++ b/tests/out/table_settings.in.ron @@ -14,8 +14,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 42..46, - raw: "int ", + span_range: 42..45, + raw: "int", type_name: Raw( "int", ), @@ -54,8 +54,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 60..67, - raw: "string\n", + span_range: 60..66, + raw: "string", type_name: Raw( "string", ), @@ -115,8 +115,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 122..126, - raw: "int ", + span_range: 122..125, + raw: "int", type_name: Raw( "int", ), @@ -155,8 +155,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 140..147, - raw: "string ", + span_range: 140..146, + raw: "string", type_name: Raw( "string", ), @@ -240,8 +240,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 242..246, - raw: "int ", + span_range: 242..245, + raw: "int", type_name: Raw( "int", ), @@ -280,8 +280,8 @@ SchemaBlock { to_string: "name", }, type: ColumnType { - span_range: 260..269, - raw: "string\n ", + span_range: 260..266, + raw: "string", type_name: Raw( "string", ), @@ -298,8 +298,8 @@ SchemaBlock { to_string: "price", }, type: ColumnType { - span_range: 277..285, - raw: "decimal ", + span_range: 277..284, + raw: "decimal", type_name: Raw( "decimal", ), @@ -400,8 +400,8 @@ SchemaBlock { to_string: "id", }, type: ColumnType { - span_range: 378..382, - raw: "int ", + span_range: 378..381, + raw: "int", type_name: Raw( "int", ), @@ -440,8 +440,8 @@ SchemaBlock { to_string: "user_id", }, type: ColumnType { - span_range: 399..405, - raw: "int\n ", + span_range: 399..402, + raw: "int", type_name: Raw( "int", ), @@ -458,8 +458,8 @@ SchemaBlock { to_string: "product_id", }, type: ColumnType { - span_range: 418..424, - raw: "int\n ", + span_range: 418..421, + raw: "int", type_name: Raw( "int", ), @@ -476,8 +476,8 @@ SchemaBlock { to_string: "address", }, type: ColumnType { - span_range: 434..441, - raw: "string\n", + span_range: 434..440, + raw: "string", type_name: Raw( "string", ),