@dbml/core 2.4.3 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/export/PostgresExporter.js +6 -3
- package/lib/model_structure/database.js +5 -2
- package/lib/model_structure/enum.js +2 -1
- package/lib/model_structure/enumValue.js +2 -1
- package/lib/model_structure/field.js +4 -3
- package/lib/model_structure/indexes.js +2 -1
- package/lib/model_structure/schema.js +2 -3
- package/lib/model_structure/table.js +2 -1
- package/lib/parse/dbml/parser.pegjs +12 -2
- package/lib/parse/dbmlParser.js +434 -428
- package/lib/parse/mssql/statements/actions.js +10 -6
- package/lib/parse/mssql/statements/statement_types/comments/actions.js +23 -23
- package/lib/parse/mysql/parser.pegjs +9 -9
- package/lib/parse/mysqlParser.js +95 -20
- package/lib/parse/postgresParser.js +6 -6
- package/lib/parse/postgresql/Base_rules.pegjs +1 -0
- package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +8 -6
- package/lib/parse/postgresql/parser.pegjs +2 -2
- package/package.json +2 -2
- package/types/.DS_Store +0 -0
- package/types/model_structure/database.d.ts +3 -2
- package/types/model_structure/element.d.ts +6 -0
- package/types/model_structure/enum.d.ts +3 -2
- package/types/model_structure/enumValue.d.ts +3 -2
- package/types/model_structure/field.d.ts +6 -2
- package/types/model_structure/indexes.d.ts +3 -2
- package/types/model_structure/schema.d.ts +3 -2
- package/types/model_structure/table.d.ts +3 -2
|
@@ -101,6 +101,7 @@ data_type "VALID TYPE" = c1:"CHARACTER"i _ c2:"VARYING"i _ args:("("expression")
|
|
|
101
101
|
args: null
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
|
|
104
105
|
type_name = pathName:path_name? c:(character)+ _ args:("(" expression ")")? {
|
|
105
106
|
let type_name = c.join("");
|
|
106
107
|
args = args ? args[1] : null;
|
|
@@ -94,13 +94,12 @@ table_property =
|
|
|
94
94
|
}
|
|
95
95
|
/ column_name:column_name __ data_type:data_type (__ COLLATE __ collation:identifier)? column_constraints:(_ column_constraint)* {
|
|
96
96
|
const column = { name: column_name , type: data_type};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
const columnTypeName = column.type.type_name.toLowerCase();
|
|
98
|
+
const serialIncrementType = new Set(['serial', 'smallserial', 'bigserial']);
|
|
99
|
+
// process type for increment
|
|
100
|
+
if (serialIncrementType.has(columnTypeName)) {
|
|
101
101
|
column.increment = true;
|
|
102
102
|
}
|
|
103
|
-
|
|
104
103
|
// map from grammar to right object
|
|
105
104
|
column_constraints = column_constraints.map(c => c[1]);
|
|
106
105
|
// process column_constraints
|
|
@@ -109,6 +108,9 @@ table_property =
|
|
|
109
108
|
case "not_null":
|
|
110
109
|
column.not_null = value;
|
|
111
110
|
break;
|
|
111
|
+
case "increment":
|
|
112
|
+
column.increment = true;
|
|
113
|
+
break;
|
|
112
114
|
case "dbdefault":
|
|
113
115
|
column.dbdefault = value;
|
|
114
116
|
break;
|
|
@@ -138,7 +140,7 @@ column_constraint = constraint_name:(CONSTRAINT __ constraint_name:identifier __
|
|
|
138
140
|
/ NULL { return { type: "not_null" , value: false } }
|
|
139
141
|
/ CHECK _ "("_ expression _")" (__ NO __ INHERIT)? { return { type: "not_supported" } }
|
|
140
142
|
/ DEFAULT __ default_expr:default_expr { return { type: "dbdefault", value: default_expr } }
|
|
141
|
-
/ GENERATED __ (ALWAYS/ BY __ DEFAULT) __ AS __ IDENTITY { return { type: "
|
|
143
|
+
/ GENERATED __ (ALWAYS/ BY __ DEFAULT) __ AS __ IDENTITY { return { type: "increment" } } // (_ "("_ sequence_options _ ")")? { return { type: "not_supported" } }
|
|
142
144
|
/ UNIQUE (__ index_parameters)? { return { type: "unique" } }
|
|
143
145
|
/ PRIMARY_KEY (__ index_parameters)? { return { type: "pk" } }
|
|
144
146
|
/ REFERENCES __ reftable:table_name refcolumn:(_ "(" _ refcolumn:column_name _ ")" {return refcolumn})? (__ MATCH __ FULL/__ MATCH __ PARTIAL/__ MATCH __ SIMPLE)?
|
|
@@ -112,14 +112,14 @@ parser = commands:command* {
|
|
|
112
112
|
const foundTable = findTable(schemaName, tableName);
|
|
113
113
|
if (foundTable) {
|
|
114
114
|
const foundField = findField(foundTable, columnName);
|
|
115
|
-
if (foundField) foundField.note = value.text;
|
|
115
|
+
if (foundField) foundField.note = value.text ? { value: value.text } : null;
|
|
116
116
|
}
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
119
119
|
case "table": {
|
|
120
120
|
const { schemaName, name: tableName } = value.table_name;
|
|
121
121
|
const foundTable = findTable(schemaName, tableName);
|
|
122
|
-
if (foundTable) foundTable.note = value.text;
|
|
122
|
+
if (foundTable) foundTable.note = value.text ? { value: value.text } : null;
|
|
123
123
|
break;
|
|
124
124
|
}
|
|
125
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Holistics <dev@holistics.io>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"\\.(?!json$)[^.]*$": "jest-raw-loader"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "b78340400449b8ef88f785556916a3a91c925c9a"
|
|
60
60
|
}
|
package/types/.DS_Store
ADDED
|
Binary file
|
|
@@ -3,7 +3,7 @@ import Ref, { NormalizedRef } from './ref';
|
|
|
3
3
|
import Enum, { NormalizedEnum } from './enum';
|
|
4
4
|
import TableGroup, { NormalizedTableGroup } from './tableGroup';
|
|
5
5
|
import Table, { NormalizedTable } from './table';
|
|
6
|
-
import Element from './element';
|
|
6
|
+
import Element, { RawNote, Token } from './element';
|
|
7
7
|
import DbState from './dbState';
|
|
8
8
|
import { NormalizedEndpoint } from './endpoint';
|
|
9
9
|
import { NormalizedEnumValue } from './enumValue';
|
|
@@ -11,7 +11,7 @@ import { NormalizedField } from './field';
|
|
|
11
11
|
import { NormalizedIndexColumn } from './indexColumn';
|
|
12
12
|
import { NormalizedIndex } from './indexes';
|
|
13
13
|
export interface Project {
|
|
14
|
-
note:
|
|
14
|
+
note: RawNote;
|
|
15
15
|
database_type: string;
|
|
16
16
|
name: string;
|
|
17
17
|
}
|
|
@@ -28,6 +28,7 @@ declare class Database extends Element {
|
|
|
28
28
|
hasDefaultSchema: boolean;
|
|
29
29
|
schemas: Schema[];
|
|
30
30
|
note: string;
|
|
31
|
+
noteToken: Token;
|
|
31
32
|
databaseType: string;
|
|
32
33
|
name: string;
|
|
33
34
|
id: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NormalizedDatabase } from './database';
|
|
2
2
|
import DbState from './dbState';
|
|
3
|
-
import Element, { Token } from './element';
|
|
3
|
+
import Element, { Token, RawNote } from './element';
|
|
4
4
|
import EnumValue from './enumValue';
|
|
5
5
|
import Field from './field';
|
|
6
6
|
import Schema from './schema';
|
|
@@ -8,7 +8,7 @@ interface RawEnum {
|
|
|
8
8
|
name: string;
|
|
9
9
|
token: Token;
|
|
10
10
|
values: EnumValue[];
|
|
11
|
-
note:
|
|
11
|
+
note: RawNote;
|
|
12
12
|
schema: Schema;
|
|
13
13
|
}
|
|
14
14
|
declare class Enum extends Element {
|
|
@@ -16,6 +16,7 @@ declare class Enum extends Element {
|
|
|
16
16
|
token: Token;
|
|
17
17
|
values: EnumValue[];
|
|
18
18
|
note: string;
|
|
19
|
+
noteToken: Token;
|
|
19
20
|
schema: Schema;
|
|
20
21
|
fields: Field[];
|
|
21
22
|
dbState: DbState;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { NormalizedDatabase } from './database';
|
|
2
2
|
import DbState from './dbState';
|
|
3
|
-
import Element, { Token } from './element';
|
|
3
|
+
import Element, { Token, RawNote } from './element';
|
|
4
4
|
import Enum from './enum';
|
|
5
5
|
interface RawEnumValue {
|
|
6
6
|
name: string;
|
|
7
7
|
token: Token;
|
|
8
|
-
note:
|
|
8
|
+
note: RawNote;
|
|
9
9
|
_enum: Enum;
|
|
10
10
|
}
|
|
11
11
|
declare class EnumValue extends Element {
|
|
12
12
|
name: string;
|
|
13
13
|
note: string;
|
|
14
|
+
noteToken: Token;
|
|
14
15
|
_enum: Enum;
|
|
15
16
|
dbState: DbState;
|
|
16
17
|
constructor({ name, token, note, _enum }: RawEnumValue);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NormalizedDatabase } from './database';
|
|
2
2
|
import DbState from './dbState';
|
|
3
|
-
import Element, { Token } from './element';
|
|
3
|
+
import Element, { Token, RawNote } from './element';
|
|
4
4
|
import Endpoint from './endpoint';
|
|
5
5
|
import Enum from './enum';
|
|
6
6
|
import Table from './table';
|
|
@@ -11,7 +11,7 @@ interface RawField {
|
|
|
11
11
|
pk: boolean;
|
|
12
12
|
token: Token;
|
|
13
13
|
not_null: boolean;
|
|
14
|
-
note:
|
|
14
|
+
note: RawNote;
|
|
15
15
|
dbdefault: any;
|
|
16
16
|
increment: boolean;
|
|
17
17
|
table: Table;
|
|
@@ -24,6 +24,7 @@ declare class Field extends Element {
|
|
|
24
24
|
dbState: DbState;
|
|
25
25
|
not_null: boolean;
|
|
26
26
|
note: string;
|
|
27
|
+
noteToken: Token;
|
|
27
28
|
dbdefault: any;
|
|
28
29
|
increment: boolean;
|
|
29
30
|
table: Table;
|
|
@@ -72,6 +73,9 @@ export interface NormalizedField {
|
|
|
72
73
|
note: string;
|
|
73
74
|
dbdefault: any;
|
|
74
75
|
increment: boolean;
|
|
76
|
+
tableId: number;
|
|
77
|
+
endpointIds: number[];
|
|
78
|
+
enumId: number;
|
|
75
79
|
};
|
|
76
80
|
}
|
|
77
81
|
export default Field;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NormalizedDatabase } from './database';
|
|
2
2
|
import DbState from './dbState';
|
|
3
|
-
import Element, { Token } from './element';
|
|
3
|
+
import Element, { RawNote, Token } from './element';
|
|
4
4
|
import IndexColumn from './indexColumn';
|
|
5
5
|
import Table from './table';
|
|
6
6
|
interface RawIndex {
|
|
@@ -9,7 +9,7 @@ interface RawIndex {
|
|
|
9
9
|
unique: boolean;
|
|
10
10
|
pk: string;
|
|
11
11
|
name: string;
|
|
12
|
-
note:
|
|
12
|
+
note: RawNote;
|
|
13
13
|
table: Table;
|
|
14
14
|
token: Token;
|
|
15
15
|
}
|
|
@@ -20,6 +20,7 @@ declare class Index extends Element {
|
|
|
20
20
|
pk: string;
|
|
21
21
|
name: string;
|
|
22
22
|
note: string;
|
|
23
|
+
noteToken: Token;
|
|
23
24
|
table: Table;
|
|
24
25
|
dbState: DbState;
|
|
25
26
|
constructor({ columns, type, unique, pk, token, name, note, table }: RawIndex);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Table from './table';
|
|
2
|
-
import Element, { Token } from './element';
|
|
2
|
+
import Element, { RawNote, Token } from './element';
|
|
3
3
|
import Enum from './enum';
|
|
4
4
|
import TableGroup from './tableGroup';
|
|
5
5
|
import Ref from './ref';
|
|
@@ -8,7 +8,7 @@ import DbState from './dbState';
|
|
|
8
8
|
export interface RawSchema {
|
|
9
9
|
name: string;
|
|
10
10
|
alias?: string;
|
|
11
|
-
note?:
|
|
11
|
+
note?: RawNote;
|
|
12
12
|
tables?: Table[];
|
|
13
13
|
refs?: Ref[];
|
|
14
14
|
enums?: Enum[];
|
|
@@ -20,6 +20,7 @@ declare class Schema extends Element {
|
|
|
20
20
|
name: string;
|
|
21
21
|
alias: string;
|
|
22
22
|
note: string;
|
|
23
|
+
noteToken: Token;
|
|
23
24
|
tables: Table[];
|
|
24
25
|
refs: Ref[];
|
|
25
26
|
enums: Enum[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Element, { Token } from './element';
|
|
1
|
+
import Element, { RawNote, Token } from './element';
|
|
2
2
|
import Field from './field';
|
|
3
3
|
import Index from './indexes';
|
|
4
4
|
import Schema from './schema';
|
|
@@ -8,7 +8,7 @@ import { NormalizedDatabase } from './database';
|
|
|
8
8
|
interface RawTable {
|
|
9
9
|
name: string;
|
|
10
10
|
alias: string;
|
|
11
|
-
note:
|
|
11
|
+
note: RawNote;
|
|
12
12
|
fields: Field[];
|
|
13
13
|
indexes: Index[];
|
|
14
14
|
schema: Schema;
|
|
@@ -19,6 +19,7 @@ declare class Table extends Element {
|
|
|
19
19
|
name: string;
|
|
20
20
|
alias: string;
|
|
21
21
|
note: string;
|
|
22
|
+
noteToken: Token;
|
|
22
23
|
fields: Field[];
|
|
23
24
|
indexes: Index[];
|
|
24
25
|
schema: Schema;
|