Skip to content

Commit ff529d0

Browse files
committed
Build cjs + deno
1 parent 28fbbaf commit ff529d0

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

cjs/src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const builders = Object.entries({
172172
).join(',') + ')values' +
173173
valuesBuilder(Array.isArray(first) ? first : [first], parameters, types, columns, options)
174174
}
175-
}).map(([x, fn]) => ([new RegExp('(^|[\\s(])' + x + '($|[\\s(])', 'i'), fn]))
175+
}).map(([x, fn]) => ([new RegExp('((?:^|[\\s(])' + x + '(?:$|[\\s(]))(?![\\s\\S]*\\1)', 'i'), fn]))
176176

177177
function notTagged() {
178178
throw Errors.generic('NOT_TAGGED_CALL', 'Query not called as a tagged template literal')

cjs/tests/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,3 +2140,16 @@ t('Does not try rollback when commit errors', async() => {
21402140
await sql`drop table test`
21412141
]
21422142
})
2143+
2144+
t('Last keyword used even with duplicate keywords', async() => {
2145+
await sql`create table test (x int);`
2146+
await sql`insert into test values(1)`
2147+
const [{ x }] = await sql`
2148+
select
2149+
1 in (1) as x
2150+
from test
2151+
where x in ${ sql([1, 2]) }
2152+
`
2153+
2154+
return [x, true]
2155+
})

deno/src/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const builders = Object.entries({
173173
).join(',') + ')values' +
174174
valuesBuilder(Array.isArray(first) ? first : [first], parameters, types, columns, options)
175175
}
176-
}).map(([x, fn]) => ([new RegExp('(^|[\\s(])' + x + '($|[\\s(])', 'i'), fn]))
176+
}).map(([x, fn]) => ([new RegExp('((?:^|[\\s(])' + x + '(?:$|[\\s(]))(?![\\s\\S]*\\1)', 'i'), fn]))
177177

178178
function notTagged() {
179179
throw Errors.generic('NOT_TAGGED_CALL', 'Query not called as a tagged template literal')

deno/tests/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,4 +2143,17 @@ t('Does not try rollback when commit errors', async() => {
21432143
]
21442144
})
21452145

2146+
t('Last keyword used even with duplicate keywords', async() => {
2147+
await sql`create table test (x int);`
2148+
await sql`insert into test values(1)`
2149+
const [{ x }] = await sql`
2150+
select
2151+
1 in (1) as x
2152+
from test
2153+
where x in ${ sql([1, 2]) }
2154+
`
2155+
2156+
return [x, true]
2157+
})
2158+
21462159
;window.addEventListener("unload", () => Deno.exit(process.exitCode))

0 commit comments

Comments
 (0)