Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dictionary::GLUE_OBJECTS to serve OBJECT_TYPE, CREATED metadata #924

Merged
merged 15 commits into from
Oct 27, 2022
Merged
Prev Previous commit
Next Next commit
fix: alter should not mutate created
  • Loading branch information
devgony committed Oct 25, 2022
commit 939e4294f64a3ce7911ed261d0397f52d18b86f7
13 changes: 8 additions & 5 deletions storages/sled-storage/src/alter_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use {
async_trait::async_trait,
gluesql_core::{
ast::ColumnDef,
chrono::Utc,
data::{
schema::{ColumnDefExt, Schema},
Row, Value,
Expand Down Expand Up @@ -54,6 +53,7 @@ impl AlterTable for SledStorage {
let Schema {
column_defs,
indexes,
created,
..
} = old_schema
.ok_or_else(|| AlterTableError::TableNotFound(table_name.to_owned()).into())
Expand All @@ -63,7 +63,7 @@ impl AlterTable for SledStorage {
table_name: new_table_name.to_owned(),
column_defs,
indexes,
created: Utc::now().naive_utc(),
created,
};

bincode::serialize(&old_snapshot)
Expand Down Expand Up @@ -160,6 +160,7 @@ impl AlterTable for SledStorage {
let Schema {
column_defs,
indexes,
created,
..
} = snapshot
.get(txid, None)
Expand Down Expand Up @@ -187,7 +188,7 @@ impl AlterTable for SledStorage {
table_name: table_name.to_owned(),
column_defs,
indexes,
created: Utc::now().naive_utc(),
created,
};
let (snapshot, _) = snapshot.update(txid, schema);
let value = bincode::serialize(&snapshot)
Expand Down Expand Up @@ -238,6 +239,7 @@ impl AlterTable for SledStorage {
table_name,
column_defs,
indexes,
created,
..
} = schema_snapshot
.get(txid, None)
Expand Down Expand Up @@ -312,7 +314,7 @@ impl AlterTable for SledStorage {
table_name,
column_defs,
indexes,
created: Utc::now().naive_utc(),
created,
};
let (schema_snapshot, _) = schema_snapshot.update(txid, schema);
let schema_value = bincode::serialize(&schema_snapshot)
Expand Down Expand Up @@ -367,6 +369,7 @@ impl AlterTable for SledStorage {
table_name,
column_defs,
indexes,
created,
..
} = schema_snapshot
.get(txid, None)
Expand Down Expand Up @@ -434,7 +437,7 @@ impl AlterTable for SledStorage {
table_name,
column_defs,
indexes,
created: Utc::now().naive_utc(),
created,
};
let (schema_snapshot, _) = schema_snapshot.update(txid, schema);
let schema_value = bincode::serialize(&schema_snapshot)
Expand Down
6 changes: 4 additions & 2 deletions storages/sled-storage/src/index_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl IndexMut for SledStorage {
let Schema {
column_defs,
indexes,
created,
..
} = schema
.ok_or_else(|| IndexError::ConflictTableNotFound(table_name.to_owned()).into())
Expand All @@ -94,7 +95,7 @@ impl IndexMut for SledStorage {
table_name: table_name.to_owned(),
column_defs,
indexes,
created: Utc::now().naive_utc(),
created,
};

let index_sync = IndexSync::from_schema(tree, txid, &schema);
Expand Down Expand Up @@ -147,6 +148,7 @@ impl IndexMut for SledStorage {
let Schema {
column_defs,
indexes,
created,
..
} = schema
.ok_or_else(|| IndexError::ConflictTableNotFound(table_name.to_owned()).into())
Expand All @@ -168,7 +170,7 @@ impl IndexMut for SledStorage {
table_name: table_name.to_owned(),
column_defs,
indexes,
created: Utc::now().naive_utc(),
created,
};

let index_sync = IndexSync::from_schema(tree, txid, &schema);
Expand Down