Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:funktechno/sql-simple-parser into f/…
Browse files Browse the repository at this point in the history
…lastlink2
  • Loading branch information
lastlink committed Jun 22, 2024
2 parents 7ef797c + 09a2d3e commit 54290b0
Show file tree
Hide file tree
Showing 5 changed files with 20,752 additions and 20,439 deletions.
300 changes: 156 additions & 144 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ var sql = `CREATE TABLE "humanresources_department" (
);
CREATE TABLE "humanresources_employeedepartmenthistory" (
"businessentityid" int(4) NOT NULL,
"departmentid" int(2) NOT NULL,
"shiftid" int(2) NOT NULL,
"startdate" date NOT NULL,
"enddate" date,
"modifieddate" timestamp NOT NULL,
PRIMARY KEY("businessentityid","departmentid","shiftid","startdate"),
FOREIGN KEY ("departmentid") REFERENCES "humanresources_department"("departmentid")
);
"businessentityid" int(4) NOT NULL,
"departmentid" int(2) NOT NULL,
"shiftid" int(2) NOT NULL,
"startdate" date NOT NULL,
"enddate" date,
"modifieddate" timestamp NOT NULL,
PRIMARY KEY("businessentityid","departmentid","shiftid","startdate"),
FOREIGN KEY ("departmentid") REFERENCES "humanresources_department"("departmentid")
);
`

// run parser
Expand All @@ -38,141 +38,153 @@ const models = parser
* outputs
```json
{
"TableList": [
{
"Name": "humanresources_department",
"Properties": [
{
"Name": "departmentid",
"ColumnProperties": "serial NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_department",
"IsDestination": true
}
],
"IsForeignKey": false,
"IsPrimaryKey": true
},
{
"Name": "name",
"ColumnProperties": "Name NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "groupname",
"ColumnProperties": "Name NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "modifieddate",
"ColumnProperties": "timestamp NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
}
]
},
{
"Name": "humanresources_employeedepartmenthistory",
"Properties": [
{
"Name": "businessentityid",
"ColumnProperties": "int(4) NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "departmentid",
"ColumnProperties": "int(2) NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [
{
"PrimaryKeyTableName": "humanresources_department",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_employeedepartmenthistory",
"IsDestination": false
}
],
"IsForeignKey": true,
"IsPrimaryKey": false
},
{
"Name": "shiftid",
"ColumnProperties": "int(2) NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "startdate",
"ColumnProperties": "date NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "enddate",
"ColumnProperties": "date",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "modifieddate",
"ColumnProperties": "timestamp NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
}
]
}
],
"Dialect": "postgres",
"ForeignKeyList": [
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_department",
"IsDestination": true
},
{
"PrimaryKeyTableName": "humanresources_department",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_employeedepartmenthistory",
"IsDestination": false
}
],
"PrimaryKeyList": [
{
"PrimaryKeyTableName": "humanresources_department",
"PrimaryKeyName": "departmentid"
},
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "businessentityid,departmentid,shiftid,startdate"
}
]
"TableList": [
{
"Name": "humanresources_department",
"Properties": [
{
"Name": "departmentid",
"ColumnProperties": "serial NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_department",
"IsDestination": true
}
],
"IsForeignKey": false,
"IsPrimaryKey": true
},
{
"Name": "name",
"ColumnProperties": "Name NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "groupname",
"ColumnProperties": "Name NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "modifieddate",
"ColumnProperties": "timestamp NOT NULL",
"TableName": "humanresources_department",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
}
]
},
{
"Name": "humanresources_employeedepartmenthistory",
"Properties": [
{
"Name": "businessentityid",
"ColumnProperties": "int(4) NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": true
},
{
"Name": "departmentid",
"ColumnProperties": "int(2) NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [
{
"PrimaryKeyTableName": "humanresources_department",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_employeedepartmenthistory",
"IsDestination": false
}
],
"IsForeignKey": true,
"IsPrimaryKey": true
},
{
"Name": "shiftid",
"ColumnProperties": "int(2) NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": true
},
{
"Name": "startdate",
"ColumnProperties": "date NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": true
},
{
"Name": "enddate",
"ColumnProperties": "date",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
},
{
"Name": "modifieddate",
"ColumnProperties": "timestamp NOT NULL",
"TableName": "humanresources_employeedepartmenthistory",
"ForeignKey": [],
"IsForeignKey": false,
"IsPrimaryKey": false
}
]
}
],
"Dialect": "postgres",
"ForeignKeyList": [
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_department",
"IsDestination": true
},
{
"PrimaryKeyTableName": "humanresources_department",
"PrimaryKeyName": "departmentid",
"ReferencesPropertyName": "departmentid",
"ReferencesTableName": "humanresources_employeedepartmenthistory",
"IsDestination": false
}
],
"PrimaryKeyList": [
{
"PrimaryKeyTableName": "humanresources_department",
"PrimaryKeyName": "departmentid"
},
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "businessentityid"
},
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "departmentid"
},
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "shiftid"
},
{
"PrimaryKeyTableName": "humanresources_employeedepartmenthistory",
"PrimaryKeyName": "startdate"
}
]
}
```
* there are some [example](./examples) sql files
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@funktechno/sqlsimpleparser",
"version": "0.0.6",
"version": "0.0.9",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -24,6 +24,18 @@
"type": "git",
"url": "git+https://github.com/funktechno/sql-simple-parser.git"
},
"keywords": [
"typescript",
"sql",
"draw.io",
"diagram",
"UML",
"plugins",
"erdiagram",
"sql-parser",
"plugins",
"sql-ddl"
],
"author": "lastlink",
"license": "MIT",
"bugs": {
Expand Down
Loading

0 comments on commit 54290b0

Please sign in to comment.