Query("error returned from database: syntax error at or near \"WHERE\"")
Description
Steps to Reproduce
i try to update a model by this code
let result = item // Model
.into_active_model()
.update(&conn)
.await
.unwrap();
Expected Behavior
update success
Actual Behavior
2022-08-08T17:50:27.805394Z DEBUG linkplane::handler::tun: 53: session_item.mtu=65425
thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: Query("error returned from database: syntax error at or near "WHERE"")', src/handler/tun.rs:58:10.
Versions
➜ linkplane git:(master) ✗ cargo tree | grep sea- │ └── sea-orm v0.9.1 │ ├── sea-orm-macros v0.9.1 (proc-macro) │ ├── sea-query v0.26.2 │ │ ├── sea-query-derive v0.2.0 (proc-macro) │ │ ├── sea-query-driver v0.2.0 (proc-macro) │ ├── sea-strum v0.23.0 │ │ └── sea-strum_macros v0.23.0 (proc-macro) │ └── sea-orm-migration v0.9.1 │ ├── sea-orm v0.9.1 () │ ├── sea-orm-cli v0.9.1 │ │ ├── sea-schema v0.9.3 │ │ │ ├── sea-query v0.26.2 () │ │ │ └── sea-schema-derive v0.1.0 (proc-macro) │ ├── sea-schema v0.9.3 () ├── sea-orm v0.9.1 ()
Hey @kulame, welcome! I guess you need to first convert Model into ActiveModel. Then, change the value of the field you wish to update on the ActiveModel. Finally, execute the update query.
- https://www.sea-ql.org/SeaORM/docs/basic-crud/update/
- https://www.sea-ql.org/sea-orm-tutorial/ch01-05-basic-crud-operations.html#insert-and-update