Coder Social home page Coder Social logo

Comments (8)

koskimas avatar koskimas commented on July 29, 2024 2

Those are not our limitations but MySQL's. Feel free to take this up to MySQL.

from kysely.

heethjain21 avatar heethjain21 commented on July 29, 2024 2

Those are not our limitations but MySQL's. Feel free to take this up to MySQL.

Not sure if I understand the workings under the hood, but I do get a insertId when using mysql2, so maybe not a MySQL limitation

This is the response from mysql2:

    { rows: [], insertId: '0', rowsAffected: 1 }

And in Kysley, I get this:

InsertResult { insertId: undefined, numInsertedOrUpdatedRows: 1n } 

The docs mention this:

This property can be undefined when the query contains an on conflict clause that makes the query succeed even when nothing gets inserted.

In my case, there is

  • no conflict
  • the primary key has an auto increment param

So maybe not an issue with MySQL, something else

from kysely.

Dan1ve avatar Dan1ve commented on July 29, 2024 1

Closed, likely a duplicate to #316 :

InsertId is irrelevant and may not be available when the table's primary key is not an auto increment column.

Also, the docs state:

This property can be undefined when the query contains an on conflict

Still a little bummer that the original query has to be split up into two, but oh well...

from kysely.

JorgeJimenez15 avatar JorgeJimenez15 commented on July 29, 2024

@heethjain21, Did you managed to find a workaround?

from kysely.

heethjain21 avatar heethjain21 commented on July 29, 2024

@heethjain21, Did you managed to find a workaround?

No. I was thinking of creating a PR to fix this, but haven't gotten time yet.

@koskimas could you please point me in the direction where I should be looking to fix this problem? Referring to this comment: #1049 (comment)

I'll start once I manage to get some time.

from kysely.

koskimas avatar koskimas commented on July 29, 2024

We have tests. This works. Provide a reproduction.

from kysely.

heethjain21 avatar heethjain21 commented on July 29, 2024

Strange, it worked this time.

Not sure what the issue was last time.

I wanted to adopt Kysely in our project, but didn't do it because of this error.

I tried a little more times, and it worked all of the time.

Don't remember what might have caused the issue last time.

Thanks for your comment anyways, since I was able to get it working now, so I can use it in my project then!

from kysely.

tsulatsitamim avatar tsulatsitamim commented on July 29, 2024

Using retuning with query builder return undefined.

Screenshot 2024-07-24 at 10 04 51
Screenshot 2024-07-24 at 10 04 39

my workaround is using raw sql
const { rows: [row] } = await sql`INSERT INTO Transaction (accountId, amount, date, description, type) VALUES (${data.toAccountId}, ${data.amount}, ${data.date}, 'TRANSFER', 'DEBIT') RETURNING id`.execute(trx)

from kysely.

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.