Giter Site home page Giter Site logo

Comments (4)

JordanMarr avatar JordanMarr commented on July 21, 2024 1

I have added some description to the insert builder docs that should help to clarify this for others.
Thank you for your feedback. 😊

from sqlhydra.

JordanMarr avatar JordanMarr commented on July 21, 2024

You have two options when using identity/sequence columns -- you must use either getId or excludeColumn in your insert; otherwise, id will be included in the insert columns.

  1. If you want to return the next id sequence, use getId.
use ctx = openContext dbConnection
let! nextId = 
    insert {
        for e in myTable do
        entity { id = 0; name = "Test" }
        getId e.id
    }
    |> ctx.InsertAsync
  1. If you don't want to auto query and return the next id sequence, then you must ignore it with excludeColumn:
use ctx = openContext dbConnection
let! _ =
    insert {
        for e in myTable do
        entity myRecord
        excludeColumn e.id
    }
    |> ctx.InsertAsync

from sqlhydra.

MargaretKrutikova avatar MargaretKrutikova commented on July 21, 2024

Great, getId worked! Would you be able to update the readme so that it says that it is required to use getId or otherwise it won't work? It doesn't seem to be mandatory if you just follow the docs 😄
Thanks a lot for your help!

from sqlhydra.

MargaretKrutikova avatar MargaretKrutikova commented on July 21, 2024

Thank you for the lightning speed responses! ❤️

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.