relq 1.0.61 → 1.0.62
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.
|
@@ -46,6 +46,22 @@ function parseOptionsArray(options) {
|
|
|
46
46
|
}
|
|
47
47
|
return result;
|
|
48
48
|
}
|
|
49
|
+
function mapInternalToFriendlyType(internalType) {
|
|
50
|
+
const typeMap = {
|
|
51
|
+
'int2': 'smallint',
|
|
52
|
+
'int4': 'integer',
|
|
53
|
+
'int8': 'bigint',
|
|
54
|
+
'float4': 'real',
|
|
55
|
+
'float8': 'double precision',
|
|
56
|
+
'bool': 'boolean',
|
|
57
|
+
'timestamptz': 'timestamp with time zone',
|
|
58
|
+
'timetz': 'time with time zone',
|
|
59
|
+
'varchar': 'character varying',
|
|
60
|
+
'bpchar': 'character',
|
|
61
|
+
'varbit': 'bit varying',
|
|
62
|
+
};
|
|
63
|
+
return typeMap[internalType] || internalType;
|
|
64
|
+
}
|
|
49
65
|
async function fastIntrospectDatabase(connection, onProgress, options) {
|
|
50
66
|
const { includeFunctions = false, includeTriggers = false, onDetailedProgress } = options || {};
|
|
51
67
|
const { Pool } = await Promise.resolve().then(() => __importStar(require("../../addon/pg/index.cjs")));
|
|
@@ -215,9 +231,21 @@ async function fastIntrospectDatabase(connection, onProgress, options) {
|
|
|
215
231
|
if (!columnsByTable.has(col.table_name)) {
|
|
216
232
|
columnsByTable.set(col.table_name, []);
|
|
217
233
|
}
|
|
234
|
+
let dataType = col.data_type;
|
|
235
|
+
if (dataType === 'ARRAY' && col.udt_name) {
|
|
236
|
+
const baseType = col.udt_name.startsWith('_') ? col.udt_name.slice(1) : col.udt_name;
|
|
237
|
+
const friendlyBase = mapInternalToFriendlyType(baseType);
|
|
238
|
+
dataType = `${friendlyBase}[]`;
|
|
239
|
+
}
|
|
240
|
+
else if (dataType === 'USER-DEFINED' && col.udt_name) {
|
|
241
|
+
dataType = col.udt_name;
|
|
242
|
+
}
|
|
243
|
+
else if (col.udt_name) {
|
|
244
|
+
dataType = col.udt_name;
|
|
245
|
+
}
|
|
218
246
|
columnsByTable.get(col.table_name).push({
|
|
219
247
|
name: col.column_name,
|
|
220
|
-
dataType
|
|
248
|
+
dataType,
|
|
221
249
|
isNullable: col.is_nullable,
|
|
222
250
|
defaultValue: col.column_default,
|
|
223
251
|
isPrimaryKey: false,
|
|
@@ -10,6 +10,22 @@ function parseOptionsArray(options) {
|
|
|
10
10
|
}
|
|
11
11
|
return result;
|
|
12
12
|
}
|
|
13
|
+
function mapInternalToFriendlyType(internalType) {
|
|
14
|
+
const typeMap = {
|
|
15
|
+
'int2': 'smallint',
|
|
16
|
+
'int4': 'integer',
|
|
17
|
+
'int8': 'bigint',
|
|
18
|
+
'float4': 'real',
|
|
19
|
+
'float8': 'double precision',
|
|
20
|
+
'bool': 'boolean',
|
|
21
|
+
'timestamptz': 'timestamp with time zone',
|
|
22
|
+
'timetz': 'time with time zone',
|
|
23
|
+
'varchar': 'character varying',
|
|
24
|
+
'bpchar': 'character',
|
|
25
|
+
'varbit': 'bit varying',
|
|
26
|
+
};
|
|
27
|
+
return typeMap[internalType] || internalType;
|
|
28
|
+
}
|
|
13
29
|
export async function fastIntrospectDatabase(connection, onProgress, options) {
|
|
14
30
|
const { includeFunctions = false, includeTriggers = false, onDetailedProgress } = options || {};
|
|
15
31
|
const { Pool } = await import("../../addon/pg/index.js");
|
|
@@ -179,9 +195,21 @@ export async function fastIntrospectDatabase(connection, onProgress, options) {
|
|
|
179
195
|
if (!columnsByTable.has(col.table_name)) {
|
|
180
196
|
columnsByTable.set(col.table_name, []);
|
|
181
197
|
}
|
|
198
|
+
let dataType = col.data_type;
|
|
199
|
+
if (dataType === 'ARRAY' && col.udt_name) {
|
|
200
|
+
const baseType = col.udt_name.startsWith('_') ? col.udt_name.slice(1) : col.udt_name;
|
|
201
|
+
const friendlyBase = mapInternalToFriendlyType(baseType);
|
|
202
|
+
dataType = `${friendlyBase}[]`;
|
|
203
|
+
}
|
|
204
|
+
else if (dataType === 'USER-DEFINED' && col.udt_name) {
|
|
205
|
+
dataType = col.udt_name;
|
|
206
|
+
}
|
|
207
|
+
else if (col.udt_name) {
|
|
208
|
+
dataType = col.udt_name;
|
|
209
|
+
}
|
|
182
210
|
columnsByTable.get(col.table_name).push({
|
|
183
211
|
name: col.column_name,
|
|
184
|
-
dataType
|
|
212
|
+
dataType,
|
|
185
213
|
isNullable: col.is_nullable,
|
|
186
214
|
defaultValue: col.column_default,
|
|
187
215
|
isPrimaryKey: false,
|