Skip to content

Commit 9dd7865

Browse files
authored
Merge pull request #11 from funktechno/f/lastlink
F/lastlink expose more parser methods
2 parents f534f41 + 371f513 commit 9dd7865

4 files changed

Lines changed: 210 additions & 16 deletions

File tree

client/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// sqlsimpleparser client
2+
import { SqlSimpleParser } from "../src";
3+
4+
interface Window {
5+
sqlsimpleparser: SqlSimpleParser;
6+
}
7+
8+
declare let window: Window;
9+
window.sqlsimpleparser = new SqlSimpleParser;

package-lock.json

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"test:watch": "jest --watchAll",
1414
"lint": "eslint",
1515
"build": "tsc",
16-
"build:client": "browserify src/index.ts -p [ tsify --noImplicitAny ] > dist/sqlsimpleparser.js"
16+
"build:help": "tsc --help",
17+
"build:drawio": "tsc ./src/index.ts --moduleResolution node --outFile ./lib/single.js --module amd",
18+
"build:client": "browserify client/index.ts -p [ tsify --noImplicitAny ] > dist/sqlsimpleparser.js"
1719
},
1820
"author": "lastlink",
1921
"license": "MIT",
@@ -29,6 +31,7 @@
2931
"jest": "^29.0.3",
3032
"jest-junit": "^12.0.0",
3133
"jest-serial-runner": "^1.1.0",
34+
"tsify": "^5.0.2",
3235
"ts-jest": "^29.0.1",
3336
"ts-node": "^10.9.1",
3437
"typescript": "^4.8.3"

src/index.ts

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -485,20 +485,6 @@ export class SqlSimpleParser {
485485
}
486486
return new RegExp("//(.+)/.*/", "//.+/(.*)/");
487487
}
488-
private GetColumnQuantifiers() {
489-
let chars: ColumnQuantifiers = {
490-
Start: '"',
491-
End: '"',
492-
};
493-
if (this.dialect == "mysql") {
494-
chars.Start = "`";
495-
chars.End = "`";
496-
} else if (this.dialect == "sqlserver") {
497-
chars.Start = "[";
498-
chars.End = "]";
499-
}
500-
return chars;
501-
}
502488

503489
private CreatePrimaryKey(
504490
primaryKeyName: string,
@@ -774,7 +760,43 @@ export class SqlSimpleParser {
774760
private static isQuoteChar(char: string): boolean {
775761
return char === '"' || char === "'" || char === "`";
776762
}
777-
763+
/**
764+
* return text quantifiers for dialect
765+
* @returns json
766+
*/
767+
GetColumnQuantifiers() {
768+
let chars: ColumnQuantifiers = {
769+
Start: '"',
770+
End: '"',
771+
};
772+
if (this.dialect == "mysql") {
773+
chars.Start = "`";
774+
chars.End = "`";
775+
} else if (this.dialect == "sqlserver") {
776+
chars.Start = "[";
777+
chars.End = "]";
778+
}
779+
return chars;
780+
}
781+
ToTableList() {
782+
return this.tableList;
783+
}
784+
ToPrimaryKeyList() {
785+
return this.primaryKeyList;
786+
}
787+
ToForeignKeyList() {
788+
return this.foreignKeyList;
789+
}
790+
ResetModel() {
791+
this.tableList = [];
792+
this.primaryKeyList = [];
793+
this.foreignKeyList = [];
794+
return this;
795+
}
796+
/**
797+
* return full sql model
798+
* @returns
799+
*/
778800
ToModel(): DatabaseModel {
779801
return {
780802
TableList: this.tableList,

0 commit comments

Comments
 (0)