Skip to content

Commit d3ee92e

Browse files
committed
chore: add test to ensure that multiple curley braces in oneline in config block is parsed correctly
1 parent 303f8b5 commit d3ee92e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

cmd/sqlx_parser_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pre_operations {
2929
}
3030
`
3131

32+
3233
func TestSqlxParser(t *testing.T) {
3334
tests := []struct {
3435
name string
@@ -143,6 +144,51 @@ limit 100
143144
},
144145
wantErr: false,
145146
},
147+
{
148+
name: "Config block with multiple curly braces in a single line",
149+
content: `
150+
config {
151+
type: 'table',
152+
schema: 'yyy',
153+
description: 'some descrtition', bigquery: { partitionBy: "foo",
154+
clusterBy: ["bar", "baz"],
155+
}, tags: ["tag1", "tag2"] }
156+
SELECT
157+
FOO
158+
, BAR
159+
, BAZ
160+
FROM ${ref({schema:'dataset_name', name:'table_name'})}
161+
`,
162+
expected: sqlxParserMeta{
163+
numLines: 12,
164+
configBlockMeta: ConfigBlockMeta{
165+
exsists: true,
166+
startOfConfigBlock: 2,
167+
endOfConfigBlock: 7,
168+
configBlockContent: `
169+
config {
170+
type: 'table',
171+
schema: 'yyy',
172+
description: 'some descrtition', bigquery: { partitionBy: "foo",
173+
clusterBy: ["bar", "baz"],
174+
}, tags: ["tag1", "tag2"] }
175+
`,
176+
},
177+
sqlBlocksMeta: SqlBlockMeta{
178+
exsists: true,
179+
startOfSqlBlock: 8,
180+
endOfSqlBlock: 12,
181+
sqlBlockContent: `SELECT
182+
FOO
183+
, BAR
184+
, BAZ
185+
FROM ${ref({schema:'dataset_name', name:'table_name'})}
186+
`,
187+
formattedSqlBlockContent: "",
188+
},
189+
},
190+
wantErr: false,
191+
},
146192
}
147193

148194
for _, tt := range tests {

0 commit comments

Comments
 (0)