Gorm SQL语句多出表名前缀

Your Question多个项目共用一套Models,之前是在各个项目中分别AutoMigrate(),为了统一我将AutoMigrate()独立成单独的应用,但是这样导致了一些问题:SELECT * FROM `suppliers` W...

Gorm Use TableName to specify the database for the Create operation, but Create will ignore my database name

Description:I use 'Attach DATABASE' to attach the databaseerr = db.Exec("ATTACH DATABASE '" + dsnInfo + "' AS info").Err...

Gorm Understanding Foreign Keys/One-to-Many

How can I use 1 - Many RelationshipsI'm at a loss how to make this work. I've extensively experimented, and reviewed the...

Gorm How to add Limit, Offset and Order By clause to Raw chain method?

Your QuestionThe query that I am trying is err = gdb.Raw(sqlQuery, qp.WhereArgs...).Offset(qp.Offset).Limit(qp.Limit).Or...

Gorm model value required when using preload

When I run tx.Preload, get error: "model value required when using preload"tx *gorm.DB tx = tx.Preload("Tags"...

Gorm Why does the OR method exist, But not the AND method?!

Why does the OR method exist, But not the AND method?!https://gorm.io/docs/query.html#Or-ConditionsComment From: github-...

Gorm FindInBatches over Offset instead of Primary Key increments

Actually find in Batches works using the primary key as an increment, so it assumes that the Batch is sorted with the Pr...

Gorm update使用子查询

UPDATE phone SET user_id=2, share=0 where (SELECT id FROM phone WHERE share = 1 LIMIT 1)这样的sql用gormv2 要怎么写呢...Comment Fr...

Gorm Disable Timestamp Tracking is not working as is documented?

Your QuestionI have this model:type sqlModel struct { Id string `gorm:"primaryKey"` Product...

Gorm False value in where clause ignored

I'm running in to an issue I'll detail with a brief example:// Example modeltype Example struct { gorm.Model Value...

Gorm A limit of zero returns the wrong results

GORM Playground Linkhttps://github.com/go-gorm/playground/pull/522DescriptionSpecifying a limit of 0 results in all rows...

Gorm Please reopen #4946

Referencing another ticket that a lot of people have commented on recently and trying to have it reopened. So as to avoi...

Gorm Add the JSON support for SQLite

Describe the featureSQLite now supports JSON type.Please refer to https://www.sqlite.org/json1.htmlMotivationSQLite No 1...

Gorm Nested preload with limit

Your QuestionI want to perform a limit on a nested preload to improve performance. The limit works on the total count on...

Gorm How to get the number of affected rows actually inserted when using the FirstOrCreate method

V1.24.6 result := db.Where(entity.SysClientUser{Email: "sun"}).FirstOrCreate(&entity.SysClientUser{Email: "test"}...

Gorm 使用errgroup并发查询时报错

问题: 当我使用errgroup并发读数据库时发生了panic报错信息:fatal error: concurrent map writesgoroutine 2183 [running]:runtime.throw(0x2168afc, ...

Gorm Save (probably) should be idempotent

According to https://gorm.io/docs/update.html#Save-All-Fields"Save is a combination function. If save value does not con...

Gorm How to update created_at manually

I tried db.DB.Exec("UPDATE thread SET created_at = ? WHERE id = ?", time.Now(), id) but seems this method dose not work ...

Gorm Preload associations inside embedded fields

GORM Playground Linkhttps://github.com/go-gorm/playground/pull/576DescriptionIn our application we'd like to have a simi...

Gorm AutoMigrate ignore "where" conditions on unique index for SQLite

GORM Playground Linkhttps://github.com/go-gorm/playground/pull/581DescriptionI create uniq index with condition on value...
上一页 下一页
.