From d01959fa1fd4ec8f458900b9f2ab18a33867dee6 Mon Sep 17 00:00:00 2001 From: Mara Schulke Date: Sat, 25 Nov 2023 14:09:33 +0100 Subject: [PATCH] Fix clippy issues --- Cargo.toml | 6 +- README.md | 22 ++------ atmosphere-core/src/bind.rs | 8 ++- atmosphere-core/src/runtime/sql.rs | 50 ++++++++--------- atmosphere-core/src/schema/create.rs | 2 +- atmosphere-core/src/schema/delete.rs | 2 +- atmosphere-core/src/schema/mod.rs | 32 +++++------ atmosphere-core/src/schema/read.rs | 2 +- atmosphere-core/src/schema/update.rs | 4 +- atmosphere-core/src/testing.rs | 12 ++-- atmosphere-macros/src/derive/bindings.rs | 6 +- atmosphere-macros/src/derive/hooks.rs | 1 - .../src/derive/queries/unique.rs | 4 +- atmosphere-macros/src/derive/relationships.rs | 2 +- atmosphere-macros/src/schema/column.rs | 55 ++++++++----------- atmosphere-macros/src/schema/table.rs | 6 +- examples/forest/main.rs | 31 ----------- 17 files changed, 96 insertions(+), 149 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4d0ddbb..78e58a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] [workspace.package] -version = "0.0.2" +version = "0.1.0" license = "Apache-2.0" edition = "2021" authors = ["Mara Schulke "] @@ -15,8 +15,8 @@ repository = "https://github.com/hemisphere-studio/atmosphere" keywords = ["sqlx", "postgres", "database", "orm", "backend"] [workspace.dependencies] -atmosphere-core = { version = "=0.0.2", path = "atmosphere-core" } -atmosphere-macros = { version = "=0.0.2", path = "atmosphere-macros" } +atmosphere-core = { version = "=0.1.0", path = "atmosphere-core" } +atmosphere-macros = { version = "=0.1.0", path = "atmosphere-macros" } async-trait = "0.1" lazy_static = "1" sqlx = { version = "0.7", features = ["chrono"] } diff --git a/README.md b/README.md index b015618..3a4ccb5 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,11 @@ async fn main() -> sqlx::Result<()> { user.save(&pool).await?; user.delete(&pool).await?; + user.create(&pool).await?; // Field Queries - assert!( + assert_eq!( User::find(&0, &pool).await?, User::find_by_email("some@email.com", &pool).await? ); @@ -96,20 +97,7 @@ async fn main() -> sqlx::Result<()> { Atmosphere introspects the `User` and `Post` structs at compile time and generates `const` available type information about the schema into the `Table` -trait: - -```rust -impl Table for User { - const SCHEMA: &str = "public" - const TABLE: &str = "user" - const PRIMARY_KEY: Column = Column { name: "id", ty: PrimaryKey, .. }; - const FOREIGN_KEYS: &'static [Column; 0] = &[]; - const DATA: &'static [Column; 2] = &[ - Column { name: "name", ty: Value, .. }, - Column { name: "email", ty: Value, .. } - ]; -} -``` +trait. ## Roadmap @@ -136,14 +124,14 @@ impl Table for User { - [ ] Stabilize Traits - [ ] Stabilize Query Generation - [ ] Table Lenses (subsets / views) +- [ ] `validator` support +- [ ] Auto Timestamping ### Advanced - [ ] Virtual Columns using (`#[virtual = ""]`) - [ ] Soft Delete Support - [ ] Attribute Macro (`#[query]`) - [ ] Custom queries -- [ ] Auto Timestamping -- [ ] `validator` support ### Longterm - [ ] Generate GraphQL + HTTP Servers? diff --git a/atmosphere-core/src/bind.rs b/atmosphere-core/src/bind.rs index 48177a2..85af664 100644 --- a/atmosphere-core/src/bind.rs +++ b/atmosphere-core/src/bind.rs @@ -84,8 +84,12 @@ impl<'q> Bindable<'q> for QueryBuilder<'q, crate::Driver> { } } -/// Bind columns to SQL Queries +/// Trait for binding columns to SQL queries in the context of a specific table. +/// +/// This trait should be implemented by table entities to enable the binding of their columns to +/// SQL queries. It provides a method to bind a single column, ensuring that the query correctly +/// reflects the structure and constraints of the table. pub trait Bind: Table { - /// Bind a single column to the query + /// Binds a single column of the implementing table entity to a given query. fn bind<'q, Q: Bindable<'q>>(&'q self, c: &'q Column, query: Q) -> Result; } diff --git a/atmosphere-core/src/runtime/sql.rs b/atmosphere-core/src/runtime/sql.rs index 740bbf9..7ce1d27 100644 --- a/atmosphere-core/src/runtime/sql.rs +++ b/atmosphere-core/src/runtime/sql.rs @@ -100,15 +100,15 @@ pub fn select_by(c: Column) -> Query { separated.push(T::PRIMARY_KEY.sql); - for ref fk in T::FOREIGN_KEYS { + for fk in T::FOREIGN_KEYS { separated.push(fk.sql); } - for ref data in T::DATA_COLUMNS { + for data in T::DATA_COLUMNS { separated.push(data.sql); } - for ref meta in T::TIMESTAMP_COLUMNS { + for meta in T::TIMESTAMP_COLUMNS { separated.push(meta.sql); } @@ -133,15 +133,15 @@ pub fn select_all() -> Query { separated.push(T::PRIMARY_KEY.sql); - for ref fk in T::FOREIGN_KEYS { + for fk in T::FOREIGN_KEYS { separated.push(fk.sql); } - for ref data in T::DATA_COLUMNS { + for data in T::DATA_COLUMNS { separated.push(data.sql); } - for ref meta in T::TIMESTAMP_COLUMNS { + for meta in T::TIMESTAMP_COLUMNS { separated.push(meta.sql); } @@ -175,12 +175,12 @@ pub fn insert() -> Query { for data in T::DATA_COLUMNS { separated.push(data.sql.to_string()); - bindings.push(Column::DataColumn(data)); + bindings.push(Column::Data(data)); } for meta in T::TIMESTAMP_COLUMNS { separated.push(meta.sql.to_string()); - bindings.push(Column::TimestampColumn(meta)); + bindings.push(Column::Timestamp(meta)); } separated.push_unseparated(")\nVALUES\n ("); @@ -217,21 +217,21 @@ pub fn update() -> Query { let mut col = 2; - for ref fk in T::FOREIGN_KEYS { + for fk in T::FOREIGN_KEYS { separated.push(format!("{} = ${col}", fk.sql)); bindings.push(Column::ForeignKey(fk)); col += 1; } - for ref data in T::DATA_COLUMNS { + for data in T::DATA_COLUMNS { separated.push(format!("{} = ${col}", data.sql)); - bindings.push(Column::DataColumn(data)); + bindings.push(Column::Data(data)); col += 1; } - for ref meta in T::TIMESTAMP_COLUMNS { + for meta in T::TIMESTAMP_COLUMNS { separated.push(format!("{} = ${col}", meta.sql)); - bindings.push(Column::TimestampColumn(meta)); + bindings.push(Column::Timestamp(meta)); col += 1; } @@ -261,15 +261,15 @@ pub fn upsert() -> Query { let mut separated = builder.separated(",\n "); - for ref fk in T::FOREIGN_KEYS { + for fk in T::FOREIGN_KEYS { separated.push(format!("{} = EXCLUDED.{}", fk.sql, fk.sql)); } - for ref data in T::DATA_COLUMNS { + for data in T::DATA_COLUMNS { separated.push(format!("{} = EXCLUDED.{}", data.sql, data.sql)); } - for ref meta in T::TIMESTAMP_COLUMNS { + for meta in T::TIMESTAMP_COLUMNS { separated.push(format!("{} = EXCLUDED.{}", meta.sql, meta.sql)); } @@ -340,15 +340,9 @@ mod tests { impl Bind for TestTable { fn bind<'q, Q: Bindable<'q>>(&'q self, c: &'q Column, query: Q) -> crate::Result { match c.field() { - "id" => { - return Ok(query.dyn_bind(&self.id)); - } - "fk" => { - return Ok(query.dyn_bind(&self.fk)); - } - "data" => { - return Ok(query.dyn_bind(&self.data)); - } + "id" => Ok(query.dyn_bind(self.id)), + "fk" => Ok(query.dyn_bind(self.fk)), + "data" => Ok(query.dyn_bind(self.data)), _ => unimplemented!(), } } @@ -387,7 +381,7 @@ mod tests { Bindings(vec![ Column::PrimaryKey(&TestTable::PRIMARY_KEY), Column::ForeignKey(&TestTable::FOREIGN_KEYS[0]), - Column::DataColumn(&TestTable::DATA_COLUMNS[0]), + Column::Data(&TestTable::DATA_COLUMNS[0]), ]) ); } @@ -408,7 +402,7 @@ mod tests { Bindings(vec![ Column::PrimaryKey(&TestTable::PRIMARY_KEY), Column::ForeignKey(&TestTable::FOREIGN_KEYS[0]), - Column::DataColumn(&TestTable::DATA_COLUMNS[0]), + Column::Data(&TestTable::DATA_COLUMNS[0]), ]) ); } @@ -429,7 +423,7 @@ mod tests { Bindings(vec![ Column::PrimaryKey(&TestTable::PRIMARY_KEY), Column::ForeignKey(&TestTable::FOREIGN_KEYS[0]), - Column::DataColumn(&TestTable::DATA_COLUMNS[0]), + Column::Data(&TestTable::DATA_COLUMNS[0]), ]) ); } diff --git a/atmosphere-core/src/schema/create.rs b/atmosphere-core/src/schema/create.rs index 4f7859f..56311dc 100644 --- a/atmosphere-core/src/schema/create.rs +++ b/atmosphere-core/src/schema/create.rs @@ -45,7 +45,7 @@ where { let query = crate::runtime::sql::insert::(); - hooks::execute(HookStage::PreBind, &query, HookInput::Row(&mut self)).await?; + hooks::execute(HookStage::PreBind, &query, HookInput::Row(self)).await?; let mut builder = sqlx::query(query.sql()); diff --git a/atmosphere-core/src/schema/delete.rs b/atmosphere-core/src/schema/delete.rs index 38e1c72..9d15a7c 100644 --- a/atmosphere-core/src/schema/delete.rs +++ b/atmosphere-core/src/schema/delete.rs @@ -59,7 +59,7 @@ where hooks::execute( hooks::HookStage::PreBind, &query, - hooks::HookInput::Row(&mut self), + hooks::HookInput::Row(self), ) .await?; diff --git a/atmosphere-core/src/schema/mod.rs b/atmosphere-core/src/schema/mod.rs index 4fb9e06..794fc0f 100644 --- a/atmosphere-core/src/schema/mod.rs +++ b/atmosphere-core/src/schema/mod.rs @@ -78,9 +78,9 @@ pub mod column { /// A foreign key ForeignKey(&'static ForeignKey), /// A data column - DataColumn(&'static DataColumn), + Data(&'static DataColumn), /// A timestamp column - TimestampColumn(&'static TimestampColumn), + Timestamp(&'static TimestampColumn), } impl Clone for Column { @@ -88,8 +88,8 @@ pub mod column { match self { Self::PrimaryKey(pk) => Self::PrimaryKey(*pk), Self::ForeignKey(fk) => Self::ForeignKey(*fk), - Self::DataColumn(data) => Self::DataColumn(*data), - Self::TimestampColumn(ts) => Self::TimestampColumn(*ts), + Self::Data(data) => Self::Data(*data), + Self::Timestamp(ts) => Self::Timestamp(*ts), } } } @@ -99,8 +99,8 @@ pub mod column { match self { Self::PrimaryKey(pk) => pk.field, Self::ForeignKey(fk) => fk.field, - Self::DataColumn(data) => data.field, - Self::TimestampColumn(ts) => ts.field, + Self::Data(data) => data.field, + Self::Timestamp(ts) => ts.field, } } @@ -108,8 +108,8 @@ pub mod column { match self { Self::PrimaryKey(pk) => pk.sql, Self::ForeignKey(fk) => fk.sql, - Self::DataColumn(data) => data.sql, - Self::TimestampColumn(ts) => ts.sql, + Self::Data(data) => data.sql, + Self::Timestamp(ts) => ts.sql, } } } @@ -169,14 +169,14 @@ pub mod column { Column::ForeignKey(self) } + /// # Safety + // + /// We do treat this foreign key as a column of another table. This is not + /// smart to do - but can become necessary when doing complex joins. This + /// is memory safe as Self and Self have the exact same memory layout, + /// we do not store any data (A or B) but only a `PhantomData` instance which + /// is here transmuted. pub const unsafe fn transmute(&'static self) -> &'static ForeignKey { - // SAFETY: - // - // We do treat this foreign key as a column of another table. This is not - // smart to do - but can become necessary when doing complex joins. This - // is memory safe as Self and Self have the exact same memory layout, - // we do not store any data (A or B) but only a `PhantomData` instance which - // is here transmuted. std::mem::transmute(self) } } @@ -211,7 +211,7 @@ pub mod column { } pub const fn as_col(&'static self) -> Column { - Column::DataColumn(self) + Column::Data(self) } } diff --git a/atmosphere-core/src/schema/read.rs b/atmosphere-core/src/schema/read.rs index a371136..5b7385d 100644 --- a/atmosphere-core/src/schema/read.rs +++ b/atmosphere-core/src/schema/read.rs @@ -102,7 +102,7 @@ where { let query = crate::runtime::sql::select_by::(T::PRIMARY_KEY.as_col()); - hooks::execute(HookStage::PreBind, &query, HookInput::Row(&mut self)).await?; + hooks::execute(HookStage::PreBind, &query, HookInput::Row(self)).await?; let mut sql = sqlx::query_as(query.sql()); diff --git a/atmosphere-core/src/schema/update.rs b/atmosphere-core/src/schema/update.rs index 776c925..236eaf4 100644 --- a/atmosphere-core/src/schema/update.rs +++ b/atmosphere-core/src/schema/update.rs @@ -56,7 +56,7 @@ where { let query = crate::runtime::sql::update::(); - hooks::execute(HookStage::PreBind, &query, HookInput::Row(&mut self)).await?; + hooks::execute(HookStage::PreBind, &query, HookInput::Row(self)).await?; let mut sql = sqlx::query(query.sql()); @@ -91,7 +91,7 @@ where { let query = crate::runtime::sql::upsert::(); - hooks::execute(HookStage::PreBind, &query, HookInput::Row(&mut self)).await?; + hooks::execute(HookStage::PreBind, &query, HookInput::Row(self)).await?; let mut sql = sqlx::query(query.sql()); diff --git a/atmosphere-core/src/testing.rs b/atmosphere-core/src/testing.rs index 89c12bd..345e8d9 100644 --- a/atmosphere-core/src/testing.rs +++ b/atmosphere-core/src/testing.rs @@ -16,13 +16,13 @@ where E: Entity + Clone + Debug + Eq + Send, { assert!( - E::find(&instance.pk(), pool).await.unwrap().is_none(), + E::find(instance.pk(), pool).await.unwrap().is_none(), "instance was found before it was created" ); instance.create(pool).await.expect("insertion did not work"); - let retrieved = E::find(&instance.pk(), pool) + let retrieved = E::find(instance.pk(), pool) .await .unwrap() .expect("instance not found after insertion"); @@ -40,13 +40,13 @@ where E: Entity + Clone + Debug + Eq + Send, { assert!( - E::find(&instance.pk(), pool).await.unwrap().is_none(), + E::find(instance.pk(), pool).await.unwrap().is_none(), "instance was found after deletion" ); instance.create(pool).await.expect("insertion did not work"); - let retrieved = E::find(&instance.pk(), pool) + let retrieved = E::find(instance.pk(), pool) .await .unwrap() .expect("instance not found after insertion"); @@ -77,7 +77,7 @@ where assert_eq!(instance, update); - let retrieved = E::find(&instance.pk(), pool) + let retrieved = E::find(instance.pk(), pool) .await .unwrap() .expect("instance not found after update"); @@ -104,7 +104,7 @@ where .expect_err("instance could be reloaded from db after deletion"); assert!( - E::find(&instance.pk(), pool).await.unwrap().is_none(), + E::find(instance.pk(), pool).await.unwrap().is_none(), "instance was found after deletion" ); diff --git a/atmosphere-macros/src/derive/bindings.rs b/atmosphere-macros/src/derive/bindings.rs index 9772474..d8d951a 100644 --- a/atmosphere-macros/src/derive/bindings.rs +++ b/atmosphere-macros/src/derive/bindings.rs @@ -21,7 +21,7 @@ pub fn bindings(table: &Table) -> TokenStream { )); } - for ref fk in &table.foreign_keys { + for fk in &table.foreign_keys { let field = fk.name.field(); binds.extend(quote!( @@ -32,7 +32,7 @@ pub fn bindings(table: &Table) -> TokenStream { )); } - for ref data in &table.data_columns { + for data in &table.data_columns { let field = data.name.field(); binds.extend(quote!( @@ -43,7 +43,7 @@ pub fn bindings(table: &Table) -> TokenStream { )); } - for ref ts in &table.timestamp_columns { + for ts in &table.timestamp_columns { let field = ts.name.field(); binds.extend(quote!( diff --git a/atmosphere-macros/src/derive/hooks.rs b/atmosphere-macros/src/derive/hooks.rs index e809f46..74e3a14 100644 --- a/atmosphere-macros/src/derive/hooks.rs +++ b/atmosphere-macros/src/derive/hooks.rs @@ -54,5 +54,4 @@ pub fn hooks(table: &Table) -> TokenStream { ]; } ) - .into() } diff --git a/atmosphere-macros/src/derive/queries/unique.rs b/atmosphere-macros/src/derive/queries/unique.rs index 1361b45..e9326ae 100644 --- a/atmosphere-macros/src/derive/queries/unique.rs +++ b/atmosphere-macros/src/derive/queries/unique.rs @@ -14,7 +14,7 @@ pub fn queries(table: &Table) -> TokenStream { .iter() .filter(|fk| fk.modifiers.unique) .cloned() - .map(|fk| Column::ForeignKey(fk)) + .map(Column::ForeignKey) .collect(); let data: Vec = table @@ -22,7 +22,7 @@ pub fn queries(table: &Table) -> TokenStream { .iter() .filter(|data| data.modifiers.unique) .cloned() - .map(|data| Column::DataColumn(data)) + .map(Column::Data) .collect(); for column in fks.iter().chain(data.iter()) { diff --git a/atmosphere-macros/src/derive/relationships.rs b/atmosphere-macros/src/derive/relationships.rs index b463304..d71cab3 100644 --- a/atmosphere-macros/src/derive/relationships.rs +++ b/atmosphere-macros/src/derive/relationships.rs @@ -20,7 +20,7 @@ pub fn relationships(table: &Table) -> TokenStream { ); let find_other = Ident::new( - &format!("{}", fk.name.field().to_string().to_lowercase()), + &fk.name.field().to_string().to_lowercase().to_string(), Span::mixed_site(), ); diff --git a/atmosphere-macros/src/schema/column.rs b/atmosphere-macros/src/schema/column.rs index 5a28dff..1c4f875 100644 --- a/atmosphere-macros/src/schema/column.rs +++ b/atmosphere-macros/src/schema/column.rs @@ -95,8 +95,8 @@ impl DataColumn { pub enum Column { PrimaryKey(PrimaryKey), ForeignKey(ForeignKey), - DataColumn(DataColumn), - TimestampColumn(TimestampColumn), + Data(DataColumn), + Timestamp(TimestampColumn), } impl Hash for Column { @@ -110,8 +110,8 @@ impl Column { match self { Self::PrimaryKey(pk) => pk.quote(), Self::ForeignKey(fk) => fk.quote(), - Self::DataColumn(data) => data.quote(), - Self::TimestampColumn(time) => time.quote(), + Self::Data(data) => data.quote(), + Self::Timestamp(time) => time.quote(), } } @@ -119,8 +119,8 @@ impl Column { match self { Self::PrimaryKey(pk) => &pk.ty, Self::ForeignKey(fk) => &fk.ty, - Self::DataColumn(data) => &data.ty, - Self::TimestampColumn(ts) => &ts.ty, + Self::Data(data) => &data.ty, + Self::Timestamp(ts) => &ts.ty, } } } @@ -194,10 +194,8 @@ pub mod attribute { _ => {} }; - if kind != ColumnKind::Data { - if input.peek(Token![,]) { - input.parse::()?; - } + if kind != ColumnKind::Data && input.peek(Token![,]) { + input.parse::()?; } } @@ -224,7 +222,7 @@ pub mod attribute { // we found a tag if ident.to_string().as_str() == UNIQUE { - if modifiers.unique == true { + if modifiers.unique { return Err(Error::new( ident.span(), "found redundant `unique` modifier", @@ -284,7 +282,7 @@ impl TryFrom for Column { .find(|a| a.path().is_ident(attribute::PATH)); let Some(attribute) = attribute else { - return Ok(Self::DataColumn(DataColumn { + return Ok(Self::Data(DataColumn { modifiers: ColumnModifiers { unique: false }, name: NameSet::new(name, None), ty, @@ -296,12 +294,9 @@ impl TryFrom for Column { let modifiers = attribute.modifiers; let name = NameSet::new(name, attribute.renamed); - return match attribute.kind { + match attribute.kind { attribute::ColumnKind::PrimaryKey => Ok(Self::PrimaryKey(PrimaryKey { - modifiers: ColumnModifiers { - unique: true, - ..modifiers - }, + modifiers: ColumnModifiers { unique: true }, name, ty, })), @@ -311,20 +306,18 @@ impl TryFrom for Column { name, ty, })), - attribute::ColumnKind::Data => Ok(Self::DataColumn(DataColumn { + attribute::ColumnKind::Data => Ok(Self::Data(DataColumn { modifiers, name, ty, })), - attribute::ColumnKind::Timestamp { kind } => { - Ok(Self::TimestampColumn(TimestampColumn { - modifiers, - kind, - name, - ty, - })) - } - }; + attribute::ColumnKind::Timestamp { kind } => Ok(Self::Timestamp(TimestampColumn { + modifiers, + kind, + name, + ty, + })), + } } } @@ -333,8 +326,8 @@ impl Column { match self { Self::PrimaryKey(pk) => &pk.name, Self::ForeignKey(fk) => &fk.name, - Self::DataColumn(data) => &data.name, - Self::TimestampColumn(ts) => &ts.name, + Self::Data(data) => &data.name, + Self::Timestamp(ts) => &ts.name, } } } @@ -357,14 +350,14 @@ impl Column { pub const fn as_data_column(&self) -> Option<&DataColumn> { match self { - Self::DataColumn(c) => Some(c), + Self::Data(c) => Some(c), _ => None, } } pub const fn as_timestamp_column(&self) -> Option<&TimestampColumn> { match self { - Self::TimestampColumn(c) => Some(c), + Self::Timestamp(c) => Some(c), _ => None, } } diff --git a/atmosphere-macros/src/schema/table.rs b/atmosphere-macros/src/schema/table.rs index d9a09e9..da224f3 100644 --- a/atmosphere-macros/src/schema/table.rs +++ b/atmosphere-macros/src/schema/table.rs @@ -102,7 +102,7 @@ impl Parse for Table { ident.span(), format!( "{} must use named fields in order to derive `Schema`", - ident.to_string() + ident ), )) } @@ -126,7 +126,7 @@ impl Parse for Table { input.span(), format!( "{} declares more than one column as its primary key – only one is allowed", - ident.to_string() + ident ), )); } @@ -135,7 +135,7 @@ impl Parse for Table { input.span(), format!( "{} must declare one field as its primary key (using `#[primary_key]`", - ident.to_string() + ident ), ))? }; diff --git a/examples/forest/main.rs b/examples/forest/main.rs index 6fa656f..aa3ede4 100644 --- a/examples/forest/main.rs +++ b/examples/forest/main.rs @@ -1,13 +1,10 @@ -use atmosphere::hooks::*; use atmosphere::prelude::*; -use atmosphere::query::Query; use sqlx::types::chrono; use sqlx::types::chrono::Utc; #[derive(Schema, Debug, PartialEq, Eq, PartialOrd, Ord, Clone)] #[table(schema = "public", name = "forest")] -#[hooks(Created)] struct Forest { #[sql(pk)] id: i32, @@ -15,38 +12,10 @@ struct Forest { name: String, #[sql(unique)] location: String, - #[sql(timestamp = created)] created: chrono::DateTime, } -//struct Created; - -//#[async_trait::async_trait] -//impl Hook for Created { -//fn stage(&self) -> HookStage { -//HookStage::PreBind -//} - -//async fn apply(&self, ctx: &Query, input: &mut HookInput<'_, Forest>) -> Result<()> { -//dbg!(&ctx.op); - -//if ctx.op != ::atmosphere::query::Operation::Insert { -//return Ok(()); -//} - -//let HookInput::Row(ref mut row) = input else { -//return Ok(()); -//}; - -//dbg!(&row); - -//row.created = Utc::now(); - -//Ok(()) -//} -//} - #[derive(Schema, Debug, PartialEq, Eq, PartialOrd, Ord, Clone)] #[table(schema = "public", name = "tree")] struct Tree {