go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

Exlude primary key on insert when using postgresql squence/nextval() #164

Closed agoat1 closed 2 years ago

agoat1 commented 2 years ago

Is your feature request related to a problem? Please describe. When I insert with INSERT().MODEL(...) and the primary key uses a sequence in postgresql to se the value automatically with nexval(..) as default value, go-jet still set a value of 0 for the primary key if it was not set in the model.

Describe the solution you'd like Have an way to exclude primary key column from the insert and then read the inserted value that was based on postgresql sequence.

houten11 commented 2 years ago

Did you check wiki? https://github.com/go-jet/jet/wiki/INSERT You can specify which values to insert.

Table.INSERT(Table.AllColumns.Except(Table.SomeColumn)).
    MODEL(model).
    RETURNING(Table.AllColumns)
agoat1 commented 2 years ago

Did you check wiki? https://github.com/go-jet/jet/wiki/INSERT You can specify which values to insert.

Table.INSERT(Table.AllColumns.Except(Table.SomeColumn)).
    MODEL(model).
    RETURNING(Table.AllColumns)

Thanks, I missed that.