@sqlanvil/cli 1.2.0 → 1.3.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/bundle.js +56 -10
- package/package.json +1 -1
- package/worker_bundle.js +28 -0
package/bundle.js
CHANGED
|
@@ -12722,6 +12722,7 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12722
12722
|
* @interface IBound
|
|
12723
12723
|
* @property {string|null} [name] Bound name
|
|
12724
12724
|
* @property {string|null} [values] Bound values
|
|
12725
|
+
* @property {sqlanvil.PostgresOptions.IPartition|null} [subPartition] Bound subPartition
|
|
12725
12726
|
*/
|
|
12726
12727
|
|
|
12727
12728
|
/**
|
|
@@ -12755,6 +12756,14 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12755
12756
|
*/
|
|
12756
12757
|
Bound.prototype.values = "";
|
|
12757
12758
|
|
|
12759
|
+
/**
|
|
12760
|
+
* Bound subPartition.
|
|
12761
|
+
* @member {sqlanvil.PostgresOptions.IPartition|null|undefined} subPartition
|
|
12762
|
+
* @memberof sqlanvil.PostgresOptions.Partition.Bound
|
|
12763
|
+
* @instance
|
|
12764
|
+
*/
|
|
12765
|
+
Bound.prototype.subPartition = null;
|
|
12766
|
+
|
|
12758
12767
|
/**
|
|
12759
12768
|
* Creates a new Bound instance using the specified properties.
|
|
12760
12769
|
* @function create
|
|
@@ -12783,6 +12792,8 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12783
12792
|
writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
|
|
12784
12793
|
if (message.values != null && Object.hasOwnProperty.call(message, "values"))
|
|
12785
12794
|
writer.uint32(/* id 2, wireType 2 =*/18).string(message.values);
|
|
12795
|
+
if (message.subPartition != null && Object.hasOwnProperty.call(message, "subPartition"))
|
|
12796
|
+
$root.sqlanvil.PostgresOptions.Partition.encode(message.subPartition, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
|
|
12786
12797
|
return writer;
|
|
12787
12798
|
};
|
|
12788
12799
|
|
|
@@ -12827,6 +12838,10 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12827
12838
|
message.values = reader.string();
|
|
12828
12839
|
break;
|
|
12829
12840
|
}
|
|
12841
|
+
case 3: {
|
|
12842
|
+
message.subPartition = $root.sqlanvil.PostgresOptions.Partition.decode(reader, reader.uint32());
|
|
12843
|
+
break;
|
|
12844
|
+
}
|
|
12830
12845
|
default:
|
|
12831
12846
|
reader.skipType(tag & 7);
|
|
12832
12847
|
break;
|
|
@@ -12868,6 +12883,11 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12868
12883
|
if (message.values != null && message.hasOwnProperty("values"))
|
|
12869
12884
|
if (!$util.isString(message.values))
|
|
12870
12885
|
return "values: string expected";
|
|
12886
|
+
if (message.subPartition != null && message.hasOwnProperty("subPartition")) {
|
|
12887
|
+
let error = $root.sqlanvil.PostgresOptions.Partition.verify(message.subPartition);
|
|
12888
|
+
if (error)
|
|
12889
|
+
return "subPartition." + error;
|
|
12890
|
+
}
|
|
12871
12891
|
return null;
|
|
12872
12892
|
};
|
|
12873
12893
|
|
|
@@ -12887,6 +12907,11 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12887
12907
|
message.name = String(object.name);
|
|
12888
12908
|
if (object.values != null)
|
|
12889
12909
|
message.values = String(object.values);
|
|
12910
|
+
if (object.subPartition != null) {
|
|
12911
|
+
if (typeof object.subPartition !== "object")
|
|
12912
|
+
throw TypeError(".sqlanvil.PostgresOptions.Partition.Bound.subPartition: object expected");
|
|
12913
|
+
message.subPartition = $root.sqlanvil.PostgresOptions.Partition.fromObject(object.subPartition);
|
|
12914
|
+
}
|
|
12890
12915
|
return message;
|
|
12891
12916
|
};
|
|
12892
12917
|
|
|
@@ -12906,11 +12931,14 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12906
12931
|
if (options.defaults) {
|
|
12907
12932
|
object.name = "";
|
|
12908
12933
|
object.values = "";
|
|
12934
|
+
object.subPartition = null;
|
|
12909
12935
|
}
|
|
12910
12936
|
if (message.name != null && message.hasOwnProperty("name"))
|
|
12911
12937
|
object.name = message.name;
|
|
12912
12938
|
if (message.values != null && message.hasOwnProperty("values"))
|
|
12913
12939
|
object.values = message.values;
|
|
12940
|
+
if (message.subPartition != null && message.hasOwnProperty("subPartition"))
|
|
12941
|
+
object.subPartition = $root.sqlanvil.PostgresOptions.Partition.toObject(message.subPartition, options);
|
|
12914
12942
|
return object;
|
|
12915
12943
|
};
|
|
12916
12944
|
|
|
@@ -38415,27 +38443,44 @@ class PostgresExecutionSql {
|
|
|
38415
38443
|
}
|
|
38416
38444
|
}
|
|
38417
38445
|
createPartitionedTableTasks(table) {
|
|
38446
|
+
var _a;
|
|
38418
38447
|
const partition = table.postgres.partition;
|
|
38419
38448
|
const target = this.resolveTarget(table.target);
|
|
38420
38449
|
const stage = this.resolveTarget(Object.assign(Object.assign({}, table.target), { name: `${table.target.name}__sa_stage` }));
|
|
38421
38450
|
const kind = this.partitionKindAsSql(partition.kind);
|
|
38422
38451
|
const columns = (partition.columns || []).map(c => `"${c}"`).join(", ");
|
|
38452
|
+
const tablespace = ((_a = table.postgres) === null || _a === void 0 ? void 0 : _a.tablespace) ? ` tablespace "${table.postgres.tablespace}"` : "";
|
|
38423
38453
|
const statements = [
|
|
38424
38454
|
`drop table if exists ${stage} cascade`,
|
|
38425
38455
|
`create unlogged table ${stage} as ${table.query} with no data`,
|
|
38426
38456
|
`drop table if exists ${target} cascade`,
|
|
38427
|
-
`create table ${target} (like ${stage} including defaults) partition by ${kind} (${columns})`
|
|
38457
|
+
`create table ${target} (like ${stage} including defaults) partition by ${kind} (${columns})${tablespace}`
|
|
38428
38458
|
];
|
|
38459
|
+
statements.push(...this.createChildPartitions(table.target, table.target.name, target, partition));
|
|
38460
|
+
statements.push(`insert into ${target} select * from (${table.query}) as q`);
|
|
38461
|
+
statements.push(`drop table if exists ${stage} cascade`);
|
|
38462
|
+
return statements;
|
|
38463
|
+
}
|
|
38464
|
+
createChildPartitions(baseTarget, parentName, parentSql, partition) {
|
|
38465
|
+
const statements = [];
|
|
38429
38466
|
for (const bound of partition.partitions || []) {
|
|
38430
|
-
const
|
|
38431
|
-
|
|
38467
|
+
const childName = `${parentName}__${bound.name}`;
|
|
38468
|
+
const childSql = this.resolveTarget(Object.assign(Object.assign({}, baseTarget), { name: childName }));
|
|
38469
|
+
const sub = bound.subPartition;
|
|
38470
|
+
if (sub && (sub.columns || []).length > 0) {
|
|
38471
|
+
const subKind = this.partitionKindAsSql(sub.kind);
|
|
38472
|
+
const subColumns = (sub.columns || []).map(c => `"${c}"`).join(", ");
|
|
38473
|
+
statements.push(`create table ${childSql} partition of ${parentSql} for values ${bound.values} partition by ${subKind} (${subColumns})`);
|
|
38474
|
+
statements.push(...this.createChildPartitions(baseTarget, childName, childSql, sub));
|
|
38475
|
+
}
|
|
38476
|
+
else {
|
|
38477
|
+
statements.push(`create table ${childSql} partition of ${parentSql} for values ${bound.values}`);
|
|
38478
|
+
}
|
|
38432
38479
|
}
|
|
38433
38480
|
if (partition.includeDefault) {
|
|
38434
|
-
const def = this.resolveTarget(Object.assign(Object.assign({},
|
|
38435
|
-
statements.push(`create table ${def} partition of ${
|
|
38481
|
+
const def = this.resolveTarget(Object.assign(Object.assign({}, baseTarget), { name: `${parentName}__default` }));
|
|
38482
|
+
statements.push(`create table ${def} partition of ${parentSql} default`);
|
|
38436
38483
|
}
|
|
38437
|
-
statements.push(`insert into ${target} select * from (${table.query}) as q`);
|
|
38438
|
-
statements.push(`drop table if exists ${stage} cascade`);
|
|
38439
38484
|
return statements;
|
|
38440
38485
|
}
|
|
38441
38486
|
partitionKindAsSql(kind) {
|
|
@@ -38608,7 +38653,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
|
|
|
38608
38653
|
.filter(validationQuery => !!validationQuery.query);
|
|
38609
38654
|
}
|
|
38610
38655
|
|
|
38611
|
-
const version = "1.
|
|
38656
|
+
const version = "1.3.0";
|
|
38612
38657
|
const dataformVersion = "3.0.59";
|
|
38613
38658
|
|
|
38614
38659
|
async function build(compiledGraph, runConfig, dbadapter) {
|
|
@@ -39693,12 +39738,13 @@ async function test(dbadapter, tests) {
|
|
|
39693
39738
|
return await Promise.all(tests.map(testCase => runTest(dbadapter, testCase)));
|
|
39694
39739
|
}
|
|
39695
39740
|
async function runTest(dbadapter, testCase) {
|
|
39741
|
+
const noLimit = {};
|
|
39696
39742
|
let actualResults;
|
|
39697
39743
|
let expectedResults;
|
|
39698
39744
|
try {
|
|
39699
39745
|
[actualResults, expectedResults] = await Promise.all([
|
|
39700
|
-
dbadapter.execute(testCase.testQuery,
|
|
39701
|
-
dbadapter.execute(testCase.expectedOutputQuery,
|
|
39746
|
+
dbadapter.execute(testCase.testQuery, noLimit),
|
|
39747
|
+
dbadapter.execute(testCase.expectedOutputQuery, noLimit)
|
|
39702
39748
|
]);
|
|
39703
39749
|
}
|
|
39704
39750
|
catch (e) {
|
package/package.json
CHANGED
package/worker_bundle.js
CHANGED
|
@@ -12665,6 +12665,7 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12665
12665
|
* @interface IBound
|
|
12666
12666
|
* @property {string|null} [name] Bound name
|
|
12667
12667
|
* @property {string|null} [values] Bound values
|
|
12668
|
+
* @property {sqlanvil.PostgresOptions.IPartition|null} [subPartition] Bound subPartition
|
|
12668
12669
|
*/
|
|
12669
12670
|
|
|
12670
12671
|
/**
|
|
@@ -12698,6 +12699,14 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12698
12699
|
*/
|
|
12699
12700
|
Bound.prototype.values = "";
|
|
12700
12701
|
|
|
12702
|
+
/**
|
|
12703
|
+
* Bound subPartition.
|
|
12704
|
+
* @member {sqlanvil.PostgresOptions.IPartition|null|undefined} subPartition
|
|
12705
|
+
* @memberof sqlanvil.PostgresOptions.Partition.Bound
|
|
12706
|
+
* @instance
|
|
12707
|
+
*/
|
|
12708
|
+
Bound.prototype.subPartition = null;
|
|
12709
|
+
|
|
12701
12710
|
/**
|
|
12702
12711
|
* Creates a new Bound instance using the specified properties.
|
|
12703
12712
|
* @function create
|
|
@@ -12726,6 +12735,8 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12726
12735
|
writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
|
|
12727
12736
|
if (message.values != null && Object.hasOwnProperty.call(message, "values"))
|
|
12728
12737
|
writer.uint32(/* id 2, wireType 2 =*/18).string(message.values);
|
|
12738
|
+
if (message.subPartition != null && Object.hasOwnProperty.call(message, "subPartition"))
|
|
12739
|
+
$root.sqlanvil.PostgresOptions.Partition.encode(message.subPartition, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
|
|
12729
12740
|
return writer;
|
|
12730
12741
|
};
|
|
12731
12742
|
|
|
@@ -12770,6 +12781,10 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12770
12781
|
message.values = reader.string();
|
|
12771
12782
|
break;
|
|
12772
12783
|
}
|
|
12784
|
+
case 3: {
|
|
12785
|
+
message.subPartition = $root.sqlanvil.PostgresOptions.Partition.decode(reader, reader.uint32());
|
|
12786
|
+
break;
|
|
12787
|
+
}
|
|
12773
12788
|
default:
|
|
12774
12789
|
reader.skipType(tag & 7);
|
|
12775
12790
|
break;
|
|
@@ -12811,6 +12826,11 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12811
12826
|
if (message.values != null && message.hasOwnProperty("values"))
|
|
12812
12827
|
if (!$util.isString(message.values))
|
|
12813
12828
|
return "values: string expected";
|
|
12829
|
+
if (message.subPartition != null && message.hasOwnProperty("subPartition")) {
|
|
12830
|
+
let error = $root.sqlanvil.PostgresOptions.Partition.verify(message.subPartition);
|
|
12831
|
+
if (error)
|
|
12832
|
+
return "subPartition." + error;
|
|
12833
|
+
}
|
|
12814
12834
|
return null;
|
|
12815
12835
|
};
|
|
12816
12836
|
|
|
@@ -12830,6 +12850,11 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12830
12850
|
message.name = String(object.name);
|
|
12831
12851
|
if (object.values != null)
|
|
12832
12852
|
message.values = String(object.values);
|
|
12853
|
+
if (object.subPartition != null) {
|
|
12854
|
+
if (typeof object.subPartition !== "object")
|
|
12855
|
+
throw TypeError(".sqlanvil.PostgresOptions.Partition.Bound.subPartition: object expected");
|
|
12856
|
+
message.subPartition = $root.sqlanvil.PostgresOptions.Partition.fromObject(object.subPartition);
|
|
12857
|
+
}
|
|
12833
12858
|
return message;
|
|
12834
12859
|
};
|
|
12835
12860
|
|
|
@@ -12849,11 +12874,14 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
12849
12874
|
if (options.defaults) {
|
|
12850
12875
|
object.name = "";
|
|
12851
12876
|
object.values = "";
|
|
12877
|
+
object.subPartition = null;
|
|
12852
12878
|
}
|
|
12853
12879
|
if (message.name != null && message.hasOwnProperty("name"))
|
|
12854
12880
|
object.name = message.name;
|
|
12855
12881
|
if (message.values != null && message.hasOwnProperty("values"))
|
|
12856
12882
|
object.values = message.values;
|
|
12883
|
+
if (message.subPartition != null && message.hasOwnProperty("subPartition"))
|
|
12884
|
+
object.subPartition = $root.sqlanvil.PostgresOptions.Partition.toObject(message.subPartition, options);
|
|
12857
12885
|
return object;
|
|
12858
12886
|
};
|
|
12859
12887
|
|