Giter Site home page Giter Site logo

Support for insert many? about sqlhydra HOT 7 CLOSED

jordanmarr avatar jordanmarr commented on July 21, 2024
Support for insert many?

from sqlhydra.

Comments (7)

MargaretKrutikova avatar MargaretKrutikova commented on July 21, 2024 1

Was able to test it recently, everything works as expected. Thanks a lot for your help!
This project looks like a fantastic solution to the eternal problem of having your database in sync with the code and avoiding tons of boilerplate, more robust and stable than data providers ❤️

from sqlhydra.

JordanMarr avatar JordanMarr commented on July 21, 2024

If this is a feature of SqlKata then it definitely could (and should) be added to SqlHydra!
Perhaps an entities operation could be added to the insert builder.

from sqlhydra.

MargaretKrutikova avatar MargaretKrutikova commented on July 21, 2024

There is this overload of AsInsert:

public Query AsInsert(
      IEnumerable<string> columns,
      IEnumerable<IEnumerable<object>> rowsValues)

that I think can be used for insert-many. Would be also nice to not have to pass a list of columns but automatically infer them as it is currently done for a single entity.

from sqlhydra.

JordanMarr avatar JordanMarr commented on July 21, 2024

That overload doesn't take returnId as in input. Hopefully the current overload that takes KeyValuePair seq will work for multiple columns.

Does SqlKata allow returning multiple ids for multiple inserts?

from sqlhydra.

MargaretKrutikova avatar MargaretKrutikova commented on July 21, 2024

I am not sure, I was looking at this example.
And the execution of insert many, which doesn't seem to return anything at all.

from sqlhydra.

JordanMarr avatar JordanMarr commented on July 21, 2024

Ahh ok, I bet it does not support automatically returning identity fields for multiple inserts, which seems reasonable. That is probably why the overload for multiple inserts doesn't allow for the returnId field.

SqlHydra could probably support this, but for v1 of this feature, I think it would be best to throw the following exception:
"getId is not currently supported for multiple inserts via the entities operation."

from sqlhydra.

JordanMarr avatar JordanMarr commented on July 21, 2024

v0.530.0 has been published with multiple inserts via entities operation.
Note that you since getId is not supported for multiple inserts, you will need to replace it with excludeColumn.

from sqlhydra.

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.