-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
354 additions
and
2,169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,8 @@ | ||
package field | ||
|
||
import ( | ||
"database/sql/driver" | ||
|
||
"gorm.io/gorm/clause" | ||
) | ||
|
||
// ScanValuer interface for Field | ||
type ScanValuer interface { | ||
Scan(src interface{}) error // sql.Scanner | ||
Value() (driver.Value, error) // driver.Valuer | ||
} | ||
import "database/sql/driver" | ||
|
||
// Field a standard field struct | ||
type Field struct{ expr } | ||
|
||
// Eq judge equal | ||
func (field Field) Eq(value driver.Valuer) Expr { | ||
return expr{e: clause.Eq{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// Neq judge not equal | ||
func (field Field) Neq(value driver.Valuer) Expr { | ||
return expr{e: clause.Neq{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// In ... | ||
func (field Field) In(values ...driver.Valuer) Expr { | ||
return expr{e: clause.IN{Column: field.RawExpr(), Values: field.toSlice(values...)}} | ||
} | ||
|
||
// Gt ... | ||
func (field Field) Gt(value driver.Valuer) Expr { | ||
return expr{e: clause.Gt{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// Gte ... | ||
func (field Field) Gte(value driver.Valuer) Expr { | ||
return expr{e: clause.Gte{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// Lt ... | ||
func (field Field) Lt(value driver.Valuer) Expr { | ||
return expr{e: clause.Lt{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// Lte ... | ||
func (field Field) Lte(value driver.Valuer) Expr { | ||
return expr{e: clause.Lte{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// Like ... | ||
func (field Field) Like(value driver.Valuer) Expr { | ||
return expr{e: clause.Like{Column: field.RawExpr(), Value: value}} | ||
} | ||
|
||
// Value ... | ||
func (field Field) Value(value driver.Valuer) AssignExpr { | ||
return field.value(value) | ||
} | ||
|
||
// Sum ... | ||
func (field Field) Sum() Field { | ||
return Field{field.sum()} | ||
} | ||
|
||
// IfNull ... | ||
func (field Field) IfNull(value driver.Valuer) Expr { | ||
return field.ifNull(value) | ||
} | ||
|
||
func (field Field) toSlice(values ...driver.Valuer) []interface{} { | ||
slice := make([]interface{}, len(values)) | ||
for i, v := range values { | ||
slice[i] = v | ||
} | ||
return slice | ||
type Field struct { | ||
GenericsField[driver.Valuer] | ||
} |
Oops, something went wrong.