Giter Site home page Giter Site logo

Postgres Incompatibility about knex HOT 4 CLOSED

knex avatar knex commented on July 30, 2024
Postgres Incompatibility

from knex.

Comments (4)

tgriesser avatar tgriesser commented on July 30, 2024

Thanks for the issue... should be fixed on a new release (0.2.3). Let me know if you see any issues.

from knex.

kmalakoff avatar kmalakoff commented on July 30, 2024

That was quick! Thank you...

I don't seem to be getting back the ids anymore in postgres, mysql seems to work....

connection.insert(json).exec (err, res) =>

generates correctly:

insert into "flats" ("created_at", "name", "updated_at") values (?, ?, ?)

but res is [] on postgres and contains an id on mysql. Maybe there was a side effect from some of the changes? I'll comb through your changes and will see if I can spot anything.

from knex.

tgriesser avatar tgriesser commented on July 30, 2024

In postgres, you need to make sure you're passing the second parameter in the insert with the id you wish to return:

connection.insert(json, 'id').exec - this is new as of 0.2.0, because it was causing issues for folks when they didn't have a primary key or the primary key was something other than id. Let me know if that still doesn't fix it.

Also, the id will just be ignored in mysql and sqlite, so you don't need to worry about it breaking anything there.

from knex.

kmalakoff avatar kmalakoff commented on July 30, 2024

Awesome. That worked! Thank you again for being so quick! (and writing such a great library)

from knex.

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.