@nocobase/database 0.19.0-alpha.6 → 0.19.0-alpha.8

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.
@@ -2,6 +2,7 @@ declare const _default: {
2
2
  postgres: {
3
3
  'character varying': string;
4
4
  varchar: string;
5
+ character: string;
5
6
  text: string;
6
7
  char: string;
7
8
  oid: string;
@@ -11,9 +12,11 @@ declare const _default: {
11
12
  bigint: string;
12
13
  decimal: string;
13
14
  numeric: string;
15
+ real: string;
14
16
  'double precision': string;
15
17
  'timestamp without time zone': string;
16
18
  'timestamp with time zone': string;
19
+ 'time without time zone': string;
17
20
  date: string;
18
21
  boolean: string;
19
22
  json: string[];
@@ -22,18 +25,30 @@ declare const _default: {
22
25
  path: string;
23
26
  polygon: string;
24
27
  circle: string;
28
+ uuid: string;
25
29
  };
26
30
  mysql: {
31
+ smallint: string[];
32
+ tinyint: string[];
33
+ mediumint: string[];
34
+ 'smallint unsigned': string[];
35
+ 'tinyint unsigned': string[];
36
+ 'mediumint unsigned': string[];
37
+ char: string;
38
+ date: string;
39
+ time: string;
27
40
  varchar: string;
28
41
  text: string;
29
42
  longtext: string;
30
43
  int: string;
44
+ 'int unsigned': string;
31
45
  integer: string;
32
46
  bigint: string;
47
+ 'bigint unsigned': string;
33
48
  float: string;
34
49
  double: string;
35
50
  boolean: string;
36
- tinyint: string;
51
+ decimal: string;
37
52
  datetime: string;
38
53
  timestamp: string;
39
54
  json: string[];
@@ -51,16 +66,27 @@ declare const _default: {
51
66
  json: string[];
52
67
  };
53
68
  mariadb: {
69
+ smallint: string[];
70
+ tinyint: string[];
71
+ mediumint: string[];
72
+ 'smallint unsigned': string[];
73
+ 'tinyint unsigned': string[];
74
+ 'mediumint unsigned': string[];
75
+ char: string;
76
+ date: string;
77
+ time: string;
54
78
  varchar: string;
55
79
  text: string;
56
80
  longtext: string;
57
81
  int: string;
82
+ 'int unsigned': string;
58
83
  integer: string;
59
84
  bigint: string;
85
+ 'bigint unsigned': string;
60
86
  float: string;
61
87
  double: string;
62
88
  boolean: string;
63
- tinyint: string;
89
+ decimal: string;
64
90
  datetime: string;
65
91
  timestamp: string;
66
92
  json: string[];
@@ -23,6 +23,7 @@ module.exports = __toCommonJS(field_type_map_exports);
23
23
  const postgres = {
24
24
  "character varying": "string",
25
25
  varchar: "string",
26
+ character: "string",
26
27
  text: "text",
27
28
  char: "string",
28
29
  oid: "string",
@@ -30,31 +31,45 @@ const postgres = {
30
31
  smallint: "integer",
31
32
  integer: "integer",
32
33
  bigint: "bigInt",
33
- decimal: "float",
34
+ decimal: "decimal",
34
35
  numeric: "float",
36
+ real: "float",
35
37
  "double precision": "float",
36
38
  "timestamp without time zone": "date",
37
39
  "timestamp with time zone": "date",
40
+ "time without time zone": "time",
38
41
  date: "date",
39
42
  boolean: "boolean",
40
43
  json: ["json", "array"],
41
44
  jsonb: ["json", "array", "jsonb"],
42
- point: "point",
43
- path: "lineString",
44
- polygon: "polygon",
45
- circle: "circle"
45
+ point: "json",
46
+ path: "json",
47
+ polygon: "json",
48
+ circle: "json",
49
+ uuid: "string"
46
50
  };
47
51
  const mysql = {
52
+ smallint: ["integer", "boolean"],
53
+ tinyint: ["integer", "boolean"],
54
+ mediumint: ["integer", "boolean"],
55
+ "smallint unsigned": ["integer", "boolean"],
56
+ "tinyint unsigned": ["integer", "boolean"],
57
+ "mediumint unsigned": ["integer", "boolean"],
58
+ char: "string",
59
+ date: "date",
60
+ time: "time",
48
61
  varchar: "string",
49
62
  text: "text",
50
63
  longtext: "text",
51
64
  int: "integer",
65
+ "int unsigned": "integer",
52
66
  integer: "integer",
53
67
  bigint: "bigInt",
68
+ "bigint unsigned": "bigInt",
54
69
  float: "float",
55
70
  double: "float",
56
71
  boolean: "boolean",
57
- tinyint: "integer",
72
+ decimal: "decimal",
58
73
  datetime: "date",
59
74
  timestamp: "date",
60
75
  json: ["json", "array"]
@@ -8,6 +8,7 @@ type InferredFieldResult = {
8
8
  [key: string]: InferredField;
9
9
  };
10
10
  export declare class ViewFieldInference {
11
+ static extractTypeFromDefinition(typeDefinition: any): any;
11
12
  static inferFields(options: {
12
13
  db: Database;
13
14
  viewName: string;
@@ -34,6 +34,13 @@ module.exports = __toCommonJS(view_inference_exports);
34
34
  var import_mathjs = require("mathjs");
35
35
  var import_field_type_map = __toESM(require("./field-type-map"));
36
36
  const _ViewFieldInference = class _ViewFieldInference {
37
+ static extractTypeFromDefinition(typeDefinition) {
38
+ const leftParenIndex = typeDefinition.indexOf("(");
39
+ if (leftParenIndex === -1) {
40
+ return typeDefinition.toLowerCase();
41
+ }
42
+ return typeDefinition.substring(0, leftParenIndex).toLowerCase().trim();
43
+ }
37
44
  static async inferFields(options) {
38
45
  const { db } = options;
39
46
  if (!db.inDialect("postgres")) {
@@ -120,7 +127,7 @@ const _ViewFieldInference = class _ViewFieldInference {
120
127
  possibleTypes: Object.keys(fieldTypeMap)
121
128
  };
122
129
  }
123
- const queryType = options.type.toLowerCase().replace(/\(\d+\)/, "");
130
+ const queryType = this.extractTypeFromDefinition(options.type);
124
131
  const mappedType = fieldTypeMap[queryType];
125
132
  if ((0, import_mathjs.isArray)(mappedType)) {
126
133
  return {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "0.19.0-alpha.6",
3
+ "version": "0.19.0-alpha.8",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "Apache-2.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "0.19.0-alpha.6",
10
- "@nocobase/utils": "0.19.0-alpha.6",
9
+ "@nocobase/logger": "0.19.0-alpha.8",
10
+ "@nocobase/utils": "0.19.0-alpha.8",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -35,5 +35,5 @@
35
35
  "url": "git+https://github.com/nocobase/nocobase.git",
36
36
  "directory": "packages/database"
37
37
  },
38
- "gitHead": "2eb524db98c7f4136fe1a9a1b1259cd72cf6635f"
38
+ "gitHead": "b8fbe613e320e40ebf2da1bf64907eab0197b589"
39
39
  }