From 8aca60ab6d826adbdf1e6e672e1ab13f637e21cd Mon Sep 17 00:00:00 2001 From: Pavel Berezhnoy Date: Thu, 8 Feb 2018 18:17:44 +0300 Subject: [PATCH] #19: escape columns names in sql statements --- Makefile | 4 +- queryset/methods/queryset.go | 4 +- queryset/queryset_test.go | 18 +- queryset/test/autogenerated_models.go | 228 +++++++++++++------------- 4 files changed, 127 insertions(+), 127 deletions(-) diff --git a/Makefile b/Makefile index b4c8a67..1559649 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ test_static: --deadline=5m \ ./... -test_unit: +test_unit: test_gen mkdir -p test go test -v ./parser/ ./queryset/ ./queryset/methods/ @@ -25,7 +25,7 @@ test_gen: gen go build $$(dirname $F)/*.go; \ ) -test: test_unit bench test_static test_gen +test: test_unit bench test_static bench: go test -bench=. -benchtime=1s -v -run=^$$ ./queryset/ diff --git a/queryset/methods/queryset.go b/queryset/methods/queryset.go index b3b4665..726bb41 100644 --- a/queryset/methods/queryset.go +++ b/queryset/methods/queryset.go @@ -246,7 +246,7 @@ func NewBinaryFilterMethod(ctx QsFieldContext) BinaryFilterMethod { onFieldMethod: ctx.onFieldMethod(), oneArgMethod: newOneArgMethod(argName, ctx.fieldTypeName()), chainedQuerySetMethod: ctx.chainedQuerySetMethod(), - qsCallGormMethod: newQsCallGormMethod("Where", `"%s %s", %s`, + qsCallGormMethod: newQsCallGormMethod("Where", "\"`%s` %s\", %s", ctx.fieldDBName(), getWhereCondition(ctx.operationName), argName), } } @@ -280,7 +280,7 @@ func newInFilterMethodImpl(ctx QsFieldContext, operationName, sql string) InFilt onFieldMethod: ctx.onFieldMethod(), nArgsMethod: args, chainedQuerySetMethod: ctx.chainedQuerySetMethod(), - qsCallGormMethod: newQsCallGormMethod("Where", `"%s %s (?)", iArgs`, + qsCallGormMethod: newQsCallGormMethod("Where", "\"`%s` %s (?)\", iArgs", ctx.fieldDBName(), sql), } } diff --git a/queryset/queryset_test.go b/queryset/queryset_test.go index a093691..2bb5e85 100644 --- a/queryset/queryset_test.go +++ b/queryset/queryset_test.go @@ -171,7 +171,7 @@ func testUserSelectWithSurnameFilter(t *testing.T, m sqlmock.Sqlmock, db *gorm.D expUsers[0].Surname = &surname req := "SELECT * FROM `users` " + - "WHERE `users`.deleted_at IS NULL AND ((user_surname = ?)) ORDER BY `users`.`id` ASC LIMIT 1" + "WHERE `users`.deleted_at IS NULL AND ((`user_surname` = ?)) ORDER BY `users`.`id` ASC LIMIT 1" m.ExpectQuery(fixedFullRe(req)). WillReturnRows(getRowsForUsers(expUsers)) @@ -191,28 +191,28 @@ type userQueryTestCase struct { func testUserQueryFilters(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { cases := []userQueryTestCase{ { - q: "((name IN (?)))", + q: "((`name` IN (?)))", args: []driver.Value{"a"}, qs: func(qs test.UserQuerySet) test.UserQuerySet { return qs.NameIn("a") }, }, { - q: "((name IN (?,?)))", + q: "((`name` IN (?,?)))", args: []driver.Value{"a", "b"}, qs: func(qs test.UserQuerySet) test.UserQuerySet { return qs.NameIn("a", "b") }, }, { - q: "((name NOT IN (?)))", + q: "((`name` NOT IN (?)))", args: []driver.Value{"a"}, qs: func(qs test.UserQuerySet) test.UserQuerySet { return qs.NameNotIn("a") }, }, { - q: "((name NOT IN (?,?)))", + q: "((`name` NOT IN (?,?)))", args: []driver.Value{"a", "b"}, qs: func(qs test.UserQuerySet) test.UserQuerySet { return qs.NameNotIn("a", "b") @@ -270,7 +270,7 @@ func testUserCreateOneWithSurname(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) func testUserUpdateByEmail(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { u := getUser() - req := "UPDATE `users` SET `name` = ? WHERE `users`.deleted_at IS NULL AND ((email = ?))" + req := "UPDATE `users` SET `name` = ? WHERE `users`.deleted_at IS NULL AND ((`email` = ?))" m.ExpectExec(fixedFullRe(req)). WithArgs(u.Name, u.Email). WillReturnResult(sqlmock.NewResult(0, 1)) @@ -295,7 +295,7 @@ func testUserUpdateFieldsByPK(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { func testUserDeleteByEmail(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { u := getUser() - req := "UPDATE `users` SET deleted_at=? WHERE `users`.deleted_at IS NULL AND ((email = ?))" + req := "UPDATE `users` SET deleted_at=? WHERE `users`.deleted_at IS NULL AND ((`email` = ?))" m.ExpectExec(fixedFullRe(req)). WithArgs(sqlmock.AnyArg(), u.Email). WillReturnResult(sqlmock.NewResult(0, 1)) @@ -319,7 +319,7 @@ func testUserDeleteByPK(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { func testUsersUpdateNum(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { usersNum := 2 users := getTestUsers(usersNum) - req := "UPDATE `users` SET `name` = ? WHERE `users`.deleted_at IS NULL AND ((email IN (?,?)))" + req := "UPDATE `users` SET `name` = ? WHERE `users`.deleted_at IS NULL AND ((`email` IN (?,?)))" m.ExpectExec(fixedFullRe(req)). WithArgs(sqlmock.AnyArg(), users[0].Email, users[1].Email). WillReturnResult(sqlmock.NewResult(0, int64(usersNum))) @@ -335,7 +335,7 @@ func testUsersUpdateNum(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { func testUsersCount(t *testing.T, m sqlmock.Sqlmock, db *gorm.DB) { expCount := 5 - req := "SELECT count(*) FROM `users` WHERE `users`.deleted_at IS NULL AND ((name != ?))" + req := "SELECT count(*) FROM `users` WHERE `users`.deleted_at IS NULL AND ((`name` != ?))" m.ExpectQuery(fixedFullRe(req)).WithArgs(driver.Value("")). WillReturnRows(getRowWithFields([]driver.Value{expCount})) diff --git a/queryset/test/autogenerated_models.go b/queryset/test/autogenerated_models.go index 91f809c..975e3c0 100644 --- a/queryset/test/autogenerated_models.go +++ b/queryset/test/autogenerated_models.go @@ -51,37 +51,37 @@ func (o *Blog) Create(db *gorm.DB) error { // CreatedAtEq is an autogenerated method // nolint: dupl func (qs BlogQuerySet) CreatedAtEq(createdAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("created_at = ?", createdAt)) + return qs.w(qs.db.Where("`created_at` = ?", createdAt)) } // CreatedAtGt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) CreatedAtGt(createdAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("created_at > ?", createdAt)) + return qs.w(qs.db.Where("`created_at` > ?", createdAt)) } // CreatedAtGte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) CreatedAtGte(createdAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("created_at >= ?", createdAt)) + return qs.w(qs.db.Where("`created_at` >= ?", createdAt)) } // CreatedAtLt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) CreatedAtLt(createdAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("created_at < ?", createdAt)) + return qs.w(qs.db.Where("`created_at` < ?", createdAt)) } // CreatedAtLte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) CreatedAtLte(createdAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("created_at <= ?", createdAt)) + return qs.w(qs.db.Where("`created_at` <= ?", createdAt)) } // CreatedAtNe is an autogenerated method // nolint: dupl func (qs BlogQuerySet) CreatedAtNe(createdAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("created_at != ?", createdAt)) + return qs.w(qs.db.Where("`created_at` != ?", createdAt)) } // Delete is an autogenerated method @@ -99,19 +99,19 @@ func (o *Blog) Delete(db *gorm.DB) error { // DeletedAtEq is an autogenerated method // nolint: dupl func (qs BlogQuerySet) DeletedAtEq(deletedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("deleted_at = ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` = ?", deletedAt)) } // DeletedAtGt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) DeletedAtGt(deletedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("deleted_at > ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` > ?", deletedAt)) } // DeletedAtGte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) DeletedAtGte(deletedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("deleted_at >= ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` >= ?", deletedAt)) } // DeletedAtIsNotNull is an autogenerated method @@ -129,19 +129,19 @@ func (qs BlogQuerySet) DeletedAtIsNull() BlogQuerySet { // DeletedAtLt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) DeletedAtLt(deletedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("deleted_at < ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` < ?", deletedAt)) } // DeletedAtLte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) DeletedAtLte(deletedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("deleted_at <= ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` <= ?", deletedAt)) } // DeletedAtNe is an autogenerated method // nolint: dupl func (qs BlogQuerySet) DeletedAtNe(deletedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("deleted_at != ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` != ?", deletedAt)) } // GetUpdater is an autogenerated method @@ -153,19 +153,19 @@ func (qs BlogQuerySet) GetUpdater() BlogUpdater { // IDEq is an autogenerated method // nolint: dupl func (qs BlogQuerySet) IDEq(ID uint) BlogQuerySet { - return qs.w(qs.db.Where("id = ?", ID)) + return qs.w(qs.db.Where("`id` = ?", ID)) } // IDGt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) IDGt(ID uint) BlogQuerySet { - return qs.w(qs.db.Where("id > ?", ID)) + return qs.w(qs.db.Where("`id` > ?", ID)) } // IDGte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) IDGte(ID uint) BlogQuerySet { - return qs.w(qs.db.Where("id >= ?", ID)) + return qs.w(qs.db.Where("`id` >= ?", ID)) } // IDIn is an autogenerated method @@ -175,25 +175,25 @@ func (qs BlogQuerySet) IDIn(ID uint, IDRest ...uint) BlogQuerySet { for _, arg := range IDRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("id IN (?)", iArgs)) + return qs.w(qs.db.Where("`id` IN (?)", iArgs)) } // IDLt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) IDLt(ID uint) BlogQuerySet { - return qs.w(qs.db.Where("id < ?", ID)) + return qs.w(qs.db.Where("`id` < ?", ID)) } // IDLte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) IDLte(ID uint) BlogQuerySet { - return qs.w(qs.db.Where("id <= ?", ID)) + return qs.w(qs.db.Where("`id` <= ?", ID)) } // IDNe is an autogenerated method // nolint: dupl func (qs BlogQuerySet) IDNe(ID uint) BlogQuerySet { - return qs.w(qs.db.Where("id != ?", ID)) + return qs.w(qs.db.Where("`id` != ?", ID)) } // IDNotIn is an autogenerated method @@ -203,7 +203,7 @@ func (qs BlogQuerySet) IDNotIn(ID uint, IDRest ...uint) BlogQuerySet { for _, arg := range IDRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("id NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`id` NOT IN (?)", iArgs)) } // Limit is an autogenerated method @@ -215,7 +215,7 @@ func (qs BlogQuerySet) Limit(limit int) BlogQuerySet { // NameEq is an autogenerated method // nolint: dupl func (qs BlogQuerySet) NameEq(name string) BlogQuerySet { - return qs.w(qs.db.Where("myname = ?", name)) + return qs.w(qs.db.Where("`myname` = ?", name)) } // NameIn is an autogenerated method @@ -225,13 +225,13 @@ func (qs BlogQuerySet) NameIn(name string, nameRest ...string) BlogQuerySet { for _, arg := range nameRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("myname IN (?)", iArgs)) + return qs.w(qs.db.Where("`myname` IN (?)", iArgs)) } // NameNe is an autogenerated method // nolint: dupl func (qs BlogQuerySet) NameNe(name string) BlogQuerySet { - return qs.w(qs.db.Where("myname != ?", name)) + return qs.w(qs.db.Where("`myname` != ?", name)) } // NameNotIn is an autogenerated method @@ -241,7 +241,7 @@ func (qs BlogQuerySet) NameNotIn(name string, nameRest ...string) BlogQuerySet { for _, arg := range nameRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("myname NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`myname` NOT IN (?)", iArgs)) } // One is used to retrieve one result. It returns gorm.ErrRecordNotFound @@ -349,37 +349,37 @@ func (u BlogUpdater) UpdateNum() (int64, error) { // UpdatedAtEq is an autogenerated method // nolint: dupl func (qs BlogQuerySet) UpdatedAtEq(updatedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("updated_at = ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` = ?", updatedAt)) } // UpdatedAtGt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) UpdatedAtGt(updatedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("updated_at > ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` > ?", updatedAt)) } // UpdatedAtGte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) UpdatedAtGte(updatedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("updated_at >= ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` >= ?", updatedAt)) } // UpdatedAtLt is an autogenerated method // nolint: dupl func (qs BlogQuerySet) UpdatedAtLt(updatedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("updated_at < ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` < ?", updatedAt)) } // UpdatedAtLte is an autogenerated method // nolint: dupl func (qs BlogQuerySet) UpdatedAtLte(updatedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("updated_at <= ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` <= ?", updatedAt)) } // UpdatedAtNe is an autogenerated method // nolint: dupl func (qs BlogQuerySet) UpdatedAtNe(updatedAt time.Time) BlogQuerySet { - return qs.w(qs.db.Where("updated_at != ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` != ?", updatedAt)) } // ===== END of query set BlogQuerySet @@ -547,19 +547,19 @@ func (u CheckReservedKeywordsUpdater) SetType(typeValue string) CheckReservedKey // StructEq is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) StructEq(structValue int) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("struct = ?", structValue)) + return qs.w(qs.db.Where("`struct` = ?", structValue)) } // StructGt is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) StructGt(structValue int) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("struct > ?", structValue)) + return qs.w(qs.db.Where("`struct` > ?", structValue)) } // StructGte is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) StructGte(structValue int) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("struct >= ?", structValue)) + return qs.w(qs.db.Where("`struct` >= ?", structValue)) } // StructIn is an autogenerated method @@ -569,25 +569,25 @@ func (qs CheckReservedKeywordsQuerySet) StructIn(structValue int, structValueRes for _, arg := range structValueRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("struct IN (?)", iArgs)) + return qs.w(qs.db.Where("`struct` IN (?)", iArgs)) } // StructLt is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) StructLt(structValue int) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("struct < ?", structValue)) + return qs.w(qs.db.Where("`struct` < ?", structValue)) } // StructLte is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) StructLte(structValue int) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("struct <= ?", structValue)) + return qs.w(qs.db.Where("`struct` <= ?", structValue)) } // StructNe is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) StructNe(structValue int) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("struct != ?", structValue)) + return qs.w(qs.db.Where("`struct` != ?", structValue)) } // StructNotIn is an autogenerated method @@ -597,13 +597,13 @@ func (qs CheckReservedKeywordsQuerySet) StructNotIn(structValue int, structValue for _, arg := range structValueRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("struct NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`struct` NOT IN (?)", iArgs)) } // TypeEq is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) TypeEq(typeValue string) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("type = ?", typeValue)) + return qs.w(qs.db.Where("`type` = ?", typeValue)) } // TypeIn is an autogenerated method @@ -613,13 +613,13 @@ func (qs CheckReservedKeywordsQuerySet) TypeIn(typeValue string, typeValueRest . for _, arg := range typeValueRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("type IN (?)", iArgs)) + return qs.w(qs.db.Where("`type` IN (?)", iArgs)) } // TypeNe is an autogenerated method // nolint: dupl func (qs CheckReservedKeywordsQuerySet) TypeNe(typeValue string) CheckReservedKeywordsQuerySet { - return qs.w(qs.db.Where("type != ?", typeValue)) + return qs.w(qs.db.Where("`type` != ?", typeValue)) } // TypeNotIn is an autogenerated method @@ -629,7 +629,7 @@ func (qs CheckReservedKeywordsQuerySet) TypeNotIn(typeValue string, typeValueRes for _, arg := range typeValueRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("type NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`type` NOT IN (?)", iArgs)) } // Update is an autogenerated method @@ -757,37 +757,37 @@ func (o *Post) Create(db *gorm.DB) error { // CreatedAtEq is an autogenerated method // nolint: dupl func (qs PostQuerySet) CreatedAtEq(createdAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("created_at = ?", createdAt)) + return qs.w(qs.db.Where("`created_at` = ?", createdAt)) } // CreatedAtGt is an autogenerated method // nolint: dupl func (qs PostQuerySet) CreatedAtGt(createdAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("created_at > ?", createdAt)) + return qs.w(qs.db.Where("`created_at` > ?", createdAt)) } // CreatedAtGte is an autogenerated method // nolint: dupl func (qs PostQuerySet) CreatedAtGte(createdAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("created_at >= ?", createdAt)) + return qs.w(qs.db.Where("`created_at` >= ?", createdAt)) } // CreatedAtLt is an autogenerated method // nolint: dupl func (qs PostQuerySet) CreatedAtLt(createdAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("created_at < ?", createdAt)) + return qs.w(qs.db.Where("`created_at` < ?", createdAt)) } // CreatedAtLte is an autogenerated method // nolint: dupl func (qs PostQuerySet) CreatedAtLte(createdAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("created_at <= ?", createdAt)) + return qs.w(qs.db.Where("`created_at` <= ?", createdAt)) } // CreatedAtNe is an autogenerated method // nolint: dupl func (qs PostQuerySet) CreatedAtNe(createdAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("created_at != ?", createdAt)) + return qs.w(qs.db.Where("`created_at` != ?", createdAt)) } // Delete is an autogenerated method @@ -805,19 +805,19 @@ func (qs PostQuerySet) Delete() error { // DeletedAtEq is an autogenerated method // nolint: dupl func (qs PostQuerySet) DeletedAtEq(deletedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("deleted_at = ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` = ?", deletedAt)) } // DeletedAtGt is an autogenerated method // nolint: dupl func (qs PostQuerySet) DeletedAtGt(deletedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("deleted_at > ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` > ?", deletedAt)) } // DeletedAtGte is an autogenerated method // nolint: dupl func (qs PostQuerySet) DeletedAtGte(deletedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("deleted_at >= ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` >= ?", deletedAt)) } // DeletedAtIsNotNull is an autogenerated method @@ -835,19 +835,19 @@ func (qs PostQuerySet) DeletedAtIsNull() PostQuerySet { // DeletedAtLt is an autogenerated method // nolint: dupl func (qs PostQuerySet) DeletedAtLt(deletedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("deleted_at < ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` < ?", deletedAt)) } // DeletedAtLte is an autogenerated method // nolint: dupl func (qs PostQuerySet) DeletedAtLte(deletedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("deleted_at <= ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` <= ?", deletedAt)) } // DeletedAtNe is an autogenerated method // nolint: dupl func (qs PostQuerySet) DeletedAtNe(deletedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("deleted_at != ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` != ?", deletedAt)) } // GetUpdater is an autogenerated method @@ -859,19 +859,19 @@ func (qs PostQuerySet) GetUpdater() PostUpdater { // IDEq is an autogenerated method // nolint: dupl func (qs PostQuerySet) IDEq(ID uint) PostQuerySet { - return qs.w(qs.db.Where("id = ?", ID)) + return qs.w(qs.db.Where("`id` = ?", ID)) } // IDGt is an autogenerated method // nolint: dupl func (qs PostQuerySet) IDGt(ID uint) PostQuerySet { - return qs.w(qs.db.Where("id > ?", ID)) + return qs.w(qs.db.Where("`id` > ?", ID)) } // IDGte is an autogenerated method // nolint: dupl func (qs PostQuerySet) IDGte(ID uint) PostQuerySet { - return qs.w(qs.db.Where("id >= ?", ID)) + return qs.w(qs.db.Where("`id` >= ?", ID)) } // IDIn is an autogenerated method @@ -881,25 +881,25 @@ func (qs PostQuerySet) IDIn(ID uint, IDRest ...uint) PostQuerySet { for _, arg := range IDRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("id IN (?)", iArgs)) + return qs.w(qs.db.Where("`id` IN (?)", iArgs)) } // IDLt is an autogenerated method // nolint: dupl func (qs PostQuerySet) IDLt(ID uint) PostQuerySet { - return qs.w(qs.db.Where("id < ?", ID)) + return qs.w(qs.db.Where("`id` < ?", ID)) } // IDLte is an autogenerated method // nolint: dupl func (qs PostQuerySet) IDLte(ID uint) PostQuerySet { - return qs.w(qs.db.Where("id <= ?", ID)) + return qs.w(qs.db.Where("`id` <= ?", ID)) } // IDNe is an autogenerated method // nolint: dupl func (qs PostQuerySet) IDNe(ID uint) PostQuerySet { - return qs.w(qs.db.Where("id != ?", ID)) + return qs.w(qs.db.Where("`id` != ?", ID)) } // IDNotIn is an autogenerated method @@ -909,7 +909,7 @@ func (qs PostQuerySet) IDNotIn(ID uint, IDRest ...uint) PostQuerySet { for _, arg := range IDRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("id NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`id` NOT IN (?)", iArgs)) } // Limit is an autogenerated method @@ -1036,7 +1036,7 @@ func (u PostUpdater) SetUser(user User) PostUpdater { // StrEq is an autogenerated method // nolint: dupl func (qs PostQuerySet) StrEq(str tmp.StringDef) PostQuerySet { - return qs.w(qs.db.Where("str = ?", str)) + return qs.w(qs.db.Where("`str` = ?", str)) } // StrIn is an autogenerated method @@ -1046,13 +1046,13 @@ func (qs PostQuerySet) StrIn(str tmp.StringDef, strRest ...tmp.StringDef) PostQu for _, arg := range strRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("str IN (?)", iArgs)) + return qs.w(qs.db.Where("`str` IN (?)", iArgs)) } // StrNe is an autogenerated method // nolint: dupl func (qs PostQuerySet) StrNe(str tmp.StringDef) PostQuerySet { - return qs.w(qs.db.Where("str != ?", str)) + return qs.w(qs.db.Where("`str` != ?", str)) } // StrNotIn is an autogenerated method @@ -1062,13 +1062,13 @@ func (qs PostQuerySet) StrNotIn(str tmp.StringDef, strRest ...tmp.StringDef) Pos for _, arg := range strRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("str NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`str` NOT IN (?)", iArgs)) } // TitleEq is an autogenerated method // nolint: dupl func (qs PostQuerySet) TitleEq(title string) PostQuerySet { - return qs.w(qs.db.Where("title = ?", title)) + return qs.w(qs.db.Where("`title` = ?", title)) } // TitleIn is an autogenerated method @@ -1078,7 +1078,7 @@ func (qs PostQuerySet) TitleIn(title string, titleRest ...string) PostQuerySet { for _, arg := range titleRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("title IN (?)", iArgs)) + return qs.w(qs.db.Where("`title` IN (?)", iArgs)) } // TitleIsNotNull is an autogenerated method @@ -1096,7 +1096,7 @@ func (qs PostQuerySet) TitleIsNull() PostQuerySet { // TitleNe is an autogenerated method // nolint: dupl func (qs PostQuerySet) TitleNe(title string) PostQuerySet { - return qs.w(qs.db.Where("title != ?", title)) + return qs.w(qs.db.Where("`title` != ?", title)) } // TitleNotIn is an autogenerated method @@ -1106,7 +1106,7 @@ func (qs PostQuerySet) TitleNotIn(title string, titleRest ...string) PostQuerySe for _, arg := range titleRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("title NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`title` NOT IN (?)", iArgs)) } // Update is an autogenerated method @@ -1125,37 +1125,37 @@ func (u PostUpdater) UpdateNum() (int64, error) { // UpdatedAtEq is an autogenerated method // nolint: dupl func (qs PostQuerySet) UpdatedAtEq(updatedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("updated_at = ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` = ?", updatedAt)) } // UpdatedAtGt is an autogenerated method // nolint: dupl func (qs PostQuerySet) UpdatedAtGt(updatedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("updated_at > ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` > ?", updatedAt)) } // UpdatedAtGte is an autogenerated method // nolint: dupl func (qs PostQuerySet) UpdatedAtGte(updatedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("updated_at >= ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` >= ?", updatedAt)) } // UpdatedAtLt is an autogenerated method // nolint: dupl func (qs PostQuerySet) UpdatedAtLt(updatedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("updated_at < ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` < ?", updatedAt)) } // UpdatedAtLte is an autogenerated method // nolint: dupl func (qs PostQuerySet) UpdatedAtLte(updatedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("updated_at <= ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` <= ?", updatedAt)) } // UpdatedAtNe is an autogenerated method // nolint: dupl func (qs PostQuerySet) UpdatedAtNe(updatedAt time.Time) PostQuerySet { - return qs.w(qs.db.Where("updated_at != ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` != ?", updatedAt)) } // ===== END of query set PostQuerySet @@ -1276,37 +1276,37 @@ func (o *User) Create(db *gorm.DB) error { // CreatedAtEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) CreatedAtEq(createdAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("created_at = ?", createdAt)) + return qs.w(qs.db.Where("`created_at` = ?", createdAt)) } // CreatedAtGt is an autogenerated method // nolint: dupl func (qs UserQuerySet) CreatedAtGt(createdAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("created_at > ?", createdAt)) + return qs.w(qs.db.Where("`created_at` > ?", createdAt)) } // CreatedAtGte is an autogenerated method // nolint: dupl func (qs UserQuerySet) CreatedAtGte(createdAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("created_at >= ?", createdAt)) + return qs.w(qs.db.Where("`created_at` >= ?", createdAt)) } // CreatedAtLt is an autogenerated method // nolint: dupl func (qs UserQuerySet) CreatedAtLt(createdAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("created_at < ?", createdAt)) + return qs.w(qs.db.Where("`created_at` < ?", createdAt)) } // CreatedAtLte is an autogenerated method // nolint: dupl func (qs UserQuerySet) CreatedAtLte(createdAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("created_at <= ?", createdAt)) + return qs.w(qs.db.Where("`created_at` <= ?", createdAt)) } // CreatedAtNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) CreatedAtNe(createdAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("created_at != ?", createdAt)) + return qs.w(qs.db.Where("`created_at` != ?", createdAt)) } // Delete is an autogenerated method @@ -1324,19 +1324,19 @@ func (o *User) Delete(db *gorm.DB) error { // DeletedAtEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) DeletedAtEq(deletedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("deleted_at = ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` = ?", deletedAt)) } // DeletedAtGt is an autogenerated method // nolint: dupl func (qs UserQuerySet) DeletedAtGt(deletedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("deleted_at > ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` > ?", deletedAt)) } // DeletedAtGte is an autogenerated method // nolint: dupl func (qs UserQuerySet) DeletedAtGte(deletedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("deleted_at >= ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` >= ?", deletedAt)) } // DeletedAtIsNotNull is an autogenerated method @@ -1354,25 +1354,25 @@ func (qs UserQuerySet) DeletedAtIsNull() UserQuerySet { // DeletedAtLt is an autogenerated method // nolint: dupl func (qs UserQuerySet) DeletedAtLt(deletedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("deleted_at < ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` < ?", deletedAt)) } // DeletedAtLte is an autogenerated method // nolint: dupl func (qs UserQuerySet) DeletedAtLte(deletedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("deleted_at <= ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` <= ?", deletedAt)) } // DeletedAtNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) DeletedAtNe(deletedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("deleted_at != ?", deletedAt)) + return qs.w(qs.db.Where("`deleted_at` != ?", deletedAt)) } // EmailEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) EmailEq(email string) UserQuerySet { - return qs.w(qs.db.Where("email = ?", email)) + return qs.w(qs.db.Where("`email` = ?", email)) } // EmailIn is an autogenerated method @@ -1382,13 +1382,13 @@ func (qs UserQuerySet) EmailIn(email string, emailRest ...string) UserQuerySet { for _, arg := range emailRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("email IN (?)", iArgs)) + return qs.w(qs.db.Where("`email` IN (?)", iArgs)) } // EmailNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) EmailNe(email string) UserQuerySet { - return qs.w(qs.db.Where("email != ?", email)) + return qs.w(qs.db.Where("`email` != ?", email)) } // EmailNotIn is an autogenerated method @@ -1398,7 +1398,7 @@ func (qs UserQuerySet) EmailNotIn(email string, emailRest ...string) UserQuerySe for _, arg := range emailRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("email NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`email` NOT IN (?)", iArgs)) } // GetUpdater is an autogenerated method @@ -1410,19 +1410,19 @@ func (qs UserQuerySet) GetUpdater() UserUpdater { // IDEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) IDEq(ID uint) UserQuerySet { - return qs.w(qs.db.Where("id = ?", ID)) + return qs.w(qs.db.Where("`id` = ?", ID)) } // IDGt is an autogenerated method // nolint: dupl func (qs UserQuerySet) IDGt(ID uint) UserQuerySet { - return qs.w(qs.db.Where("id > ?", ID)) + return qs.w(qs.db.Where("`id` > ?", ID)) } // IDGte is an autogenerated method // nolint: dupl func (qs UserQuerySet) IDGte(ID uint) UserQuerySet { - return qs.w(qs.db.Where("id >= ?", ID)) + return qs.w(qs.db.Where("`id` >= ?", ID)) } // IDIn is an autogenerated method @@ -1432,25 +1432,25 @@ func (qs UserQuerySet) IDIn(ID uint, IDRest ...uint) UserQuerySet { for _, arg := range IDRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("id IN (?)", iArgs)) + return qs.w(qs.db.Where("`id` IN (?)", iArgs)) } // IDLt is an autogenerated method // nolint: dupl func (qs UserQuerySet) IDLt(ID uint) UserQuerySet { - return qs.w(qs.db.Where("id < ?", ID)) + return qs.w(qs.db.Where("`id` < ?", ID)) } // IDLte is an autogenerated method // nolint: dupl func (qs UserQuerySet) IDLte(ID uint) UserQuerySet { - return qs.w(qs.db.Where("id <= ?", ID)) + return qs.w(qs.db.Where("`id` <= ?", ID)) } // IDNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) IDNe(ID uint) UserQuerySet { - return qs.w(qs.db.Where("id != ?", ID)) + return qs.w(qs.db.Where("`id` != ?", ID)) } // IDNotIn is an autogenerated method @@ -1460,7 +1460,7 @@ func (qs UserQuerySet) IDNotIn(ID uint, IDRest ...uint) UserQuerySet { for _, arg := range IDRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("id NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`id` NOT IN (?)", iArgs)) } // Limit is an autogenerated method @@ -1472,7 +1472,7 @@ func (qs UserQuerySet) Limit(limit int) UserQuerySet { // NameEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) NameEq(name string) UserQuerySet { - return qs.w(qs.db.Where("name = ?", name)) + return qs.w(qs.db.Where("`name` = ?", name)) } // NameIn is an autogenerated method @@ -1482,13 +1482,13 @@ func (qs UserQuerySet) NameIn(name string, nameRest ...string) UserQuerySet { for _, arg := range nameRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("name IN (?)", iArgs)) + return qs.w(qs.db.Where("`name` IN (?)", iArgs)) } // NameNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) NameNe(name string) UserQuerySet { - return qs.w(qs.db.Where("name != ?", name)) + return qs.w(qs.db.Where("`name` != ?", name)) } // NameNotIn is an autogenerated method @@ -1498,7 +1498,7 @@ func (qs UserQuerySet) NameNotIn(name string, nameRest ...string) UserQuerySet { for _, arg := range nameRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("name NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`name` NOT IN (?)", iArgs)) } // One is used to retrieve one result. It returns gorm.ErrRecordNotFound @@ -1607,7 +1607,7 @@ func (u UserUpdater) SetUpdatedAt(updatedAt time.Time) UserUpdater { // SurnameEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) SurnameEq(surname string) UserQuerySet { - return qs.w(qs.db.Where("user_surname = ?", surname)) + return qs.w(qs.db.Where("`user_surname` = ?", surname)) } // SurnameIn is an autogenerated method @@ -1617,7 +1617,7 @@ func (qs UserQuerySet) SurnameIn(surname string, surnameRest ...string) UserQuer for _, arg := range surnameRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("user_surname IN (?)", iArgs)) + return qs.w(qs.db.Where("`user_surname` IN (?)", iArgs)) } // SurnameIsNotNull is an autogenerated method @@ -1635,7 +1635,7 @@ func (qs UserQuerySet) SurnameIsNull() UserQuerySet { // SurnameNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) SurnameNe(surname string) UserQuerySet { - return qs.w(qs.db.Where("user_surname != ?", surname)) + return qs.w(qs.db.Where("`user_surname` != ?", surname)) } // SurnameNotIn is an autogenerated method @@ -1645,7 +1645,7 @@ func (qs UserQuerySet) SurnameNotIn(surname string, surnameRest ...string) UserQ for _, arg := range surnameRest { iArgs = append(iArgs, arg) } - return qs.w(qs.db.Where("user_surname NOT IN (?)", iArgs)) + return qs.w(qs.db.Where("`user_surname` NOT IN (?)", iArgs)) } // Update is an autogenerated method @@ -1664,37 +1664,37 @@ func (u UserUpdater) UpdateNum() (int64, error) { // UpdatedAtEq is an autogenerated method // nolint: dupl func (qs UserQuerySet) UpdatedAtEq(updatedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("updated_at = ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` = ?", updatedAt)) } // UpdatedAtGt is an autogenerated method // nolint: dupl func (qs UserQuerySet) UpdatedAtGt(updatedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("updated_at > ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` > ?", updatedAt)) } // UpdatedAtGte is an autogenerated method // nolint: dupl func (qs UserQuerySet) UpdatedAtGte(updatedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("updated_at >= ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` >= ?", updatedAt)) } // UpdatedAtLt is an autogenerated method // nolint: dupl func (qs UserQuerySet) UpdatedAtLt(updatedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("updated_at < ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` < ?", updatedAt)) } // UpdatedAtLte is an autogenerated method // nolint: dupl func (qs UserQuerySet) UpdatedAtLte(updatedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("updated_at <= ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` <= ?", updatedAt)) } // UpdatedAtNe is an autogenerated method // nolint: dupl func (qs UserQuerySet) UpdatedAtNe(updatedAt time.Time) UserQuerySet { - return qs.w(qs.db.Where("updated_at != ?", updatedAt)) + return qs.w(qs.db.Where("`updated_at` != ?", updatedAt)) } // ===== END of query set UserQuerySet