Giter Club home page Giter Club logo

Comments (2)

csummers avatar csummers commented on July 24, 2024

Yes, I'm looking at how to reliably and consistently do this across different databases and different library backends. From a library perspective, it seems to hinge on whether or not .getGeneratedKeys is supported. clojure.java.jdbc does support this. I think clojure.jdbc support is currently commented out in the code.

I'm looking at supporting the single record created and multiple records created for a forthcoming multi-insert functionality.

Also, if you are using a database that supports the RETURNING syntax for INSERTS (like Postgresql), you can support this directly in your SQL statement.

from hugsql.

csummers avatar csummers commented on July 24, 2024

As of 0.4.0, we have commands :insert, or :i! for short, that have behavior similar to Yesql's <! suffix. Specifically, the underlying adapter and libraries must support the JDBC call to .getGeneratedKeys. The return value of this is quite varied across libraries. See Insert for some samples from the test suite.

Implementation note: Since the support for this varies so much, I decided not to change the HugSQLAdapter protocol by adding an insert function. Instead, I now pass the :command and :result along to the adapter in the options and allow the execute function to conditionally change behavior if it encounters a command type that will change which underlying function it should call. You can see an example of this in the adapter code for clojure.java.jdbc.

from hugsql.

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.