Giter Club home page Giter Club logo

Comments (13)

fnc12 avatar fnc12 commented on June 25, 2024

Hello. How would you perform this with raw SQL?

from sqlite_orm.

m1s1da avatar m1s1da commented on June 25, 2024
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.

fnc12 avatar fnc12 commented on June 25, 2024
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.

m1s1da avatar m1s1da commented on June 25, 2024

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..
image
Can u please see the repo and give me an advice?

from sqlite_orm.

fnc12 avatar fnc12 commented on June 25, 2024

@m1s1da you can debug easily if you print query value. What it contains?

from sqlite_orm.

m1s1da avatar m1s1da commented on June 25, 2024
"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.

fnc12 avatar fnc12 commented on June 25, 2024

@m1s1da what error do you get?

from sqlite_orm.

m1s1da avatar m1s1da commented on June 25, 2024
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.

fnc12 avatar fnc12 commented on June 25, 2024

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

from sqlite_orm.

m1s1da avatar m1s1da commented on June 25, 2024

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.

fnc12 avatar fnc12 commented on June 25, 2024

@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.

fnc12 avatar fnc12 commented on June 25, 2024

@m1s1da did it work?

from sqlite_orm.

fnc12 avatar fnc12 commented on June 25, 2024

closing due to inactivity. Feel free to reopen in case

from sqlite_orm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.