Skip to content

Commit

Permalink
patched criteria column in
Browse files Browse the repository at this point in the history
  • Loading branch information
klarysz committed Jul 13, 2022
1 parent 17f3f83 commit b636050
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestRun(t *testing.T) {
{
description: "column codec",
URI: "case003_columns_codec",
args: []string{"-N=events", "-D=sqlite3", "-X=testdata/case003_columns_codec/events.sql"},
args: []string{"-N=events", "-D=sqlite3", "-A=/tmp/datly/generator/db.db", "-X=testdata/case003_columns_codec/events.sql"},
viewURL: "/v1/api/meta/view/dev/events",
dataURL: "/v1/api/dev/events",
dataMethod: http.MethodGet,
Expand Down
23 changes: 13 additions & 10 deletions cmd/testdata/case003_columns_codec/events.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
SELECT events.*,
name,
(CASE
WHEN COLUMN_X = 1 THEN
'x1,x2'
WHEN COLUMN_X = 2 THEN
'x3,x4'
ELSE ''
END) AS slice /* {"Codec":{"Ref":"AsStrings"}} */
FROM events as events
SELECT events.*
-- event_type.*
FROM (
SELECT id,
name,
(CASE
WHEN COLUMN_X = 1 THEN
'x1,x2'
WHEN COLUMN_X = 2 THEN
'x3,x4'
END) AS slice /* {"Codec":{"Ref":"AsStrings"}} */
FROM events
) events
5 changes: 4 additions & 1 deletion cmd/testdata/case003_columns_codec/log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}
---------- connections: -----------
mem://localhost/dev/Datly/dependencies/connections.yamlConnectors:
- DSN: ${Username}:${Password}@tcp(localhost:3306)/dev?parseTime=true
- DSN: /tmp/datly/generator/db.db
Driver: sqlite3
Name: dev
Secret:
Expand All @@ -48,6 +48,7 @@ Resource:
- CaseFormat: lc
Connector:
Ref: dev
FromURL: events_from.sql
Name: events
Selector:
Constraints:
Expand All @@ -60,6 +61,7 @@ Resource:
Projection: true
Limit: 40
Table: events
UseBindingPositions: true
Routes:
- Cardinality: Many
CaseFormat: lc
Expand All @@ -73,6 +75,7 @@ Routes:
- '*'
ExposeHeaders:
- '*'
EnableAudit: false
Method: GET
Namespace:
ev: events
Expand Down
7 changes: 6 additions & 1 deletion router/criteria/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ func matchDataSet(cursor *parsly.Cursor, columns view.ColumnIndex, column *view.
return dataSetCursor.NewError(comaMatcher)
}

if err := matchFieldValue(valueCursor, columns, column.ColumnType(), column.Format, buffer, placeholders, methods); err != nil {
columnType := column.ColumnType()
if columnType.Kind() == reflect.Ptr {
columnType = columnType.Elem()
}

if err := matchFieldValue(valueCursor, columns, columnType, column.Format, buffer, placeholders, methods); err != nil {
return err
}

Expand Down

0 comments on commit b636050

Please sign in to comment.