enable RETURNING functionality for Create opeartion due to bug fix in GORM (https://github.com/go-gorm/gorm/issues/4891)

This commit is contained in:
Сахнов Глеб Андреевич
2021-12-02 23:13:19 +03:00
parent 2802d80f2e
commit 7fe4fc9efd
4 changed files with 8 additions and 6 deletions

View File

@@ -56,11 +56,7 @@ func (dialector Dialector) Initialize(db *gorm.DB) (err error) {
// https://www.sqlite.org/releaselog/3_35_0.html
if compareVersion(version, "3.35.0") >= 0 {
callbacks.RegisterDefaultCallbacks(db, &callbacks.Config{
// CreateClauses should support RETURNING, but for now there's a bug with foreign key pragma
// RETURNING will be added as soon as bug is fixed
// in case of Primary key, the generated SQLite ID is still accessible though,
// due to LastGeneratedID support golang sql package
CreateClauses: []string{"INSERT", "VALUES", "ON CONFLICT"},
CreateClauses: []string{"INSERT", "VALUES", "ON CONFLICT", "RETURNING"},
UpdateClauses: []string{"UPDATE", "SET", "WHERE", "RETURNING"},
DeleteClauses: []string{"DELETE", "FROM", "WHERE", "RETURNING"},
LastInsertIDReversed: true,