Address lint issues
This commit is contained in:
parent
0fe079686b
commit
c9984634ac
@ -200,6 +200,7 @@ func (db *DB) FindInBatches(dest interface{}, batchSize int, fc func(tx *DB, bat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find:
|
||||||
for {
|
for {
|
||||||
result := queryDB.Limit(batchSize).Find(dest)
|
result := queryDB.Limit(batchSize).Find(dest)
|
||||||
rowsAffected += result.RowsAffected
|
rowsAffected += result.RowsAffected
|
||||||
@ -257,8 +258,8 @@ func (db *DB) FindInBatches(dest interface{}, batchSize int, fc func(tx *DB, bat
|
|||||||
f = result.Statement.Schema.PrimaryFields[i]
|
f = result.Statement.Schema.PrimaryFields[i]
|
||||||
primaryValue, zero := f.ValueOf(tx.Statement.Context, resultsValue.Index(resultsValue.Len()-1))
|
primaryValue, zero := f.ValueOf(tx.Statement.Context, resultsValue.Index(resultsValue.Len()-1))
|
||||||
if zero {
|
if zero {
|
||||||
tx.AddError(ErrPrimaryKeyRequired)
|
tx.AddError(ErrPrimaryKeyRequired) //nolint:typecheck,errcheck,gosec
|
||||||
break
|
break find
|
||||||
}
|
}
|
||||||
orClauses = append(orClauses, clause.Gt{Column: clause.Column{Table: clause.CurrentTable, Name: f.DBName}, Value: primaryValue})
|
orClauses = append(orClauses, clause.Gt{Column: clause.Column{Table: clause.CurrentTable, Name: f.DBName}, Value: primaryValue})
|
||||||
} else {
|
} else {
|
||||||
@ -267,8 +268,8 @@ func (db *DB) FindInBatches(dest interface{}, batchSize int, fc func(tx *DB, bat
|
|||||||
f = result.Statement.Schema.PrimaryFields[j]
|
f = result.Statement.Schema.PrimaryFields[j]
|
||||||
primaryValue, zero := f.ValueOf(tx.Statement.Context, resultsValue.Index(resultsValue.Len()-1))
|
primaryValue, zero := f.ValueOf(tx.Statement.Context, resultsValue.Index(resultsValue.Len()-1))
|
||||||
if zero {
|
if zero {
|
||||||
tx.AddError(ErrPrimaryKeyRequired)
|
tx.AddError(ErrPrimaryKeyRequired) //nolint:typecheck,errcheck,gosec
|
||||||
break
|
break find
|
||||||
}
|
}
|
||||||
if j == i {
|
if j == i {
|
||||||
// Build current outer column GT clause
|
// Build current outer column GT clause
|
||||||
@ -285,7 +286,7 @@ func (db *DB) FindInBatches(dest interface{}, batchSize int, fc func(tx *DB, bat
|
|||||||
} else {
|
} else {
|
||||||
primaryValue, zero := result.Statement.Schema.PrimaryFields[0].ValueOf(tx.Statement.Context, resultsValue.Index(resultsValue.Len()-1))
|
primaryValue, zero := result.Statement.Schema.PrimaryFields[0].ValueOf(tx.Statement.Context, resultsValue.Index(resultsValue.Len()-1))
|
||||||
if zero {
|
if zero {
|
||||||
tx.AddError(ErrPrimaryKeyRequired)
|
tx.AddError(ErrPrimaryKeyRequired) //nolint:typecheck,errcheck,gosec
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
queryDB = tx.Clauses(clause.Gt{Column: clause.Column{Table: clause.CurrentTable, Name: result.Statement.Schema.PrimaryFields[0].DBName}, Value: primaryValue})
|
queryDB = tx.Clauses(clause.Gt{Column: clause.Column{Table: clause.CurrentTable, Name: result.Statement.Schema.PrimaryFields[0].DBName}, Value: primaryValue})
|
||||||
|
19
statement.go
19
statement.go
@ -112,7 +112,7 @@ func (stmt *Statement) QuoteTo(writer clause.Writer, field interface{}) {
|
|||||||
} else if stmt.Schema.PrimaryFields != nil {
|
} else if stmt.Schema.PrimaryFields != nil {
|
||||||
for idx, s := range stmt.Schema.PrimaryFieldDBNames {
|
for idx, s := range stmt.Schema.PrimaryFieldDBNames {
|
||||||
if idx > 0 {
|
if idx > 0 {
|
||||||
writer.WriteByte(',')
|
writer.WriteByte(',') //nolint:typecheck,errcheck,gosec
|
||||||
}
|
}
|
||||||
if v.Table != "" {
|
if v.Table != "" {
|
||||||
if v.Table == clause.CurrentTable {
|
if v.Table == clause.CurrentTable {
|
||||||
@ -120,7 +120,7 @@ func (stmt *Statement) QuoteTo(writer clause.Writer, field interface{}) {
|
|||||||
} else {
|
} else {
|
||||||
write(v.Raw, v.Table)
|
write(v.Raw, v.Table)
|
||||||
}
|
}
|
||||||
writer.WriteByte('.')
|
writer.WriteByte('.') //nolint:typecheck,errcheck,gosec
|
||||||
}
|
}
|
||||||
write(v.Raw, s)
|
write(v.Raw, s)
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ func (stmt *Statement) QuoteTo(writer clause.Writer, field interface{}) {
|
|||||||
} else {
|
} else {
|
||||||
write(v.Raw, v.Table)
|
write(v.Raw, v.Table)
|
||||||
}
|
}
|
||||||
writer.WriteByte('.')
|
writer.WriteByte('.') //nolint:typecheck,errcheck,gosec
|
||||||
}
|
}
|
||||||
write(v.Raw, stmt.Schema.DBNames[0])
|
write(v.Raw, stmt.Schema.DBNames[0])
|
||||||
} else {
|
} else {
|
||||||
@ -148,14 +148,15 @@ func (stmt *Statement) QuoteTo(writer clause.Writer, field interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.Name == clause.PrimaryKey {
|
if v.Name == clause.PrimaryKey {
|
||||||
if stmt.Schema == nil {
|
switch {
|
||||||
stmt.DB.AddError(ErrModelValueRequired)
|
case stmt.Schema == nil:
|
||||||
} else if stmt.Schema.PrioritizedPrimaryField != nil {
|
stmt.DB.AddError(ErrModelValueRequired) //nolint:typecheck,errcheck,gosec
|
||||||
|
case stmt.Schema.PrioritizedPrimaryField != nil:
|
||||||
write(v.Raw, stmt.Schema.PrioritizedPrimaryField.DBName)
|
write(v.Raw, stmt.Schema.PrioritizedPrimaryField.DBName)
|
||||||
} else if len(stmt.Schema.DBNames) > 0 {
|
case len(stmt.Schema.DBNames) > 0:
|
||||||
write(v.Raw, stmt.Schema.DBNames[0])
|
write(v.Raw, stmt.Schema.DBNames[0])
|
||||||
} else {
|
default:
|
||||||
stmt.DB.AddError(ErrModelAccessibleFieldsRequired) //nolint:typecheck,errcheck
|
stmt.DB.AddError(ErrModelAccessibleFieldsRequired) //nolint:typecheck,errcheck,gosec
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
write(v.Raw, v.Name)
|
write(v.Raw, v.Name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user