You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to express a specific update pattern in SeqQL, but there is no way to do so in the query builder.
As far as I can tell from parusing the source code, the only time the special excluded table can be generated as part of a query is in the assignment.
The equivalent query I want to build is as so:
INSERT INTO kv (key, value)
VALUES ('hi', 'blah')
ON CONFLICT (key) DO UPDATESET value =excluded.value,
version = version +1WHEREexcluded.value<> value
however I am unable to generate the excluded.value method within the WHERE clause here. The closest I can get is
let query = Kv::insert(model).on_conflict(OnConflict::column(kv::Column::Key).update_column(kv::Column::Value).value(kv::Column::Version,Expr::col(kv::Column::Version).add(1)).action_and_where(Expr::col(kv::Column::Value).not_equals(kv::Column::Value)).to_owned(),).into_query().to_string(SqliteQueryBuilder);
which evaluates to
INSERT INTO"kv" ("key", "value")
VALUES ('hi', 'blah')
ON CONFLICT ("key") DO UPDATESET"value"="excluded"."value",
"version"="version"+1WHERE"value"<>"value"
Slight update: I got there in the end, but this really doesn't feel "ideal" - this was more me brute force trying things.
let query = Kv::insert(model).on_conflict(OnConflict::column(kv::Column::Key).update_column(kv::Column::Value).value(kv::Column::Version,Expr::col(kv::Column::Version).add(1)).action_and_where(Expr::col(kv::Column::Value).ne(SimpleExpr::CustomWithExpr(r#""excluded".?"#.to_string(),vec![SimpleExpr::Column(kv::Column::Value.into_column_ref())],))).to_owned(),).into_query().to_string(SqliteQueryBuilder);
Description
I want to express a specific update pattern in SeqQL, but there is no way to do so in the query builder.
As far as I can tell from parusing the source code, the only time the special
excluded
table can be generated as part of a query is in the assignment.The equivalent query I want to build is as so:
however I am unable to generate the
excluded.value
method within theWHERE
clause here. The closest I can get iswhich evaluates to
Schema
SQL
Entity
Versions
OS: Linux
Arch: AMD64
Database: SQLite,
libsqlite3-sys: 0.30.1
Bundled SQLite version: 3.46.0
Bundled SQLite source ID:
2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e
sea-orm: 1.1.1
sea-orm-macros: 1.1.1
sea-bae: 0.2.1
sea-query: 0.32.0
sea-orm-migration: 1.1.1
sea-orm-cli: 1.1.1
sea-schema: 0.16.0
sea-schema-derive: 0.3.0
The text was updated successfully, but these errors were encountered: