Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
68263895f7 | |||
ee6cb445ab |
14
pgm.go
14
pgm.go
@@ -45,17 +45,17 @@ func (f Field) Count() Field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StringEscape will return a empty string for null value
|
// StringEscape will return a empty string for null value
|
||||||
func (f Field) StringEscape(arg ...any) Field {
|
func (f Field) StringEscape() Field {
|
||||||
return Field("COALESCE(" + f.String() + ", '')")
|
return Field("COALESCE(" + f.String() + ", '')")
|
||||||
}
|
}
|
||||||
|
|
||||||
// NumberEscape will return a zero string for null value
|
// NumberEscape will return a zero string for null value
|
||||||
func (f Field) NumberEscape(arg ...any) Field {
|
func (f Field) NumberEscape() Field {
|
||||||
return Field("COALESCE(" + f.String() + ", 0)")
|
return Field("COALESCE(" + f.String() + ", 0)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// BooleanEscape will return a false for null value
|
// BooleanEscape will return a false for null value
|
||||||
func (f Field) BooleanEscape(arg ...any) Field {
|
func (f Field) BooleanEscape() Field {
|
||||||
return Field("COALESCE(" + f.String() + ", FALSE)")
|
return Field("COALESCE(" + f.String() + ", FALSE)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,10 +104,12 @@ func (f Field) Eq(val any) Conditioner {
|
|||||||
return &Cond{Field: col, Val: val, op: " = $", len: len(col) + 5}
|
return &Cond{Field: col, Val: val, op: " = $", len: len(col) + 5}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualFold will user LOWER() for comparision
|
// EqualFold will use LOWER(column_name) = val for comparision
|
||||||
func (f Field) EqFold(val any) Conditioner {
|
//
|
||||||
|
// strings.ToLower(val) will pefromed on the provide val
|
||||||
|
func (f Field) EqFold(val string) Conditioner {
|
||||||
col := f.String()
|
col := f.String()
|
||||||
return &Cond{Field: "LOWER(" + col + ")", Val: val, op: " = LOWER($", action: CondActionNeedToClose, len: len(col) + 5}
|
return &Cond{Field: "LOWER(" + col + ")", Val: strings.ToLower(val), op: " = LOWER($", action: CondActionNeedToClose, len: len(col) + 5}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f Field) NEq(val any) Conditioner {
|
func (f Field) NEq(val any) Conditioner {
|
||||||
|
Reference in New Issue
Block a user