Skip to content

Commit cf8b110

Browse files
committed
fix: key reserved word in sqlite
1 parent abd5ca0 commit cf8b110

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

pegjs/sqlite.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'JOIN': true,
4747
// 'JSON': true,
4848

49-
'KEY': true,
49+
// 'KEY': true,
5050

5151
'LEFT': true,
5252
'LIKE': true,

test/sqlite.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ describe('sqlite', () => {
141141
expect(getParsedSql(sql)).to.be.equal('SELECT * FROM "a" UNION DISTINCT SELECT * FROM "b"')
142142
})
143143

144-
it('should support keyword as column name in create table sql', () => {
144+
it('should support keyword as column name in sql', () => {
145145
let sql = 'CREATE TABLE IF NOT EXISTS "Test" (Id INTEGER NOT NULL PRIMARY KEY UNIQUE, like TEXT NOT NULL, Difficulty TEXT, percent real, PRIMARY KEY(Id));'
146146
expect(getParsedSql(sql)).to.be.equal('CREATE TABLE IF NOT EXISTS "Test" ("Id" INTEGER NOT NULL PRIMARY KEY UNIQUE, "like" TEXT NOT NULL, "Difficulty" TEXT, "percent" REAL, PRIMARY KEY ("Id"))')
147147
sql = "SELECT * from tb WHERE NOT EXISTS (SELECT * FROM tb WHERE field1 = 'c' AND field2 = d)"
148148
expect(getParsedSql(sql)).to.be.equal(`SELECT * FROM "tb" WHERE NOT EXISTS (SELECT * FROM "tb" WHERE "field1" = 'c' AND "field2" = "d")`)
149+
sql = 'SELECT * FROM tb WHERE key="foo"'
150+
expect(getParsedSql(sql)).to.be.equal('SELECT * FROM "tb" WHERE "key" = "foo"')
149151
})
150152

151153
it('should support sqlify autoincrement to other db', () => {

0 commit comments

Comments
 (0)