Fix panic in toSQLConditionClause when no values are provided
This commit is contained in:
@@ -341,6 +341,9 @@ func (match Matcher) toSQLConditionClause(ctx context.Context, suffix string, co
|
|||||||
params[uniqKey] = encodedValue
|
params[uniqKey] = encodedValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nameStmt := colDef.Name
|
||||||
|
|
||||||
|
if len(values) > 0 {
|
||||||
// NOTE(ppacher): for now we assume that the type of each element of values
|
// NOTE(ppacher): for now we assume that the type of each element of values
|
||||||
// is the same. We also can be sure that there is always at least one value.
|
// is the same. We also can be sure that there is always at least one value.
|
||||||
//
|
//
|
||||||
@@ -357,10 +360,10 @@ func (match Matcher) toSQLConditionClause(ctx context.Context, suffix string, co
|
|||||||
// if this is a time column that is stored in "text" format and the provided
|
// if this is a time column that is stored in "text" format and the provided
|
||||||
// value is a number type, we need to wrap the property in a strftime() method
|
// value is a number type, we need to wrap the property in a strftime() method
|
||||||
// call.
|
// call.
|
||||||
nameStmt := colDef.Name
|
|
||||||
if colDef.IsTime && colDef.Type == sqlite.TypeText && isNumber {
|
if colDef.IsTime && colDef.Type == sqlite.TypeText && isNumber {
|
||||||
nameStmt = fmt.Sprintf("strftime('%%s', %s)+0", nameStmt)
|
nameStmt = fmt.Sprintf("strftime('%%s', %s)+0", nameStmt)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(placeholder) == 1 && !list {
|
if len(placeholder) == 1 && !list {
|
||||||
queryParts = append(queryParts, fmt.Sprintf("%s %s %s", nameStmt, operator, placeholder[0]))
|
queryParts = append(queryParts, fmt.Sprintf("%s %s %s", nameStmt, operator, placeholder[0]))
|
||||||
|
|||||||
Reference in New Issue
Block a user