Skip to content

Commit

Permalink
removed $. from valid template expr
Browse files Browse the repository at this point in the history
  • Loading branch information
awitas committed Mar 20, 2023
1 parent 46849ae commit 8ca3ef6
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.5.4.0
v0.5.5.0
49 changes: 49 additions & 0 deletions e2e/local/regression/cases/047_raw_json_tag/expect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{
"className": "com.class.abc.Foo",
"id": 1,
"name": "\"Foo\"",
"preferences": {
"Id": 1,
"Name": "Foo",
"Price": 125.5
}
},
{
"className": "com.class.abc.Boo",
"id": 2,
"preferences": {
"CreatedAt": "01/16/2022",
"Id": 1,
"UpdatedAt": "03/16/2022"
}
},
{
"className": "com.class.abc.Bar",
"id": 3,
"preferences": {
"Id": 1,
"Items": [
0,
"125",
250,
"275"
]
}
},
{
"className": "com.class.abc.Bar",
"id": 4,
"preferences": [
{
"Id": 1,
"Items": [
0,
"125",
250,
"275"
]
}
]
}
]
5 changes: 5 additions & 0 deletions e2e/local/regression/cases/047_raw_json_tag/gen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Name": "$tagId",
"URL": "$path/raw_json_expr.sql",
"Args": ""
}
12 changes: 12 additions & 0 deletions e2e/local/regression/cases/047_raw_json_tag/raw_json_expr.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* {"URI":"raw_json_expr"} */


SELECT main.*
FROM (
SELECT
ID as Id,
OBJECT AS Preferences /* {"DataType": "json.RawMessage"} */,
(OBJECT->'$.Name') AS Name /* {"DataType":"string"} */,
CLASS_NAME as ClassName
FROM OBJECTS
) main
13 changes: 13 additions & 0 deletions e2e/local/regression/cases/047_raw_json_tag/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
init:
parentPath: $parent.path
pipeline:

test:
action: http/runner:send
requests:
- Method: GET
URL: http://127.0.0.1:8080/v1/api/dev/raw_json_expr
Expect:
Code: 200
JSONBody: $LoadJSON('${parentPath}/expect.json')

2 changes: 1 addition & 1 deletion e2e/local/regression/regression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pipeline:
'[]gen': '@gen'

subPath: 'cases/${index}_*'
range: 1..046
range: 1..047
template:
checkSkip:
action: nop
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline:
services:
mysql_dev:
action: docker:run
image: mysql:5.6
image: mysql:5.7
platform: linux/amd64
name: mysql_dev
ports:
Expand Down
3 changes: 3 additions & 0 deletions view/parameter/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func Parse(SQL string) ([]*Value, error) {
key := text[2 : len(text)-1]
result = append(result, &Value{Key: key, TemplateFragment: text})
case selectorToken:
if cursor.Input[cursor.Pos] == '.' {
continue
}
matched = cursor.MatchOne(whitespaceTerminatorMatcher)
aKey := matched.Text(cursor)
if aKey != "" {
Expand Down

0 comments on commit 8ca3ef6

Please sign in to comment.