Skip to content

Commit 8f43052

Browse files
authored
Merge pull request #32 from funktechno/f/lastlink
F/lastlink 0.0.7
2 parents c83f7dd + 51f17bf commit 8f43052

File tree

2 files changed

+145
-145
lines changed

2 files changed

+145
-145
lines changed

README.md

+144-144
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ var sql = `CREATE TABLE "humanresources_department" (
1616
);
1717
1818
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-
);
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+
);
2828
`
2929

3030
// run parser
@@ -38,141 +38,141 @@ const models = parser
3838
* outputs
3939
```json
4040
{
41-
"TableList": [
42-
{
43-
"Name": "humanresources_department",
44-
"Properties": [
45-
{
46-
"Name": "departmentid",
47-
"ColumnProperties": "serial NOT NULL",
48-
"TableName": "humanresources_department",
49-
"ForeignKey": [
50-
{
51-
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
52-
"PrimaryKeyName": "departmentid",
53-
"ReferencesPropertyName": "departmentid",
54-
"ReferencesTableName": "humanresources_department",
55-
"IsDestination": true
56-
}
57-
],
58-
"IsForeignKey": false,
59-
"IsPrimaryKey": true
60-
},
61-
{
62-
"Name": "name",
63-
"ColumnProperties": "Name NOT NULL",
64-
"TableName": "humanresources_department",
65-
"ForeignKey": [],
66-
"IsForeignKey": false,
67-
"IsPrimaryKey": false
68-
},
69-
{
70-
"Name": "groupname",
71-
"ColumnProperties": "Name NOT NULL",
72-
"TableName": "humanresources_department",
73-
"ForeignKey": [],
74-
"IsForeignKey": false,
75-
"IsPrimaryKey": false
76-
},
77-
{
78-
"Name": "modifieddate",
79-
"ColumnProperties": "timestamp NOT NULL",
80-
"TableName": "humanresources_department",
81-
"ForeignKey": [],
82-
"IsForeignKey": false,
83-
"IsPrimaryKey": false
84-
}
85-
]
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
164-
}
165-
],
166-
"PrimaryKeyList": [
167-
{
168-
"PrimaryKeyTableName": "humanresources_department",
169-
"PrimaryKeyName": "departmentid"
170-
},
171-
{
172-
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
173-
"PrimaryKeyName": "businessentityid,departmentid,shiftid,startdate"
174-
}
175-
]
41+
"TableList": [
42+
{
43+
"Name": "humanresources_department",
44+
"Properties": [
45+
{
46+
"Name": "departmentid",
47+
"ColumnProperties": "serial NOT NULL",
48+
"TableName": "humanresources_department",
49+
"ForeignKey": [
50+
{
51+
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
52+
"PrimaryKeyName": "departmentid",
53+
"ReferencesPropertyName": "departmentid",
54+
"ReferencesTableName": "humanresources_department",
55+
"IsDestination": true
56+
}
57+
],
58+
"IsForeignKey": false,
59+
"IsPrimaryKey": true
60+
},
61+
{
62+
"Name": "name",
63+
"ColumnProperties": "Name NOT NULL",
64+
"TableName": "humanresources_department",
65+
"ForeignKey": [],
66+
"IsForeignKey": false,
67+
"IsPrimaryKey": false
68+
},
69+
{
70+
"Name": "groupname",
71+
"ColumnProperties": "Name NOT NULL",
72+
"TableName": "humanresources_department",
73+
"ForeignKey": [],
74+
"IsForeignKey": false,
75+
"IsPrimaryKey": false
76+
},
77+
{
78+
"Name": "modifieddate",
79+
"ColumnProperties": "timestamp NOT NULL",
80+
"TableName": "humanresources_department",
81+
"ForeignKey": [],
82+
"IsForeignKey": false,
83+
"IsPrimaryKey": false
84+
}
85+
]
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
164+
}
165+
],
166+
"PrimaryKeyList": [
167+
{
168+
"PrimaryKeyTableName": "humanresources_department",
169+
"PrimaryKeyName": "departmentid"
170+
},
171+
{
172+
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
173+
"PrimaryKeyName": "businessentityid,departmentid,shiftid,startdate"
174+
}
175+
]
176176
}
177177
```
178178
* there are some [example](./examples) sql files

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@funktechno/sqlsimpleparser",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

0 commit comments

Comments
 (0)