Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
94 stars 13 forks source link

Column name quoting #102

Closed jayvdb closed 1 year ago

jayvdb commented 1 year ago

I have a field called when, and I am getting what looks like a column name quoting bug

thread '...' panicked at 'called `Result::unwrap()` on an `Err` value: SQLite(SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("near \"when\": syntax error")))', rust/models/tests/common/mod.rs:20:34
jayvdb commented 1 year ago

Easy to demonstrate with

diff --git a/butane/tests/basic.rs b/butane/tests/basic.rs
index 816c58d..e69abe6 100644
--- a/butane/tests/basic.rs
+++ b/butane/tests/basic.rs
@@ -102,7 +102,7 @@ struct TimeHolder {
     pub id: i32,
     pub naive: NaiveDateTime,
     pub utc: DateTime<Utc>,
-    pub utc2: chrono::DateTime<Utc>,
+    pub when: chrono::DateTime<Utc>,
 }

 fn basic_crud(conn: Connection) {
@@ -343,7 +343,7 @@ fn basic_time(conn: Connection) {
         id: 1,
         naive: now.naive_utc(),
         utc: now,
-        utc2: now,
+        when: now,
         state: ObjectState::default(),
     };
     time.save(&conn).unwrap();

Looking into the fix now.