5 Commits

Author SHA1 Message Date
525c64e678 removed toLower 2025-08-10 12:54:29 +05:30
5f0fdadb8b undo, strings.ToLower 2025-08-10 12:24:26 +05:30
68263895f7 EqFold to do value lower case 2025-08-10 11:59:01 +05:30
ee6cb445ab remove unwanted method args 2025-08-03 22:21:24 +05:30
d07c25fe01 COALESCE related methods 2025-08-03 22:17:58 +05:30

19
pgm.go
View File

@@ -44,6 +44,21 @@ func (f Field) Count() Field {
return Field("COUNT(" + f.String() + ")") return Field("COUNT(" + f.String() + ")")
} }
// StringEscape will return a empty string for null value
func (f Field) StringEscape() Field {
return Field("COALESCE(" + f.String() + ", '')")
}
// NumberEscape will return a zero string for null value
func (f Field) NumberEscape() Field {
return Field("COALESCE(" + f.String() + ", 0)")
}
// BooleanEscape will return a false for null value
func (f Field) BooleanEscape() Field {
return Field("COALESCE(" + f.String() + ", FALSE)")
}
// Avg fn wrapping of field // Avg fn wrapping of field
func (f Field) Avg() Field { func (f Field) Avg() Field {
return Field("AVG(" + f.String() + ")") return Field("AVG(" + f.String() + ")")
@@ -89,8 +104,8 @@ 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) = LOWER(val) for comparision
func (f Field) EqFold(val any) Conditioner { 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: val, op: " = LOWER($", action: CondActionNeedToClose, len: len(col) + 5}
} }