rake-db 2.22.6 → 2.22.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.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1551,7 +1551,7 @@ declare namespace DbStructure {
|
|
|
1551
1551
|
name: string;
|
|
1552
1552
|
typeSchema: string;
|
|
1553
1553
|
type: string;
|
|
1554
|
-
|
|
1554
|
+
arrayDims: number;
|
|
1555
1555
|
maxChars?: number;
|
|
1556
1556
|
numericPrecision?: number;
|
|
1557
1557
|
numericScale?: number;
|
|
@@ -1644,7 +1644,7 @@ declare namespace DbStructure {
|
|
|
1644
1644
|
name: string;
|
|
1645
1645
|
type: string;
|
|
1646
1646
|
typeSchema: string;
|
|
1647
|
-
|
|
1647
|
+
arrayDims: number;
|
|
1648
1648
|
isNullable: boolean;
|
|
1649
1649
|
maxChars?: number;
|
|
1650
1650
|
numericPrecision?: number;
|
package/dist/index.js
CHANGED
|
@@ -3663,25 +3663,13 @@ const columnsSql = ({
|
|
|
3663
3663
|
${schema}.nspname AS "schemaName",
|
|
3664
3664
|
${table}.relname AS "tableName",
|
|
3665
3665
|
a.attname AS "name",
|
|
3666
|
-
|
|
3666
|
+
t.typname AS "type",
|
|
3667
3667
|
tn.nspname AS "typeSchema",
|
|
3668
|
-
|
|
3669
|
-
information_schema._pg_char_max_length(
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
)
|
|
3673
|
-
information_schema._pg_numeric_precision(
|
|
3674
|
-
information_schema._pg_truetypid(a, t),
|
|
3675
|
-
information_schema._pg_truetypmod(a, t)
|
|
3676
|
-
) AS "numericPrecision",
|
|
3677
|
-
information_schema._pg_numeric_scale(
|
|
3678
|
-
information_schema._pg_truetypid(a, t),
|
|
3679
|
-
information_schema._pg_truetypmod(a, t)
|
|
3680
|
-
) AS "numericScale",
|
|
3681
|
-
information_schema._pg_datetime_precision(
|
|
3682
|
-
information_schema._pg_truetypid(a, t),
|
|
3683
|
-
information_schema._pg_truetypmod(a, t)
|
|
3684
|
-
) AS "dateTimePrecision",
|
|
3668
|
+
a.attndims AS "arrayDims",
|
|
3669
|
+
information_schema._pg_char_max_length(tt.id, tt.mod) "maxChars",
|
|
3670
|
+
information_schema._pg_numeric_precision(tt.id, tt.mod) "numericPrecision",
|
|
3671
|
+
information_schema._pg_numeric_scale(tt.id,tt.mod) "numericScale",
|
|
3672
|
+
information_schema._pg_datetime_precision(tt.id,tt.mod) "dateTimePrecision",
|
|
3685
3673
|
CAST(
|
|
3686
3674
|
CASE WHEN a.attgenerated = ''
|
|
3687
3675
|
THEN pg_get_expr(ad.adbin, ad.adrelid)
|
|
@@ -3704,7 +3692,7 @@ const columnsSql = ({
|
|
|
3704
3692
|
nullif(seq.seqmin, 1),
|
|
3705
3693
|
'max',
|
|
3706
3694
|
nullif(seq.seqmax, (
|
|
3707
|
-
CASE
|
|
3695
|
+
CASE t.typname
|
|
3708
3696
|
WHEN 'int2' THEN 32767
|
|
3709
3697
|
WHEN 'int4' THEN 2147483647
|
|
3710
3698
|
WHEN 'int8' THEN 9223372036854775807
|
|
@@ -3721,8 +3709,18 @@ const columnsSql = ({
|
|
|
3721
3709
|
FROM pg_attribute a
|
|
3722
3710
|
${join}
|
|
3723
3711
|
LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
|
|
3724
|
-
JOIN pg_type t
|
|
3725
|
-
|
|
3712
|
+
JOIN pg_type t
|
|
3713
|
+
ON t.oid = (
|
|
3714
|
+
CASE WHEN a.attndims = 0
|
|
3715
|
+
THEN a.atttypid
|
|
3716
|
+
ELSE (SELECT t.typelem FROM pg_type t WHERE t.oid = a.atttypid)
|
|
3717
|
+
END
|
|
3718
|
+
)
|
|
3719
|
+
JOIN LATERAL (
|
|
3720
|
+
SELECT
|
|
3721
|
+
CASE WHEN t.typtype = 'd' THEN t.typbasetype ELSE t.oid END id,
|
|
3722
|
+
CASE WHEN t.typtype = 'd' THEN t.typtypmod ELSE a.atttypmod END mod
|
|
3723
|
+
) tt ON true
|
|
3726
3724
|
JOIN pg_namespace tn ON tn.oid = t.typnamespace
|
|
3727
3725
|
LEFT JOIN (pg_collation co JOIN pg_namespace nco ON (co.collnamespace = nco.oid))
|
|
3728
3726
|
ON a.attcollation = co.oid AND (nco.nspname, co.collname) <> ('pg_catalog', 'default')
|
|
@@ -3981,7 +3979,7 @@ const domainsSql = `SELECT
|
|
|
3981
3979
|
t.typname AS "type",
|
|
3982
3980
|
s.nspname AS "typeSchema",
|
|
3983
3981
|
NOT d.typnotnull AS "isNullable",
|
|
3984
|
-
d.
|
|
3982
|
+
d.typndims AS "arrayDims",
|
|
3985
3983
|
character_maximum_length AS "maxChars",
|
|
3986
3984
|
numeric_precision AS "numericPrecision",
|
|
3987
3985
|
numeric_scale AS "numericScale",
|
|
@@ -4247,7 +4245,7 @@ const makeDomainsMap = (ctx, data) => {
|
|
|
4247
4245
|
name: it.name,
|
|
4248
4246
|
type: it.type,
|
|
4249
4247
|
typeSchema: it.typeSchema,
|
|
4250
|
-
|
|
4248
|
+
arrayDims: it.arrayDims,
|
|
4251
4249
|
tableName: "",
|
|
4252
4250
|
isNullable: it.isNullable,
|
|
4253
4251
|
collate: it.collate,
|
|
@@ -4310,11 +4308,19 @@ const instantiateDbColumn = (ctx, data, domains, dbColumn) => {
|
|
|
4310
4308
|
}
|
|
4311
4309
|
}
|
|
4312
4310
|
column.data.name = void 0;
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4311
|
+
if (!column.data.isNullable)
|
|
4312
|
+
column.data.isNullable = void 0;
|
|
4313
|
+
if (dbColumn.arrayDims) {
|
|
4314
|
+
const arr = new pqb.ArrayColumn(
|
|
4315
|
+
ctx.columnSchemaConfig,
|
|
4316
|
+
column,
|
|
4317
|
+
ctx.columnSchemaConfig.type
|
|
4318
|
+
);
|
|
4319
|
+
arr.data.isNullable = dbColumn.isNullable;
|
|
4320
|
+
arr.data.arrayDims = dbColumn.arrayDims;
|
|
4321
|
+
column = arr;
|
|
4322
|
+
}
|
|
4323
|
+
return column;
|
|
4318
4324
|
};
|
|
4319
4325
|
const instantiateColumnByDbType = (ctx, type, isSerial, params) => {
|
|
4320
4326
|
const columnFn = ctx.columnsByType[!isSerial ? type : type === "int2" ? "smallserial" : type === "int4" ? "serial" : "bigserial"];
|