Skip to content

Commit e1420bc

Browse files
committed
remove closing )
1 parent 2e60448 commit e1420bc

3 files changed

Lines changed: 71 additions & 26 deletions

File tree

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ export class SqlSimpleParser {
103103

104104
var propertyRow = tmp.toLowerCase().trim();
105105

106+
if(propertyRow == ")")
107+
continue;
108+
106109
//Parse Table
107110
if (propertyRow.indexOf(CreateTable) != -1) {
108111
//Parse row

tests/example_sqlite.spec.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/examples_models.spec.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import * as fs from "fs";
2+
import {SqlSimpleParser} from "../src/index"
3+
4+
describe("Example Sql Parsing", () => {
5+
it("Run Parser Sqlite Ex", async () => {
6+
const filePath = "examples/chinook-database-2.0.1_sqlite.sql";
7+
async function runSample() {
8+
// load sql
9+
var sql = await fs.readFileSync(filePath, "utf8");
10+
console.log(sql);
11+
12+
// run parser
13+
const parser = new SqlSimpleParser('sqlite')
14+
15+
// get models
16+
const models = parser
17+
.feed(sql)
18+
.ToModel();
19+
20+
// write to json file
21+
await fs.writeFileSync("output-sqlite.json", JSON.stringify(models, null, '\t'));
22+
}
23+
await runSample();
24+
expect(1).toBeTruthy();
25+
});
26+
it("Run Parser mysql Ex", async () => {
27+
const filePath = "examples/adventureworks_mysql.sql";
28+
async function runSample() {
29+
// load sql
30+
var sql = await fs.readFileSync(filePath, "utf8");
31+
console.log(sql);
32+
33+
// run parser
34+
const parser = new SqlSimpleParser('mysql')
35+
36+
// get models
37+
const models = parser
38+
.feed(sql)
39+
.ToModel();
40+
41+
// write to json file
42+
await fs.writeFileSync("output-mysql.json", JSON.stringify(models, null, '\t'));
43+
}
44+
await runSample();
45+
expect(1).toBeTruthy();
46+
});
47+
it("Run Parser postgres Ex", async () => {
48+
const filePath = "examples/adventureworks_pg.sql";
49+
async function runSample() {
50+
// load sql
51+
var sql = await fs.readFileSync(filePath, "utf8");
52+
console.log(sql);
53+
54+
// run parser
55+
const parser = new SqlSimpleParser('postgres')
56+
57+
// get models
58+
const models = parser
59+
.feed(sql)
60+
.ToModel();
61+
62+
// write to json file
63+
await fs.writeFileSync("output-pg.json", JSON.stringify(models, null, '\t'));
64+
}
65+
await runSample();
66+
expect(1).toBeTruthy();
67+
});
68+
});

0 commit comments

Comments
 (0)