GORM
Moved to https://github.com/go-gorm/gorm
Moved to https://github.com/go-gorm/gorm
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Currently SubQuery() & QueryExpr() ignore 'gorm:query_option' which is wrong and causes sub-selects to lose locking. The patch eliminates the issue.
Make sure these boxes checked before submitting your pull request.
This will prevent creating nested transactions while calling *DB.Transaction(...) multiple times. Only fist call will create transaction. Rest will just reuse it.
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Sometime we want to paginate convenient, we will write like below, but we will get a 0
for count
:
var (
user []User
count int
)
if err := DB.Where("name=?", "john").Limit(10).Offset(20).Find(&users).Count(&count).Error; err != nil {
t.Errorf("Not error should happen, but got %v", err)
}
It is because if we run Count
with Offset
, we will get an empty data set.
After my attempts, this can achieve the count
var (
user []User
count int
)
db := DB.Where("name=?", "john")
if err := db.Limit(10).Offset(20).Find(&users).Error; err != nil {
t.Errorf("Not error should happen, but got %v", err)
}
if err := db.Count(&count).Error; err != nil {
t.Errorf("Not error should happen, but got %v", err)
}
or
var (
user []User
count int
)
if err := DB.Where("name=?", "john").Limit(10).Offset(20).Find(&users).Offset(0).Count(&count).Error; err != nil {
t.Errorf("Not error should happen, but got %v", err)
}
But the code will be more verbose. I think more people hope to complete the goal in one chain call, like here
This branch is ported from ignoreOrderQuery, use a new tag ignoreLimitAndOffsetQuery to skip the limitAndOffsetQuery
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Added support for setting nullable
of columns using gorm.
1.Change the time to the system default time,Avoid confusion of time
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
This pull request changes nothing but go.sum
, removing the erroneous github.com/mattn/go-sqlite3 v2.0.1
.
This PR supersedes #20. Apologies, as I chose the wrong branch to merge from.
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
For nested preloads there seems to be no passing of errors if a preload query fails. So for example in a test case from this PR, if Level2
preload fails with error for err = localDB.Preload("Level2").Find(&got).Error
, then err != nil
.
However, for nested preload fails this is not the case. If Level1
preload will fail with error from the DB, for the err = localDB.Preload("Level2.Level1").Find(&got).Error
query we will have err == nil
. This may lead to segmentation faults when objects that are expected to be preloaded (because err == nil
) are in fact not preloaded and empty.
This PR fixes that by checking currentScope
errors on preload callbacks.
Make sure these boxes checked before submitting your pull request.
For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.
Fixes a typo in a comment. Great package by the way!
I'm seeing "broken pipe" errors randomly on one of our servers The issue seems to be the db driver, connections become stale when tcp connections were disconnected.
It happens more often when the DB is behind a proxy.
This has been reported and fixed in the lib/pq in v1.9+
https://github.com/lib/pq/pull/871