Comments (13)
Hello. How would you perform this with raw SQL?
from sqlite_orm.
insert into user_messages
values ('test','test', 1, 999, 4)
on conflict (user_id, guild_id)
do update set
message_counter = message_counter + 1,
word_counter = word_counter + 999,
attachment_counter = attachment_counter + 4;
from sqlite_orm.
message_counter = message_counter + 1
in SQL is translated to C++ as
assign(&UserMessages::word_counter, add(&UserMessages::word_counter, 1))
or
c(&UserMessages::word_counter) = c(&UserMessages::word_counter) + 1
from sqlite_orm.
I tried a second variant yesterday and thought I was using the wrong syntax.
Today I tried both variants.
But I still have an error..
Can u please see the repo and give me an advice?
from sqlite_orm.
@m1s1da you can debug easily if you print query
value. What it contains?
from sqlite_orm.
"INSERT INTO \"user_messages\"
(\"user_id\", \"guild_id\", \"message_counter\", \"word_counter\", \"attachment_counter\")
VALUES (?, ?, ?, ?, ?)
ON CONFLICT (\"user_messages\".\"user_id\") (\"user_messages\".\"guild_id\")
DO UPDATE SET
\"message_counter\" = \"user_messages\".\"message_counter\" + ?,
\"word_counter\" = \"user_messages\".\"word_counter\" + ?,
\"attachment_counter\" = \"user_messages\".\"attachment_counter\" + ?"
from sqlite_orm.
@m1s1da what error do you get?
from sqlite_orm.
terminate called after throwing an instance of 'std::system_error'
what(): near "(": syntax error: SQL logic error
Signal: SIGABRT (Aborted)
in
[[noreturn]] inline void throw_translated_sqlite_error(sqlite3* db) {
throw sqlite_to_system_error(db);
}
from sqlite_orm.
looks like a serialization bug in sqlite_orm
on this line
ON CONFLICT (\"user_messages\".\"user_id\") (\"user_messages\".\"guild_id\")
. According to SQLite docs it has to be
ON CONFLICT (\"user_messages\".\"user_id\", \"user_messages\".\"guild_id\")
![Снимок экрана 2023-07-25 в 13 40 50](https://private-user-images.githubusercontent.com/6009640/255826663-78859881-d861-47f6-8893-410c5d59ac96.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTUyODM3MzIsIm5iZiI6MTcxNTI4MzQzMiwicGF0aCI6Ii82MDA5NjQwLzI1NTgyNjY2My03ODg1OTg4MS1kODYxLTQ3ZjYtODg5My00MTBjNWQ1OWFjOTYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDUwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA1MDlUMTkzNzEyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Nzk0NjgzNDhkYjE0YzBmNzZlNzQyZTUyMmJhNzQxYWVjNjJkMjY4MGUxNTk1ZDMxZjE3MTAzYjNhM2NkNTJmOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Wa-tAvSdwpLs8nzOpELaDoVM6WnwCT4i7Z5by2JGu5Y)
from sqlite_orm.
I attached my repo w/ link to request string.
And I commented all other libs and code in this branch.
Hope this can be helpful.
from sqlite_orm.
@m1s1da try to replace on_conflict(&UserMessages::user_id, &UserMessages::guild_id)
with on_conflict(columns(&UserMessages::user_id, &UserMessages::guild_id))
. Your case have to contain columns
call cause this is how it is designed to work https://github.com/fnc12/sqlite_orm/blob/master/tests/statement_serializer_tests/ast/upsert_clause.cpp#L94
from sqlite_orm.
@m1s1da did it work?
from sqlite_orm.
closing due to inactivity. Feel free to reopen in case
from sqlite_orm.
Related Issues (20)
- 怎样定义 make_storage 返回模板类型 的 c++类成员变量 HOT 1
- "no such table" error on existing database HOT 1
- Delete a foreign key HOT 5
- sqlite-orm fails to compile under uwp HOT 6
- C:\src\sqlite_orm\tests\schema\virtual_table.cpp(6): exception: no such module: FTS5: SQL logic error HOT 2
- I need to store a vector of vector<std::string> as a field in a persistent class, how can I do this? HOT 8
- add column sync_schema will recreate table HOT 12
- compile error with gcc 5.3.1 HOT 6
- Windows linker error SQLite3 HOT 3
- Warning on CMake >= 3.27 because of support for CMake >= 2.8.12
- Cannot Build my project HOT 2
- `SQLITE_DQS` Compile Option HOT 7
- Failed to compile origin/dev branch using GCC 8.3 HOT 2
- Do not understand select statement generation HOT 3
- Support for returning objects inside columns HOT 8
- Corrupted Databases HOT 10
- API has changed a bit : what is c<Type>? HOT 1
- why is this WITH not recursive? HOT 2
- FTS5 Options: Unindexed columns, prefix indexes, tokenizers & content HOT 29
- sync_schema_simulate when used with triggers HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlite_orm.