Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pegjs/sqlite.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ column_definition_opt
/ co:keyword_comment {
return { comment: co }
}
/ kc:KW_CONSTRAINT __ n:ident_without_kw_type {
return { constraint: { keyword: kc.toLowerCase(), constraint: n } }
}
/ ca:collate_expr {
return { collate: ca }
}
Expand Down
7 changes: 7 additions & 0 deletions test/sqlite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,11 @@ describe('sqlite', () => {
sql = 'CREATE INDEX if not exists schema_name.visits_url_index ON visits (url collate cn asc) where id > 10;'
expect(getParsedSql(sql)).to.be.equal('CREATE INDEX IF NOT EXISTS "schema_name"."visits_url_index" ON "visits" ("url" COLLATE cn ASC) WHERE "id" > 10')
})
it('should support constraint in create table', () => {
const sql = `CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
"MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY,
"ProductVersion" TEXT NOT NULL
);`
expect(getParsedSql(sql)).to.be.equal(`CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" ("MigrationId" TEXT NOT NULL CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY, "ProductVersion" TEXT NOT NULL)`)
})
})