Skip to content

gen: expose table's primary key and/or constraint names for use in im.OnConflict()/im.OnConflictOnConstraint() #315

Open
@edigaryev

Description

@edigaryev

The recent 0.29.0 release made some pretty substantial changes to the generated code's API (and I hope for the good), one of which was the deprecation of Upsert() in favor of Insert() with some mods.

Assuming that one now has to use im.OnConflict() or im.OnConflictOnConstraint() to achieve the same behavior, the table's primary key and/or constraint names needs to be specified explicitly for use in these mods.

Whereas before this was handled automatically by the Upsert(), when passing conflictCols equal to nil:

bob/dialect/sqlite/table.go

Lines 205 to 207 in 09c8491

if len(conflictCols) == 0 {
conflictCols = t.pkCols
}

As a result, one now has to type these constraints by hand, which makes things more error-prone than they were before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions