@sqlanvil/cli 1.10.0 → 1.11.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 +704 -7
- package/package.json +1 -1
- package/worker_bundle.js +625 -0
package/bundle.js
CHANGED
|
@@ -29,6 +29,7 @@ var childProcess = require('child_process');
|
|
|
29
29
|
var fs = require('fs-extra');
|
|
30
30
|
var tmp = require('tmp');
|
|
31
31
|
var util = require('util');
|
|
32
|
+
var mysql = require('mysql2/promise');
|
|
32
33
|
var pg = require('pg');
|
|
33
34
|
var bigquery = require('@google-cloud/bigquery');
|
|
34
35
|
var EventEmitter = require('events');
|
|
@@ -36,7 +37,6 @@ var Long = require('long');
|
|
|
36
37
|
var os = require('os');
|
|
37
38
|
var promisePoolExecutor = require('promise-pool-executor');
|
|
38
39
|
var sizeof = require('object-sizeof');
|
|
39
|
-
var mysql = require('mysql2/promise');
|
|
40
40
|
var QueryStream = require('pg-query-stream');
|
|
41
41
|
var readlineSync = require('readline-sync');
|
|
42
42
|
var untildify = require('untildify');
|
|
@@ -76,12 +76,12 @@ var semver__namespace = /*#__PURE__*/_interopNamespace(semver);
|
|
|
76
76
|
var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
|
|
77
77
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
78
78
|
var tmp__namespace = /*#__PURE__*/_interopNamespace(tmp);
|
|
79
|
+
var mysql__namespace = /*#__PURE__*/_interopNamespace(mysql);
|
|
79
80
|
var pg__namespace = /*#__PURE__*/_interopNamespace(pg);
|
|
80
81
|
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
81
82
|
var Long__default = /*#__PURE__*/_interopDefaultLegacy(Long);
|
|
82
83
|
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
83
84
|
var sizeof__default = /*#__PURE__*/_interopDefaultLegacy(sizeof);
|
|
84
|
-
var mysql__namespace = /*#__PURE__*/_interopNamespace(mysql);
|
|
85
85
|
var QueryStream__default = /*#__PURE__*/_interopDefaultLegacy(QueryStream);
|
|
86
86
|
var readlineSync__namespace = /*#__PURE__*/_interopNamespace(readlineSync);
|
|
87
87
|
var untildify__default = /*#__PURE__*/_interopDefaultLegacy(untildify);
|
|
@@ -15249,6 +15249,7 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15249
15249
|
* @property {string|null} [charset] MysqlOptions charset
|
|
15250
15250
|
* @property {string|null} [collation] MysqlOptions collation
|
|
15251
15251
|
* @property {Array.<sqlanvil.MysqlOptions.IIndex>|null} [indexes] MysqlOptions indexes
|
|
15252
|
+
* @property {sqlanvil.MysqlOptions.IPartition|null} [partition] MysqlOptions partition
|
|
15252
15253
|
*/
|
|
15253
15254
|
|
|
15254
15255
|
/**
|
|
@@ -15299,6 +15300,14 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15299
15300
|
*/
|
|
15300
15301
|
MysqlOptions.prototype.indexes = $util.emptyArray;
|
|
15301
15302
|
|
|
15303
|
+
/**
|
|
15304
|
+
* MysqlOptions partition.
|
|
15305
|
+
* @member {sqlanvil.MysqlOptions.IPartition|null|undefined} partition
|
|
15306
|
+
* @memberof sqlanvil.MysqlOptions
|
|
15307
|
+
* @instance
|
|
15308
|
+
*/
|
|
15309
|
+
MysqlOptions.prototype.partition = null;
|
|
15310
|
+
|
|
15302
15311
|
/**
|
|
15303
15312
|
* Creates a new MysqlOptions instance using the specified properties.
|
|
15304
15313
|
* @function create
|
|
@@ -15332,6 +15341,8 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15332
15341
|
if (message.indexes != null && message.indexes.length)
|
|
15333
15342
|
for (let i = 0; i < message.indexes.length; ++i)
|
|
15334
15343
|
$root.sqlanvil.MysqlOptions.Index.encode(message.indexes[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
|
|
15344
|
+
if (message.partition != null && Object.hasOwnProperty.call(message, "partition"))
|
|
15345
|
+
$root.sqlanvil.MysqlOptions.Partition.encode(message.partition, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
|
|
15335
15346
|
return writer;
|
|
15336
15347
|
};
|
|
15337
15348
|
|
|
@@ -15390,6 +15401,10 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15390
15401
|
message.indexes.push($root.sqlanvil.MysqlOptions.Index.decode(reader, reader.uint32(), undefined, long + 1));
|
|
15391
15402
|
break;
|
|
15392
15403
|
}
|
|
15404
|
+
case 5: {
|
|
15405
|
+
message.partition = $root.sqlanvil.MysqlOptions.Partition.decode(reader, reader.uint32(), undefined, long + 1);
|
|
15406
|
+
break;
|
|
15407
|
+
}
|
|
15393
15408
|
default:
|
|
15394
15409
|
reader.skipType(tag & 7, long);
|
|
15395
15410
|
break;
|
|
@@ -15447,6 +15462,11 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15447
15462
|
return "indexes." + error;
|
|
15448
15463
|
}
|
|
15449
15464
|
}
|
|
15465
|
+
if (message.partition != null && message.hasOwnProperty("partition")) {
|
|
15466
|
+
let error = $root.sqlanvil.MysqlOptions.Partition.verify(message.partition, long + 1);
|
|
15467
|
+
if (error)
|
|
15468
|
+
return "partition." + error;
|
|
15469
|
+
}
|
|
15450
15470
|
return null;
|
|
15451
15471
|
};
|
|
15452
15472
|
|
|
@@ -15482,6 +15502,11 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15482
15502
|
message.indexes[i] = $root.sqlanvil.MysqlOptions.Index.fromObject(object.indexes[i], long + 1);
|
|
15483
15503
|
}
|
|
15484
15504
|
}
|
|
15505
|
+
if (object.partition != null) {
|
|
15506
|
+
if (typeof object.partition !== "object")
|
|
15507
|
+
throw TypeError(".sqlanvil.MysqlOptions.partition: object expected");
|
|
15508
|
+
message.partition = $root.sqlanvil.MysqlOptions.Partition.fromObject(object.partition, long + 1);
|
|
15509
|
+
}
|
|
15485
15510
|
return message;
|
|
15486
15511
|
};
|
|
15487
15512
|
|
|
@@ -15504,6 +15529,7 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15504
15529
|
object.engine = "";
|
|
15505
15530
|
object.charset = "";
|
|
15506
15531
|
object.collation = "";
|
|
15532
|
+
object.partition = null;
|
|
15507
15533
|
}
|
|
15508
15534
|
if (message.engine != null && message.hasOwnProperty("engine"))
|
|
15509
15535
|
object.engine = message.engine;
|
|
@@ -15516,6 +15542,8 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15516
15542
|
for (let j = 0; j < message.indexes.length; ++j)
|
|
15517
15543
|
object.indexes[j] = $root.sqlanvil.MysqlOptions.Index.toObject(message.indexes[j], options);
|
|
15518
15544
|
}
|
|
15545
|
+
if (message.partition != null && message.hasOwnProperty("partition"))
|
|
15546
|
+
object.partition = $root.sqlanvil.MysqlOptions.Partition.toObject(message.partition, options);
|
|
15519
15547
|
return object;
|
|
15520
15548
|
};
|
|
15521
15549
|
|
|
@@ -15826,6 +15854,603 @@ const sqlanvil = $root.sqlanvil = (() => {
|
|
|
15826
15854
|
return Index;
|
|
15827
15855
|
})();
|
|
15828
15856
|
|
|
15857
|
+
MysqlOptions.Partition = (function() {
|
|
15858
|
+
|
|
15859
|
+
/**
|
|
15860
|
+
* Properties of a Partition.
|
|
15861
|
+
* @memberof sqlanvil.MysqlOptions
|
|
15862
|
+
* @interface IPartition
|
|
15863
|
+
* @property {sqlanvil.MysqlOptions.Partition.Kind|null} [kind] Partition kind
|
|
15864
|
+
* @property {string|null} [expression] Partition expression
|
|
15865
|
+
* @property {Array.<sqlanvil.MysqlOptions.Partition.IBound>|null} [partitions] Partition partitions
|
|
15866
|
+
* @property {number|null} [count] Partition count
|
|
15867
|
+
*/
|
|
15868
|
+
|
|
15869
|
+
/**
|
|
15870
|
+
* Constructs a new Partition.
|
|
15871
|
+
* @memberof sqlanvil.MysqlOptions
|
|
15872
|
+
* @classdesc Represents a Partition.
|
|
15873
|
+
* @implements IPartition
|
|
15874
|
+
* @constructor
|
|
15875
|
+
* @param {sqlanvil.MysqlOptions.IPartition=} [properties] Properties to set
|
|
15876
|
+
*/
|
|
15877
|
+
function Partition(properties) {
|
|
15878
|
+
this.partitions = [];
|
|
15879
|
+
if (properties)
|
|
15880
|
+
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
15881
|
+
if (properties[keys[i]] != null && keys[i] !== "__proto__")
|
|
15882
|
+
this[keys[i]] = properties[keys[i]];
|
|
15883
|
+
}
|
|
15884
|
+
|
|
15885
|
+
/**
|
|
15886
|
+
* Partition kind.
|
|
15887
|
+
* @member {sqlanvil.MysqlOptions.Partition.Kind} kind
|
|
15888
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15889
|
+
* @instance
|
|
15890
|
+
*/
|
|
15891
|
+
Partition.prototype.kind = 0;
|
|
15892
|
+
|
|
15893
|
+
/**
|
|
15894
|
+
* Partition expression.
|
|
15895
|
+
* @member {string} expression
|
|
15896
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15897
|
+
* @instance
|
|
15898
|
+
*/
|
|
15899
|
+
Partition.prototype.expression = "";
|
|
15900
|
+
|
|
15901
|
+
/**
|
|
15902
|
+
* Partition partitions.
|
|
15903
|
+
* @member {Array.<sqlanvil.MysqlOptions.Partition.IBound>} partitions
|
|
15904
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15905
|
+
* @instance
|
|
15906
|
+
*/
|
|
15907
|
+
Partition.prototype.partitions = $util.emptyArray;
|
|
15908
|
+
|
|
15909
|
+
/**
|
|
15910
|
+
* Partition count.
|
|
15911
|
+
* @member {number} count
|
|
15912
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15913
|
+
* @instance
|
|
15914
|
+
*/
|
|
15915
|
+
Partition.prototype.count = 0;
|
|
15916
|
+
|
|
15917
|
+
/**
|
|
15918
|
+
* Creates a new Partition instance using the specified properties.
|
|
15919
|
+
* @function create
|
|
15920
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15921
|
+
* @static
|
|
15922
|
+
* @param {sqlanvil.MysqlOptions.IPartition=} [properties] Properties to set
|
|
15923
|
+
* @returns {sqlanvil.MysqlOptions.Partition} Partition instance
|
|
15924
|
+
*/
|
|
15925
|
+
Partition.create = function create(properties) {
|
|
15926
|
+
return new Partition(properties);
|
|
15927
|
+
};
|
|
15928
|
+
|
|
15929
|
+
/**
|
|
15930
|
+
* Encodes the specified Partition message. Does not implicitly {@link sqlanvil.MysqlOptions.Partition.verify|verify} messages.
|
|
15931
|
+
* @function encode
|
|
15932
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15933
|
+
* @static
|
|
15934
|
+
* @param {sqlanvil.MysqlOptions.IPartition} message Partition message or plain object to encode
|
|
15935
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
15936
|
+
* @returns {$protobuf.Writer} Writer
|
|
15937
|
+
*/
|
|
15938
|
+
Partition.encode = function encode(message, writer) {
|
|
15939
|
+
if (!writer)
|
|
15940
|
+
writer = $Writer.create();
|
|
15941
|
+
if (message.kind != null && Object.hasOwnProperty.call(message, "kind"))
|
|
15942
|
+
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.kind);
|
|
15943
|
+
if (message.expression != null && Object.hasOwnProperty.call(message, "expression"))
|
|
15944
|
+
writer.uint32(/* id 2, wireType 2 =*/18).string(message.expression);
|
|
15945
|
+
if (message.partitions != null && message.partitions.length)
|
|
15946
|
+
for (let i = 0; i < message.partitions.length; ++i)
|
|
15947
|
+
$root.sqlanvil.MysqlOptions.Partition.Bound.encode(message.partitions[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
|
|
15948
|
+
if (message.count != null && Object.hasOwnProperty.call(message, "count"))
|
|
15949
|
+
writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.count);
|
|
15950
|
+
return writer;
|
|
15951
|
+
};
|
|
15952
|
+
|
|
15953
|
+
/**
|
|
15954
|
+
* Encodes the specified Partition message, length delimited. Does not implicitly {@link sqlanvil.MysqlOptions.Partition.verify|verify} messages.
|
|
15955
|
+
* @function encodeDelimited
|
|
15956
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15957
|
+
* @static
|
|
15958
|
+
* @param {sqlanvil.MysqlOptions.IPartition} message Partition message or plain object to encode
|
|
15959
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
15960
|
+
* @returns {$protobuf.Writer} Writer
|
|
15961
|
+
*/
|
|
15962
|
+
Partition.encodeDelimited = function encodeDelimited(message, writer) {
|
|
15963
|
+
return this.encode(message, writer).ldelim();
|
|
15964
|
+
};
|
|
15965
|
+
|
|
15966
|
+
/**
|
|
15967
|
+
* Decodes a Partition message from the specified reader or buffer.
|
|
15968
|
+
* @function decode
|
|
15969
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
15970
|
+
* @static
|
|
15971
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
15972
|
+
* @param {number} [length] Message length if known beforehand
|
|
15973
|
+
* @returns {sqlanvil.MysqlOptions.Partition} Partition
|
|
15974
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
15975
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
15976
|
+
*/
|
|
15977
|
+
Partition.decode = function decode(reader, length, error, long) {
|
|
15978
|
+
if (!(reader instanceof $Reader))
|
|
15979
|
+
reader = $Reader.create(reader);
|
|
15980
|
+
if (long === undefined)
|
|
15981
|
+
long = 0;
|
|
15982
|
+
if (long > $Reader.recursionLimit)
|
|
15983
|
+
throw Error("maximum nesting depth exceeded");
|
|
15984
|
+
let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlOptions.Partition();
|
|
15985
|
+
while (reader.pos < end) {
|
|
15986
|
+
let tag = reader.uint32();
|
|
15987
|
+
if (tag === error)
|
|
15988
|
+
break;
|
|
15989
|
+
switch (tag >>> 3) {
|
|
15990
|
+
case 1: {
|
|
15991
|
+
message.kind = reader.int32();
|
|
15992
|
+
break;
|
|
15993
|
+
}
|
|
15994
|
+
case 2: {
|
|
15995
|
+
message.expression = reader.string();
|
|
15996
|
+
break;
|
|
15997
|
+
}
|
|
15998
|
+
case 3: {
|
|
15999
|
+
if (!(message.partitions && message.partitions.length))
|
|
16000
|
+
message.partitions = [];
|
|
16001
|
+
message.partitions.push($root.sqlanvil.MysqlOptions.Partition.Bound.decode(reader, reader.uint32(), undefined, long + 1));
|
|
16002
|
+
break;
|
|
16003
|
+
}
|
|
16004
|
+
case 4: {
|
|
16005
|
+
message.count = reader.uint32();
|
|
16006
|
+
break;
|
|
16007
|
+
}
|
|
16008
|
+
default:
|
|
16009
|
+
reader.skipType(tag & 7, long);
|
|
16010
|
+
break;
|
|
16011
|
+
}
|
|
16012
|
+
}
|
|
16013
|
+
return message;
|
|
16014
|
+
};
|
|
16015
|
+
|
|
16016
|
+
/**
|
|
16017
|
+
* Decodes a Partition message from the specified reader or buffer, length delimited.
|
|
16018
|
+
* @function decodeDelimited
|
|
16019
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16020
|
+
* @static
|
|
16021
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
16022
|
+
* @returns {sqlanvil.MysqlOptions.Partition} Partition
|
|
16023
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
16024
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
16025
|
+
*/
|
|
16026
|
+
Partition.decodeDelimited = function decodeDelimited(reader) {
|
|
16027
|
+
if (!(reader instanceof $Reader))
|
|
16028
|
+
reader = new $Reader(reader);
|
|
16029
|
+
return this.decode(reader, reader.uint32());
|
|
16030
|
+
};
|
|
16031
|
+
|
|
16032
|
+
/**
|
|
16033
|
+
* Verifies a Partition message.
|
|
16034
|
+
* @function verify
|
|
16035
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16036
|
+
* @static
|
|
16037
|
+
* @param {Object.<string,*>} message Plain object to verify
|
|
16038
|
+
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
|
16039
|
+
*/
|
|
16040
|
+
Partition.verify = function verify(message, long) {
|
|
16041
|
+
if (typeof message !== "object" || message === null)
|
|
16042
|
+
return "object expected";
|
|
16043
|
+
if (long === undefined)
|
|
16044
|
+
long = 0;
|
|
16045
|
+
if (long > $util.recursionLimit)
|
|
16046
|
+
return "maximum nesting depth exceeded";
|
|
16047
|
+
if (message.kind != null && message.hasOwnProperty("kind"))
|
|
16048
|
+
switch (message.kind) {
|
|
16049
|
+
default:
|
|
16050
|
+
return "kind: enum value expected";
|
|
16051
|
+
case 0:
|
|
16052
|
+
case 1:
|
|
16053
|
+
case 2:
|
|
16054
|
+
case 3:
|
|
16055
|
+
break;
|
|
16056
|
+
}
|
|
16057
|
+
if (message.expression != null && message.hasOwnProperty("expression"))
|
|
16058
|
+
if (!$util.isString(message.expression))
|
|
16059
|
+
return "expression: string expected";
|
|
16060
|
+
if (message.partitions != null && message.hasOwnProperty("partitions")) {
|
|
16061
|
+
if (!Array.isArray(message.partitions))
|
|
16062
|
+
return "partitions: array expected";
|
|
16063
|
+
for (let i = 0; i < message.partitions.length; ++i) {
|
|
16064
|
+
let error = $root.sqlanvil.MysqlOptions.Partition.Bound.verify(message.partitions[i], long + 1);
|
|
16065
|
+
if (error)
|
|
16066
|
+
return "partitions." + error;
|
|
16067
|
+
}
|
|
16068
|
+
}
|
|
16069
|
+
if (message.count != null && message.hasOwnProperty("count"))
|
|
16070
|
+
if (!$util.isInteger(message.count))
|
|
16071
|
+
return "count: integer expected";
|
|
16072
|
+
return null;
|
|
16073
|
+
};
|
|
16074
|
+
|
|
16075
|
+
/**
|
|
16076
|
+
* Creates a Partition message from a plain object. Also converts values to their respective internal types.
|
|
16077
|
+
* @function fromObject
|
|
16078
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16079
|
+
* @static
|
|
16080
|
+
* @param {Object.<string,*>} object Plain object
|
|
16081
|
+
* @returns {sqlanvil.MysqlOptions.Partition} Partition
|
|
16082
|
+
*/
|
|
16083
|
+
Partition.fromObject = function fromObject(object, long) {
|
|
16084
|
+
if (object instanceof $root.sqlanvil.MysqlOptions.Partition)
|
|
16085
|
+
return object;
|
|
16086
|
+
if (long === undefined)
|
|
16087
|
+
long = 0;
|
|
16088
|
+
if (long > $util.recursionLimit)
|
|
16089
|
+
throw Error("maximum nesting depth exceeded");
|
|
16090
|
+
let message = new $root.sqlanvil.MysqlOptions.Partition();
|
|
16091
|
+
switch (object.kind) {
|
|
16092
|
+
default:
|
|
16093
|
+
if (typeof object.kind === "number") {
|
|
16094
|
+
message.kind = object.kind;
|
|
16095
|
+
break;
|
|
16096
|
+
}
|
|
16097
|
+
break;
|
|
16098
|
+
case "RANGE":
|
|
16099
|
+
case 0:
|
|
16100
|
+
message.kind = 0;
|
|
16101
|
+
break;
|
|
16102
|
+
case "LIST":
|
|
16103
|
+
case 1:
|
|
16104
|
+
message.kind = 1;
|
|
16105
|
+
break;
|
|
16106
|
+
case "HASH":
|
|
16107
|
+
case 2:
|
|
16108
|
+
message.kind = 2;
|
|
16109
|
+
break;
|
|
16110
|
+
case "KEY":
|
|
16111
|
+
case 3:
|
|
16112
|
+
message.kind = 3;
|
|
16113
|
+
break;
|
|
16114
|
+
}
|
|
16115
|
+
if (object.expression != null)
|
|
16116
|
+
message.expression = String(object.expression);
|
|
16117
|
+
if (object.partitions) {
|
|
16118
|
+
if (!Array.isArray(object.partitions))
|
|
16119
|
+
throw TypeError(".sqlanvil.MysqlOptions.Partition.partitions: array expected");
|
|
16120
|
+
message.partitions = [];
|
|
16121
|
+
for (let i = 0; i < object.partitions.length; ++i) {
|
|
16122
|
+
if (typeof object.partitions[i] !== "object")
|
|
16123
|
+
throw TypeError(".sqlanvil.MysqlOptions.Partition.partitions: object expected");
|
|
16124
|
+
message.partitions[i] = $root.sqlanvil.MysqlOptions.Partition.Bound.fromObject(object.partitions[i], long + 1);
|
|
16125
|
+
}
|
|
16126
|
+
}
|
|
16127
|
+
if (object.count != null)
|
|
16128
|
+
message.count = object.count >>> 0;
|
|
16129
|
+
return message;
|
|
16130
|
+
};
|
|
16131
|
+
|
|
16132
|
+
/**
|
|
16133
|
+
* Creates a plain object from a Partition message. Also converts values to other types if specified.
|
|
16134
|
+
* @function toObject
|
|
16135
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16136
|
+
* @static
|
|
16137
|
+
* @param {sqlanvil.MysqlOptions.Partition} message Partition
|
|
16138
|
+
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
|
16139
|
+
* @returns {Object.<string,*>} Plain object
|
|
16140
|
+
*/
|
|
16141
|
+
Partition.toObject = function toObject(message, options) {
|
|
16142
|
+
if (!options)
|
|
16143
|
+
options = {};
|
|
16144
|
+
let object = {};
|
|
16145
|
+
if (options.arrays || options.defaults)
|
|
16146
|
+
object.partitions = [];
|
|
16147
|
+
if (options.defaults) {
|
|
16148
|
+
object.kind = options.enums === String ? "RANGE" : 0;
|
|
16149
|
+
object.expression = "";
|
|
16150
|
+
object.count = 0;
|
|
16151
|
+
}
|
|
16152
|
+
if (message.kind != null && message.hasOwnProperty("kind"))
|
|
16153
|
+
object.kind = options.enums === String ? $root.sqlanvil.MysqlOptions.Partition.Kind[message.kind] === undefined ? message.kind : $root.sqlanvil.MysqlOptions.Partition.Kind[message.kind] : message.kind;
|
|
16154
|
+
if (message.expression != null && message.hasOwnProperty("expression"))
|
|
16155
|
+
object.expression = message.expression;
|
|
16156
|
+
if (message.partitions && message.partitions.length) {
|
|
16157
|
+
object.partitions = [];
|
|
16158
|
+
for (let j = 0; j < message.partitions.length; ++j)
|
|
16159
|
+
object.partitions[j] = $root.sqlanvil.MysqlOptions.Partition.Bound.toObject(message.partitions[j], options);
|
|
16160
|
+
}
|
|
16161
|
+
if (message.count != null && message.hasOwnProperty("count"))
|
|
16162
|
+
object.count = message.count;
|
|
16163
|
+
return object;
|
|
16164
|
+
};
|
|
16165
|
+
|
|
16166
|
+
/**
|
|
16167
|
+
* Converts this Partition to JSON.
|
|
16168
|
+
* @function toJSON
|
|
16169
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16170
|
+
* @instance
|
|
16171
|
+
* @returns {Object.<string,*>} JSON object
|
|
16172
|
+
*/
|
|
16173
|
+
Partition.prototype.toJSON = function toJSON() {
|
|
16174
|
+
return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
|
|
16175
|
+
};
|
|
16176
|
+
|
|
16177
|
+
/**
|
|
16178
|
+
* Gets the default type url for Partition
|
|
16179
|
+
* @function getTypeUrl
|
|
16180
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16181
|
+
* @static
|
|
16182
|
+
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
|
16183
|
+
* @returns {string} The default type url
|
|
16184
|
+
*/
|
|
16185
|
+
Partition.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
|
16186
|
+
if (typeUrlPrefix === undefined) {
|
|
16187
|
+
typeUrlPrefix = "type.googleapis.com";
|
|
16188
|
+
}
|
|
16189
|
+
return typeUrlPrefix + "/sqlanvil.MysqlOptions.Partition";
|
|
16190
|
+
};
|
|
16191
|
+
|
|
16192
|
+
/**
|
|
16193
|
+
* Kind enum.
|
|
16194
|
+
* @name sqlanvil.MysqlOptions.Partition.Kind
|
|
16195
|
+
* @enum {number}
|
|
16196
|
+
* @property {number} RANGE=0 RANGE value
|
|
16197
|
+
* @property {number} LIST=1 LIST value
|
|
16198
|
+
* @property {number} HASH=2 HASH value
|
|
16199
|
+
* @property {number} KEY=3 KEY value
|
|
16200
|
+
*/
|
|
16201
|
+
Partition.Kind = (function() {
|
|
16202
|
+
const valuesById = {}, values = Object.create(valuesById);
|
|
16203
|
+
values[valuesById[0] = "RANGE"] = 0;
|
|
16204
|
+
values[valuesById[1] = "LIST"] = 1;
|
|
16205
|
+
values[valuesById[2] = "HASH"] = 2;
|
|
16206
|
+
values[valuesById[3] = "KEY"] = 3;
|
|
16207
|
+
return values;
|
|
16208
|
+
})();
|
|
16209
|
+
|
|
16210
|
+
Partition.Bound = (function() {
|
|
16211
|
+
|
|
16212
|
+
/**
|
|
16213
|
+
* Properties of a Bound.
|
|
16214
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16215
|
+
* @interface IBound
|
|
16216
|
+
* @property {string|null} [name] Bound name
|
|
16217
|
+
* @property {string|null} [values] Bound values
|
|
16218
|
+
*/
|
|
16219
|
+
|
|
16220
|
+
/**
|
|
16221
|
+
* Constructs a new Bound.
|
|
16222
|
+
* @memberof sqlanvil.MysqlOptions.Partition
|
|
16223
|
+
* @classdesc Represents a Bound.
|
|
16224
|
+
* @implements IBound
|
|
16225
|
+
* @constructor
|
|
16226
|
+
* @param {sqlanvil.MysqlOptions.Partition.IBound=} [properties] Properties to set
|
|
16227
|
+
*/
|
|
16228
|
+
function Bound(properties) {
|
|
16229
|
+
if (properties)
|
|
16230
|
+
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
16231
|
+
if (properties[keys[i]] != null && keys[i] !== "__proto__")
|
|
16232
|
+
this[keys[i]] = properties[keys[i]];
|
|
16233
|
+
}
|
|
16234
|
+
|
|
16235
|
+
/**
|
|
16236
|
+
* Bound name.
|
|
16237
|
+
* @member {string} name
|
|
16238
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16239
|
+
* @instance
|
|
16240
|
+
*/
|
|
16241
|
+
Bound.prototype.name = "";
|
|
16242
|
+
|
|
16243
|
+
/**
|
|
16244
|
+
* Bound values.
|
|
16245
|
+
* @member {string} values
|
|
16246
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16247
|
+
* @instance
|
|
16248
|
+
*/
|
|
16249
|
+
Bound.prototype.values = "";
|
|
16250
|
+
|
|
16251
|
+
/**
|
|
16252
|
+
* Creates a new Bound instance using the specified properties.
|
|
16253
|
+
* @function create
|
|
16254
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16255
|
+
* @static
|
|
16256
|
+
* @param {sqlanvil.MysqlOptions.Partition.IBound=} [properties] Properties to set
|
|
16257
|
+
* @returns {sqlanvil.MysqlOptions.Partition.Bound} Bound instance
|
|
16258
|
+
*/
|
|
16259
|
+
Bound.create = function create(properties) {
|
|
16260
|
+
return new Bound(properties);
|
|
16261
|
+
};
|
|
16262
|
+
|
|
16263
|
+
/**
|
|
16264
|
+
* Encodes the specified Bound message. Does not implicitly {@link sqlanvil.MysqlOptions.Partition.Bound.verify|verify} messages.
|
|
16265
|
+
* @function encode
|
|
16266
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16267
|
+
* @static
|
|
16268
|
+
* @param {sqlanvil.MysqlOptions.Partition.IBound} message Bound message or plain object to encode
|
|
16269
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
16270
|
+
* @returns {$protobuf.Writer} Writer
|
|
16271
|
+
*/
|
|
16272
|
+
Bound.encode = function encode(message, writer) {
|
|
16273
|
+
if (!writer)
|
|
16274
|
+
writer = $Writer.create();
|
|
16275
|
+
if (message.name != null && Object.hasOwnProperty.call(message, "name"))
|
|
16276
|
+
writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
|
|
16277
|
+
if (message.values != null && Object.hasOwnProperty.call(message, "values"))
|
|
16278
|
+
writer.uint32(/* id 2, wireType 2 =*/18).string(message.values);
|
|
16279
|
+
return writer;
|
|
16280
|
+
};
|
|
16281
|
+
|
|
16282
|
+
/**
|
|
16283
|
+
* Encodes the specified Bound message, length delimited. Does not implicitly {@link sqlanvil.MysqlOptions.Partition.Bound.verify|verify} messages.
|
|
16284
|
+
* @function encodeDelimited
|
|
16285
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16286
|
+
* @static
|
|
16287
|
+
* @param {sqlanvil.MysqlOptions.Partition.IBound} message Bound message or plain object to encode
|
|
16288
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
16289
|
+
* @returns {$protobuf.Writer} Writer
|
|
16290
|
+
*/
|
|
16291
|
+
Bound.encodeDelimited = function encodeDelimited(message, writer) {
|
|
16292
|
+
return this.encode(message, writer).ldelim();
|
|
16293
|
+
};
|
|
16294
|
+
|
|
16295
|
+
/**
|
|
16296
|
+
* Decodes a Bound message from the specified reader or buffer.
|
|
16297
|
+
* @function decode
|
|
16298
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16299
|
+
* @static
|
|
16300
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
16301
|
+
* @param {number} [length] Message length if known beforehand
|
|
16302
|
+
* @returns {sqlanvil.MysqlOptions.Partition.Bound} Bound
|
|
16303
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
16304
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
16305
|
+
*/
|
|
16306
|
+
Bound.decode = function decode(reader, length, error, long) {
|
|
16307
|
+
if (!(reader instanceof $Reader))
|
|
16308
|
+
reader = $Reader.create(reader);
|
|
16309
|
+
if (long === undefined)
|
|
16310
|
+
long = 0;
|
|
16311
|
+
if (long > $Reader.recursionLimit)
|
|
16312
|
+
throw Error("maximum nesting depth exceeded");
|
|
16313
|
+
let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlOptions.Partition.Bound();
|
|
16314
|
+
while (reader.pos < end) {
|
|
16315
|
+
let tag = reader.uint32();
|
|
16316
|
+
if (tag === error)
|
|
16317
|
+
break;
|
|
16318
|
+
switch (tag >>> 3) {
|
|
16319
|
+
case 1: {
|
|
16320
|
+
message.name = reader.string();
|
|
16321
|
+
break;
|
|
16322
|
+
}
|
|
16323
|
+
case 2: {
|
|
16324
|
+
message.values = reader.string();
|
|
16325
|
+
break;
|
|
16326
|
+
}
|
|
16327
|
+
default:
|
|
16328
|
+
reader.skipType(tag & 7, long);
|
|
16329
|
+
break;
|
|
16330
|
+
}
|
|
16331
|
+
}
|
|
16332
|
+
return message;
|
|
16333
|
+
};
|
|
16334
|
+
|
|
16335
|
+
/**
|
|
16336
|
+
* Decodes a Bound message from the specified reader or buffer, length delimited.
|
|
16337
|
+
* @function decodeDelimited
|
|
16338
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16339
|
+
* @static
|
|
16340
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
16341
|
+
* @returns {sqlanvil.MysqlOptions.Partition.Bound} Bound
|
|
16342
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
16343
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
16344
|
+
*/
|
|
16345
|
+
Bound.decodeDelimited = function decodeDelimited(reader) {
|
|
16346
|
+
if (!(reader instanceof $Reader))
|
|
16347
|
+
reader = new $Reader(reader);
|
|
16348
|
+
return this.decode(reader, reader.uint32());
|
|
16349
|
+
};
|
|
16350
|
+
|
|
16351
|
+
/**
|
|
16352
|
+
* Verifies a Bound message.
|
|
16353
|
+
* @function verify
|
|
16354
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16355
|
+
* @static
|
|
16356
|
+
* @param {Object.<string,*>} message Plain object to verify
|
|
16357
|
+
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
|
16358
|
+
*/
|
|
16359
|
+
Bound.verify = function verify(message, long) {
|
|
16360
|
+
if (typeof message !== "object" || message === null)
|
|
16361
|
+
return "object expected";
|
|
16362
|
+
if (long === undefined)
|
|
16363
|
+
long = 0;
|
|
16364
|
+
if (long > $util.recursionLimit)
|
|
16365
|
+
return "maximum nesting depth exceeded";
|
|
16366
|
+
if (message.name != null && message.hasOwnProperty("name"))
|
|
16367
|
+
if (!$util.isString(message.name))
|
|
16368
|
+
return "name: string expected";
|
|
16369
|
+
if (message.values != null && message.hasOwnProperty("values"))
|
|
16370
|
+
if (!$util.isString(message.values))
|
|
16371
|
+
return "values: string expected";
|
|
16372
|
+
return null;
|
|
16373
|
+
};
|
|
16374
|
+
|
|
16375
|
+
/**
|
|
16376
|
+
* Creates a Bound message from a plain object. Also converts values to their respective internal types.
|
|
16377
|
+
* @function fromObject
|
|
16378
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16379
|
+
* @static
|
|
16380
|
+
* @param {Object.<string,*>} object Plain object
|
|
16381
|
+
* @returns {sqlanvil.MysqlOptions.Partition.Bound} Bound
|
|
16382
|
+
*/
|
|
16383
|
+
Bound.fromObject = function fromObject(object, long) {
|
|
16384
|
+
if (object instanceof $root.sqlanvil.MysqlOptions.Partition.Bound)
|
|
16385
|
+
return object;
|
|
16386
|
+
if (long === undefined)
|
|
16387
|
+
long = 0;
|
|
16388
|
+
if (long > $util.recursionLimit)
|
|
16389
|
+
throw Error("maximum nesting depth exceeded");
|
|
16390
|
+
let message = new $root.sqlanvil.MysqlOptions.Partition.Bound();
|
|
16391
|
+
if (object.name != null)
|
|
16392
|
+
message.name = String(object.name);
|
|
16393
|
+
if (object.values != null)
|
|
16394
|
+
message.values = String(object.values);
|
|
16395
|
+
return message;
|
|
16396
|
+
};
|
|
16397
|
+
|
|
16398
|
+
/**
|
|
16399
|
+
* Creates a plain object from a Bound message. Also converts values to other types if specified.
|
|
16400
|
+
* @function toObject
|
|
16401
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16402
|
+
* @static
|
|
16403
|
+
* @param {sqlanvil.MysqlOptions.Partition.Bound} message Bound
|
|
16404
|
+
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
|
16405
|
+
* @returns {Object.<string,*>} Plain object
|
|
16406
|
+
*/
|
|
16407
|
+
Bound.toObject = function toObject(message, options) {
|
|
16408
|
+
if (!options)
|
|
16409
|
+
options = {};
|
|
16410
|
+
let object = {};
|
|
16411
|
+
if (options.defaults) {
|
|
16412
|
+
object.name = "";
|
|
16413
|
+
object.values = "";
|
|
16414
|
+
}
|
|
16415
|
+
if (message.name != null && message.hasOwnProperty("name"))
|
|
16416
|
+
object.name = message.name;
|
|
16417
|
+
if (message.values != null && message.hasOwnProperty("values"))
|
|
16418
|
+
object.values = message.values;
|
|
16419
|
+
return object;
|
|
16420
|
+
};
|
|
16421
|
+
|
|
16422
|
+
/**
|
|
16423
|
+
* Converts this Bound to JSON.
|
|
16424
|
+
* @function toJSON
|
|
16425
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16426
|
+
* @instance
|
|
16427
|
+
* @returns {Object.<string,*>} JSON object
|
|
16428
|
+
*/
|
|
16429
|
+
Bound.prototype.toJSON = function toJSON() {
|
|
16430
|
+
return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
|
|
16431
|
+
};
|
|
16432
|
+
|
|
16433
|
+
/**
|
|
16434
|
+
* Gets the default type url for Bound
|
|
16435
|
+
* @function getTypeUrl
|
|
16436
|
+
* @memberof sqlanvil.MysqlOptions.Partition.Bound
|
|
16437
|
+
* @static
|
|
16438
|
+
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
|
16439
|
+
* @returns {string} The default type url
|
|
16440
|
+
*/
|
|
16441
|
+
Bound.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
|
16442
|
+
if (typeUrlPrefix === undefined) {
|
|
16443
|
+
typeUrlPrefix = "type.googleapis.com";
|
|
16444
|
+
}
|
|
16445
|
+
return typeUrlPrefix + "/sqlanvil.MysqlOptions.Partition.Bound";
|
|
16446
|
+
};
|
|
16447
|
+
|
|
16448
|
+
return Bound;
|
|
16449
|
+
})();
|
|
16450
|
+
|
|
16451
|
+
return Partition;
|
|
16452
|
+
})();
|
|
16453
|
+
|
|
15829
16454
|
return MysqlOptions;
|
|
15830
16455
|
})();
|
|
15831
16456
|
|
|
@@ -43245,7 +43870,7 @@ class MysqlExecutionSql {
|
|
|
43245
43870
|
if (table.materialized) {
|
|
43246
43871
|
tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.VIEW)));
|
|
43247
43872
|
tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
|
|
43248
|
-
tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
|
|
43873
|
+
tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)}${this.partitionClause(table)} as ${table.query}`));
|
|
43249
43874
|
this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
|
|
43250
43875
|
}
|
|
43251
43876
|
else {
|
|
@@ -43256,7 +43881,7 @@ class MysqlExecutionSql {
|
|
|
43256
43881
|
const fresh = !this.shouldWriteIncrementally(table, runConfig, tableMetadata);
|
|
43257
43882
|
if (fresh) {
|
|
43258
43883
|
tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
|
|
43259
|
-
tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
|
|
43884
|
+
tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)}${this.partitionClause(table)} as ${table.query}`));
|
|
43260
43885
|
if (table.uniqueKey && table.uniqueKey.length > 0) {
|
|
43261
43886
|
const idx = `uq_${table.target.schema}_${table.target.name}`.slice(0, 63);
|
|
43262
43887
|
const cols = table.uniqueKey.map(k => `\`${k}\``).join(", ");
|
|
@@ -43270,7 +43895,7 @@ class MysqlExecutionSql {
|
|
|
43270
43895
|
}
|
|
43271
43896
|
else {
|
|
43272
43897
|
tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
|
|
43273
|
-
tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
|
|
43898
|
+
tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)}${this.partitionClause(table)} as ${table.query}`));
|
|
43274
43899
|
this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
|
|
43275
43900
|
}
|
|
43276
43901
|
this.postOps(table, runConfig, tableMetadata).forEach(task => tasks.add(task));
|
|
@@ -43328,6 +43953,34 @@ class MysqlExecutionSql {
|
|
|
43328
43953
|
const tail = updates.length > 0 ? ` on duplicate key update ${updates}` : "";
|
|
43329
43954
|
return `insert into ${target} (${backticked.join(", ")}) select ${backticked.join(", ")} from (${query}) as insertions${tail}`;
|
|
43330
43955
|
}
|
|
43956
|
+
partitionKindAsSql(kind) {
|
|
43957
|
+
switch (kind) {
|
|
43958
|
+
case sqlanvil.MysqlOptions.Partition.Kind.LIST:
|
|
43959
|
+
return "list";
|
|
43960
|
+
case sqlanvil.MysqlOptions.Partition.Kind.HASH:
|
|
43961
|
+
return "hash";
|
|
43962
|
+
case sqlanvil.MysqlOptions.Partition.Kind.KEY:
|
|
43963
|
+
return "key";
|
|
43964
|
+
case sqlanvil.MysqlOptions.Partition.Kind.RANGE:
|
|
43965
|
+
default:
|
|
43966
|
+
return "range";
|
|
43967
|
+
}
|
|
43968
|
+
}
|
|
43969
|
+
partitionClause(table) {
|
|
43970
|
+
const partition = table.mysql && table.mysql.partition;
|
|
43971
|
+
if (!partition) {
|
|
43972
|
+
return "";
|
|
43973
|
+
}
|
|
43974
|
+
const kind = this.partitionKindAsSql(partition.kind);
|
|
43975
|
+
const head = ` partition by ${kind} (${partition.expression})`;
|
|
43976
|
+
if (kind === "hash" || kind === "key") {
|
|
43977
|
+
return partition.count ? `${head} partitions ${partition.count}` : head;
|
|
43978
|
+
}
|
|
43979
|
+
const defs = (partition.partitions || [])
|
|
43980
|
+
.map(bound => `partition ${bound.name} ${bound.values}`)
|
|
43981
|
+
.join(", ");
|
|
43982
|
+
return `${head} (${defs})`;
|
|
43983
|
+
}
|
|
43331
43984
|
tableOptions(table) {
|
|
43332
43985
|
const opts = table.mysql;
|
|
43333
43986
|
if (!opts) {
|
|
@@ -43792,7 +44445,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
|
|
|
43792
44445
|
.filter(validationQuery => !!validationQuery.query);
|
|
43793
44446
|
}
|
|
43794
44447
|
|
|
43795
|
-
const version = "1.
|
|
44448
|
+
const version = "1.11.0";
|
|
43796
44449
|
const dataformVersion = "3.0.60";
|
|
43797
44450
|
|
|
43798
44451
|
async function build(compiledGraph, runConfig, dbadapter) {
|
|
@@ -44291,6 +44944,9 @@ function mapBigQueryType(bqType) {
|
|
|
44291
44944
|
function mapPostgresType(pgType) {
|
|
44292
44945
|
return pgType.trim().toLowerCase();
|
|
44293
44946
|
}
|
|
44947
|
+
function mapMysqlType(mysqlType) {
|
|
44948
|
+
return mysqlType.trim().toLowerCase();
|
|
44949
|
+
}
|
|
44294
44950
|
function keyToken(name) {
|
|
44295
44951
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : `"${name}"`;
|
|
44296
44952
|
}
|
|
@@ -44392,6 +45048,40 @@ const readBigQuerySchema = function (resolved, sourceSchema, table) {
|
|
|
44392
45048
|
});
|
|
44393
45049
|
});
|
|
44394
45050
|
};
|
|
45051
|
+
const readMysqlSchema = function (resolved, sourceSchema, table) {
|
|
45052
|
+
const c = resolved.credentials;
|
|
45053
|
+
let conn;
|
|
45054
|
+
return mysql__namespace
|
|
45055
|
+
.createConnection({
|
|
45056
|
+
host: c.host || resolved.definition.host,
|
|
45057
|
+
port: Number(c.port || resolved.definition.port || 3306),
|
|
45058
|
+
database: c.database || resolved.definition.database,
|
|
45059
|
+
user: c.user,
|
|
45060
|
+
password: c.password,
|
|
45061
|
+
ssl: c.sslMode && c.sslMode !== "disable" ? { rejectUnauthorized: false } : undefined
|
|
45062
|
+
})
|
|
45063
|
+
.then(function (connection) {
|
|
45064
|
+
conn = connection;
|
|
45065
|
+
return conn.query(`select column_name, data_type, column_comment
|
|
45066
|
+
from information_schema.columns
|
|
45067
|
+
where table_schema = ? and table_name = ?
|
|
45068
|
+
order by ordinal_position`, [sourceSchema, table]);
|
|
45069
|
+
})
|
|
45070
|
+
.then(function (result) {
|
|
45071
|
+
const rows = result[0] || [];
|
|
45072
|
+
return rows.map(function (r) {
|
|
45073
|
+
const name = r.column_name !== undefined ? r.column_name : r.COLUMN_NAME;
|
|
45074
|
+
const type = r.data_type !== undefined ? r.data_type : r.DATA_TYPE;
|
|
45075
|
+
const comment = r.column_comment !== undefined ? r.column_comment : r.COLUMN_COMMENT;
|
|
45076
|
+
return { name, type, description: comment || undefined };
|
|
45077
|
+
});
|
|
45078
|
+
})
|
|
45079
|
+
.then(function (cols) {
|
|
45080
|
+
return conn.end().then(function () { return cols; });
|
|
45081
|
+
}, function (err) {
|
|
45082
|
+
return (conn ? conn.end() : Promise.resolve()).then(function () { throw err; }, function () { throw err; });
|
|
45083
|
+
});
|
|
45084
|
+
};
|
|
44395
45085
|
function defaultReaderFor(platform) {
|
|
44396
45086
|
if (platform === "bigquery") {
|
|
44397
45087
|
return readBigQuerySchema;
|
|
@@ -44399,6 +45089,9 @@ function defaultReaderFor(platform) {
|
|
|
44399
45089
|
if (platform === "postgres" || platform === "supabase") {
|
|
44400
45090
|
return readPostgresSchema;
|
|
44401
45091
|
}
|
|
45092
|
+
if (platform === "mysql") {
|
|
45093
|
+
return readMysqlSchema;
|
|
45094
|
+
}
|
|
44402
45095
|
throw new Error(`introspect does not support source platform "${platform}".`);
|
|
44403
45096
|
}
|
|
44404
45097
|
function splitTableRef(tableRef) {
|
|
@@ -44417,7 +45110,11 @@ function introspectToSqlx(projectDir, connectionName, tableRef, options) {
|
|
|
44417
45110
|
return Promise.reject(new Error(`Could not determine the source schema for "${tableRef}" on connection "${connectionName}". ` +
|
|
44418
45111
|
`Pass it as "schema.table", or set "dataset"/"defaultSchema" on the connection.`));
|
|
44419
45112
|
}
|
|
44420
|
-
const mapType = resolved.definition.platform === "bigquery"
|
|
45113
|
+
const mapType = resolved.definition.platform === "bigquery"
|
|
45114
|
+
? mapBigQueryType
|
|
45115
|
+
: resolved.definition.platform === "mysql"
|
|
45116
|
+
? mapMysqlType
|
|
45117
|
+
: mapPostgresType;
|
|
44421
45118
|
return reader(resolved, sourceSchema, parts.table).then(function (rawColumns) {
|
|
44422
45119
|
if (rawColumns.length === 0) {
|
|
44423
45120
|
throw new Error(`Source table "${tableRef}" on connection "${connectionName}" has no columns (does it exist?).`);
|