Skip to content

Commit 62ea22b

Browse files
authored
Merge pull request #21 from funktechno/f/lastlink2
add additional links
2 parents d37753d + e6d1d91 commit 62ea22b

File tree

7 files changed

+331
-94
lines changed

7 files changed

+331
-94
lines changed

.eslintrc

+33-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": ["plugin:@typescript-eslint/recommended"],
4+
"parserOptions": {
5+
"ecmaVersion": 2018,
6+
"sourceType": "module"
7+
},
28
"rules": {
3-
"semi": ["error", "always"],
4-
"quotes": ["error", "single"]
9+
"semi": ["error", "always"],
10+
"quotes": ["error", "double"],
11+
"@typescript-eslint/explicit-function-return-type": "off",
12+
"@typescript-eslint/camelcase": "off",
13+
"@typescript-eslint/no-explicit-any": "off",
14+
"no-multiple-empty-lines": "error",
15+
"@typescript-eslint/no-inferrable-types": [
16+
"warn", {
17+
"ignoreParameters": true
18+
}
19+
],
20+
"@typescript-eslint/no-unused-vars": "warn",
21+
"@typescript-eslint/class-name-casing": "off"
522
},
6-
"extends": "eslint:recommended",
7-
"ignorePatterns": ["*.js"]
8-
}
23+
"ignorePatterns": ["src/TextHighlighter.js","lib/*","dist/*","archived"],
24+
"overrides": [
25+
{
26+
"files": [
27+
"**/__tests__/*.{j,t}s?(x)",
28+
"**/tests/**/*.spec.{j,t}s?(x)"
29+
],
30+
"env": {
31+
"jest": true
32+
}
33+
}
34+
]
35+
}
36+

README.md

+104-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ var sql = `CREATE TABLE "humanresources_department" (
1313
"groupname" Name NOT NULL,
1414
"modifieddate" timestamp NOT NULL,
1515
PRIMARY KEY("departmentid")
16-
);`
16+
);
17+
18+
CREATE TABLE "humanresources_employeedepartmenthistory" (
19+
"businessentityid" int(4) NOT NULL,
20+
"departmentid" int(2) NOT NULL,
21+
"shiftid" int(2) NOT NULL,
22+
"startdate" date NOT NULL,
23+
"enddate" date,
24+
"modifieddate" timestamp NOT NULL,
25+
PRIMARY KEY("businessentityid","departmentid","shiftid","startdate"),
26+
FOREIGN KEY ("departmentid") REFERENCES "humanresources_department"("departmentid")
27+
);
28+
`
1729

1830
// run parser
1931
const parser = new SqlSimpleParser('postgres')
@@ -34,7 +46,15 @@ const models = parser
3446
"Name": "departmentid",
3547
"ColumnProperties": "serial NOT NULL",
3648
"TableName": "humanresources_department",
37-
"ForeignKey": [],
49+
"ForeignKey": [
50+
{
51+
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
52+
"PrimaryKeyName": "departmentid",
53+
"ReferencesPropertyName": "departmentid",
54+
"ReferencesTableName": "humanresources_department",
55+
"IsDestination": true
56+
}
57+
],
3858
"IsForeignKey": false,
3959
"IsPrimaryKey": true
4060
},
@@ -63,14 +83,94 @@ const models = parser
6383
"IsPrimaryKey": false
6484
}
6585
]
86+
},
87+
{
88+
"Name": "humanresources_employeedepartmenthistory",
89+
"Properties": [
90+
{
91+
"Name": "businessentityid",
92+
"ColumnProperties": "int(4) NOT NULL",
93+
"TableName": "humanresources_employeedepartmenthistory",
94+
"ForeignKey": [],
95+
"IsForeignKey": false,
96+
"IsPrimaryKey": false
97+
},
98+
{
99+
"Name": "departmentid",
100+
"ColumnProperties": "int(2) NOT NULL",
101+
"TableName": "humanresources_employeedepartmenthistory",
102+
"ForeignKey": [
103+
{
104+
"PrimaryKeyTableName": "humanresources_department",
105+
"PrimaryKeyName": "departmentid",
106+
"ReferencesPropertyName": "departmentid",
107+
"ReferencesTableName": "humanresources_employeedepartmenthistory",
108+
"IsDestination": false
109+
}
110+
],
111+
"IsForeignKey": true,
112+
"IsPrimaryKey": false
113+
},
114+
{
115+
"Name": "shiftid",
116+
"ColumnProperties": "int(2) NOT NULL",
117+
"TableName": "humanresources_employeedepartmenthistory",
118+
"ForeignKey": [],
119+
"IsForeignKey": false,
120+
"IsPrimaryKey": false
121+
},
122+
{
123+
"Name": "startdate",
124+
"ColumnProperties": "date NOT NULL",
125+
"TableName": "humanresources_employeedepartmenthistory",
126+
"ForeignKey": [],
127+
"IsForeignKey": false,
128+
"IsPrimaryKey": false
129+
},
130+
{
131+
"Name": "enddate",
132+
"ColumnProperties": "date",
133+
"TableName": "humanresources_employeedepartmenthistory",
134+
"ForeignKey": [],
135+
"IsForeignKey": false,
136+
"IsPrimaryKey": false
137+
},
138+
{
139+
"Name": "modifieddate",
140+
"ColumnProperties": "timestamp NOT NULL",
141+
"TableName": "humanresources_employeedepartmenthistory",
142+
"ForeignKey": [],
143+
"IsForeignKey": false,
144+
"IsPrimaryKey": false
145+
}
146+
]
147+
}
148+
],
149+
"Dialect": "postgres",
150+
"ForeignKeyList": [
151+
{
152+
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
153+
"PrimaryKeyName": "departmentid",
154+
"ReferencesPropertyName": "departmentid",
155+
"ReferencesTableName": "humanresources_department",
156+
"IsDestination": true
157+
},
158+
{
159+
"PrimaryKeyTableName": "humanresources_department",
160+
"PrimaryKeyName": "departmentid",
161+
"ReferencesPropertyName": "departmentid",
162+
"ReferencesTableName": "humanresources_employeedepartmenthistory",
163+
"IsDestination": false
66164
}
67165
],
68-
"Dialect": "sqlserver",
69-
"ForeignKeyList": [],
70166
"PrimaryKeyList": [
71167
{
72168
"PrimaryKeyTableName": "humanresources_department",
73169
"PrimaryKeyName": "departmentid"
170+
},
171+
{
172+
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
173+
"PrimaryKeyName": "businessentityid,departmentid,shiftid,startdate"
74174
}
75175
]
76176
}

package.json

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@funktechno/sqlsimpleparser",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -9,18 +9,27 @@
99
},
1010
"scripts": {
1111
"test:sqlite": "npx tsx ./examples/example.sqlite.ts",
12-
"test": "jest -c ./jest.config.ts --forceExit --verbose -i --no-cache",
13-
"test:coverage": "jest --forceExit --coverage --verbose",
14-
"test:watch": "jest --watchAll",
15-
"lint": "eslint",
12+
"test": "jest -c ./jest.config.ts --forceExit --verbose -i --no-cache --detectOpenHandles",
13+
"test:coverage": "jest --forceExit --coverage --verbose --detectOpenHandles",
14+
"test:watch": "jest --watchAll --detectOpenHandles",
15+
"lint": "tsc --noEmit && eslint \"{src,client}/**/*.{js,ts}\"",
16+
"lint:fix": "tsc --noEmit && eslint \"{src,client}/**/*.{js,ts}\" --fix",
1617
"build": "tsc",
1718
"build:help": "tsc --help",
1819
"build:drawio": "tsc ./src/index.ts --moduleResolution node --outFile ./lib/single.js --module amd",
1920
"build:client": "npm run mkdir:dist && browserify client/index.ts -p [ tsify --noImplicitAny ] > dist/sqlsimpleparser.js",
2021
"mkdir:dist": "node ./build/createDistFolder.js"
2122
},
23+
"repository": {
24+
"type": "git",
25+
"url": "git+https://github.com/funktechno/sql-simple-parser.git"
26+
},
2227
"author": "lastlink",
2328
"license": "MIT",
29+
"bugs": {
30+
"url": "https://github.com/funktechno/sql-simple-parser/issues"
31+
},
32+
"homepage": "https://github.com/funktechno/sql-simple-parser#readme",
2433
"devDependencies": {
2534
"@types/jest": "^29.0.3",
2635
"@types/lodash": "^4.14.185",

src/contants.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
export const CreateTable = "create table";
44

5-
export const AlterTable = "alter table "
5+
export const AlterTable = "alter table ";
66

7-
export const CONSTRAINT = "constraint"
7+
export const CONSTRAINT = "constraint";
88

9-
export const Primary_Key = "primary key"
9+
export const Primary_Key = "primary key";
1010

11-
export const Foreign_Key = "foreign key"
11+
export const Foreign_Key = "foreign key";
1212

1313
export const CONSTRAINT_Primary_Key = "constraint primary key";
1414

0 commit comments

Comments
 (0)