Optimize and refactor schema::Column type

This commit is contained in:
PThorpe92
2025-11-02 20:46:02 -05:00
parent 72edc6d758
commit 481d86f567
31 changed files with 900 additions and 982 deletions

View File

@@ -2272,42 +2272,28 @@ mod tests {
root_page: 2,
primary_key_columns: vec![("id".to_string(), turso_parser::ast::SortOrder::Asc)],
columns: vec![
SchemaColumn {
name: Some("id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: true,
is_rowid_alias: true,
notnull: true,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("name".to_string()),
ty: Type::Text,
ty_str: "TEXT".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("age".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new(
Some("id".to_string()),
"INTEGER".to_string(),
None,
Type::Integer,
None,
true,
true,
true,
false,
false,
),
SchemaColumn::new_default_text(
Some("name".to_string()),
"TEXT".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("age".to_string()),
"INTEGER".to_string(),
None,
),
],
has_rowid: true,
is_strict: false,
@@ -2328,42 +2314,28 @@ mod tests {
turso_parser::ast::SortOrder::Asc,
)],
columns: vec![
SchemaColumn {
name: Some("product_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: true,
is_rowid_alias: true,
notnull: true,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("product_name".to_string()),
ty: Type::Text,
ty_str: "TEXT".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("price".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new(
Some("product_id".to_string()),
"INTEGER".to_string(),
None,
Type::Integer,
None,
true,
true,
true,
false,
false,
),
SchemaColumn::new_default_text(
Some("product_name".to_string()),
"TEXT".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("price".to_string()),
"INTEGER".to_string(),
None,
),
],
has_rowid: true,
is_strict: false,
@@ -2384,54 +2356,33 @@ mod tests {
turso_parser::ast::SortOrder::Asc,
)],
columns: vec![
SchemaColumn {
name: Some("order_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: true,
is_rowid_alias: true,
notnull: true,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("user_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("product_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("quantity".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new(
Some("order_id".to_string()),
"INTEGER".to_string(),
None,
Type::Integer,
None,
true,
true,
true,
false,
false,
),
SchemaColumn::new_default_integer(
Some("user_id".to_string()),
"INTEGER".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("product_id".to_string()),
"INTEGER".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("quantity".to_string()),
"INTEGER".to_string(),
None,
),
],
has_rowid: true,
has_autoincrement: false,
@@ -2449,30 +2400,23 @@ mod tests {
root_page: 6,
primary_key_columns: vec![("id".to_string(), turso_parser::ast::SortOrder::Asc)],
columns: vec![
SchemaColumn {
name: Some("id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: true,
is_rowid_alias: true,
notnull: true,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("name".to_string()),
ty: Type::Text,
ty_str: "TEXT".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new(
Some("id".to_string()),
"INTEGER".to_string(),
None,
Type::Integer,
None,
true,
true,
true,
false,
false,
),
SchemaColumn::new_default_text(
Some("name".to_string()),
"TEXT".to_string(),
None,
),
],
has_rowid: true,
is_strict: false,
@@ -2490,54 +2434,33 @@ mod tests {
root_page: 7,
primary_key_columns: vec![("id".to_string(), turso_parser::ast::SortOrder::Asc)],
columns: vec![
SchemaColumn {
name: Some("id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: true,
is_rowid_alias: true,
notnull: true,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("customer_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("vendor_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("quantity".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new(
Some("id".to_string()),
"INTEGER".to_string(),
None,
Type::Integer,
None,
true,
true,
true,
false,
false,
),
SchemaColumn::new_default_integer(
Some("customer_id".to_string()),
"INTEGER".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("vendor_id".to_string()),
"INTEGER".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("quantity".to_string()),
"INTEGER".to_string(),
None,
),
],
has_rowid: true,
is_strict: false,
@@ -2555,42 +2478,28 @@ mod tests {
root_page: 8,
primary_key_columns: vec![("id".to_string(), turso_parser::ast::SortOrder::Asc)],
columns: vec![
SchemaColumn {
name: Some("id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: true,
is_rowid_alias: true,
notnull: true,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("name".to_string()),
ty: Type::Text,
ty_str: "TEXT".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("price".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new(
Some("id".to_string()),
"INTEGER".to_string(),
None,
Type::Integer,
None,
true,
true,
true,
false,
false,
),
SchemaColumn::new_default_text(
Some("name".to_string()),
"TEXT".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("price".to_string()),
"INTEGER".to_string(),
None,
),
],
has_rowid: true,
is_strict: false,
@@ -2607,30 +2516,16 @@ mod tests {
root_page: 2,
primary_key_columns: vec![],
columns: vec![
SchemaColumn {
name: Some("product_id".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn {
name: Some("amount".to_string()),
ty: Type::Integer,
ty_str: "INTEGER".to_string(),
primary_key: false,
is_rowid_alias: false,
notnull: false,
default: None,
unique: false,
collation: None,
hidden: false,
},
SchemaColumn::new_default_integer(
Some("product_id".to_string()),
"INTEGER".to_string(),
None,
),
SchemaColumn::new_default_integer(
Some("amount".to_string()),
"INTEGER".to_string(),
None,
),
],
has_rowid: true,
is_strict: false,