Add support for free-text search and minor bug fixes in netquery

This commit is contained in:
Patrick Pacher 2022-05-17 08:59:18 +02:00
parent bef911e925
commit 15f85b5ae9
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D
6 changed files with 109 additions and 15 deletions

View file

@ -152,7 +152,7 @@ func (req *QueryRequestPayload) generateSQL(ctx context.Context, schema *orm.Tab
orm.DefaultEncodeConfig,
)
if err != nil {
return "", nil, fmt.Errorf("ganerating where clause: %w", err)
return "", nil, fmt.Errorf("generating where clause: %w", err)
}
if req.paramMap == nil {
@ -163,8 +163,24 @@ func (req *QueryRequestPayload) generateSQL(ctx context.Context, schema *orm.Tab
req.paramMap[key] = val
}
// build the actual SQL query statement
// FIXME(ppacher): add support for group-by and sort-by
if req.TextSearch != nil {
textClause, textParams, err := req.TextSearch.toSQLConditionClause(ctx, schema, "", orm.DefaultEncodeConfig)
if err != nil {
return "", nil, fmt.Errorf("generating text-search clause: %w", err)
}
if textClause != "" {
if whereClause != "" {
whereClause += " AND "
}
whereClause += textClause
for key, val := range textParams {
req.paramMap[key] = val
}
}
}
groupByClause, err := req.generateGroupByClause(schema)
if err != nil {