@sqlanvil/cli 1.5.0 → 1.6.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.
Files changed (3) hide show
  1. package/bundle.js +795 -13
  2. package/package.json +1 -1
  3. package/worker_bundle.js +650 -0
package/bundle.js CHANGED
@@ -3818,6 +3818,7 @@ const sqlanvil = $root.sqlanvil = (() => {
3818
3818
  * @property {string|null} [reservation] TableConfig reservation
3819
3819
  * @property {sqlanvil.IPostgresOptions|null} [postgres] TableConfig postgres
3820
3820
  * @property {sqlanvil.ISupabaseOptions|null} [supabase] TableConfig supabase
3821
+ * @property {sqlanvil.IMysqlOptions|null} [mysql] TableConfig mysql
3821
3822
  */
3822
3823
 
3823
3824
  /**
@@ -4043,6 +4044,14 @@ const sqlanvil = $root.sqlanvil = (() => {
4043
4044
  */
4044
4045
  TableConfig.prototype.supabase = null;
4045
4046
 
4047
+ /**
4048
+ * TableConfig mysql.
4049
+ * @member {sqlanvil.IMysqlOptions|null|undefined} mysql
4050
+ * @memberof sqlanvil.ActionConfig.TableConfig
4051
+ * @instance
4052
+ */
4053
+ TableConfig.prototype.mysql = null;
4054
+
4046
4055
  /**
4047
4056
  * Creates a new TableConfig instance using the specified properties.
4048
4057
  * @function create
@@ -4125,6 +4134,8 @@ const sqlanvil = $root.sqlanvil = (() => {
4125
4134
  $root.sqlanvil.PostgresOptions.encode(message.postgres, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim();
4126
4135
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
4127
4136
  $root.sqlanvil.SupabaseOptions.encode(message.supabase, writer.uint32(/* id 26, wireType 2 =*/210).fork()).ldelim();
4137
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
4138
+ $root.sqlanvil.MysqlOptions.encode(message.mysql, writer.uint32(/* id 27, wireType 2 =*/218).fork()).ldelim();
4128
4139
  return writer;
4129
4140
  };
4130
4141
 
@@ -4311,6 +4322,10 @@ const sqlanvil = $root.sqlanvil = (() => {
4311
4322
  message.supabase = $root.sqlanvil.SupabaseOptions.decode(reader, reader.uint32());
4312
4323
  break;
4313
4324
  }
4325
+ case 27: {
4326
+ message.mysql = $root.sqlanvil.MysqlOptions.decode(reader, reader.uint32());
4327
+ break;
4328
+ }
4314
4329
  default:
4315
4330
  reader.skipType(tag & 7);
4316
4331
  break;
@@ -4469,6 +4484,11 @@ const sqlanvil = $root.sqlanvil = (() => {
4469
4484
  if (error)
4470
4485
  return "supabase." + error;
4471
4486
  }
4487
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
4488
+ let error = $root.sqlanvil.MysqlOptions.verify(message.mysql);
4489
+ if (error)
4490
+ return "mysql." + error;
4491
+ }
4472
4492
  return null;
4473
4493
  };
4474
4494
 
@@ -4595,6 +4615,11 @@ const sqlanvil = $root.sqlanvil = (() => {
4595
4615
  throw TypeError(".sqlanvil.ActionConfig.TableConfig.supabase: object expected");
4596
4616
  message.supabase = $root.sqlanvil.SupabaseOptions.fromObject(object.supabase);
4597
4617
  }
4618
+ if (object.mysql != null) {
4619
+ if (typeof object.mysql !== "object")
4620
+ throw TypeError(".sqlanvil.ActionConfig.TableConfig.mysql: object expected");
4621
+ message.mysql = $root.sqlanvil.MysqlOptions.fromObject(object.mysql);
4622
+ }
4598
4623
  return message;
4599
4624
  };
4600
4625
 
@@ -4641,6 +4666,7 @@ const sqlanvil = $root.sqlanvil = (() => {
4641
4666
  object.reservation = "";
4642
4667
  object.postgres = null;
4643
4668
  object.supabase = null;
4669
+ object.mysql = null;
4644
4670
  }
4645
4671
  if (message.name != null && message.hasOwnProperty("name"))
4646
4672
  object.name = message.name;
@@ -4717,6 +4743,8 @@ const sqlanvil = $root.sqlanvil = (() => {
4717
4743
  object.postgres = $root.sqlanvil.PostgresOptions.toObject(message.postgres, options);
4718
4744
  if (message.supabase != null && message.hasOwnProperty("supabase"))
4719
4745
  object.supabase = $root.sqlanvil.SupabaseOptions.toObject(message.supabase, options);
4746
+ if (message.mysql != null && message.hasOwnProperty("mysql"))
4747
+ object.mysql = $root.sqlanvil.MysqlOptions.toObject(message.mysql, options);
4720
4748
  return object;
4721
4749
  };
4722
4750
 
@@ -5919,6 +5947,7 @@ const sqlanvil = $root.sqlanvil = (() => {
5919
5947
  * @property {string|null} [reservation] IncrementalTableConfig reservation
5920
5948
  * @property {sqlanvil.IPostgresOptions|null} [postgres] IncrementalTableConfig postgres
5921
5949
  * @property {sqlanvil.ISupabaseOptions|null} [supabase] IncrementalTableConfig supabase
5950
+ * @property {sqlanvil.IMysqlOptions|null} [mysql] IncrementalTableConfig mysql
5922
5951
  */
5923
5952
 
5924
5953
  /**
@@ -6177,6 +6206,14 @@ const sqlanvil = $root.sqlanvil = (() => {
6177
6206
  */
6178
6207
  IncrementalTableConfig.prototype.supabase = null;
6179
6208
 
6209
+ /**
6210
+ * IncrementalTableConfig mysql.
6211
+ * @member {sqlanvil.IMysqlOptions|null|undefined} mysql
6212
+ * @memberof sqlanvil.ActionConfig.IncrementalTableConfig
6213
+ * @instance
6214
+ */
6215
+ IncrementalTableConfig.prototype.mysql = null;
6216
+
6180
6217
  /**
6181
6218
  * Creates a new IncrementalTableConfig instance using the specified properties.
6182
6219
  * @function create
@@ -6268,6 +6305,8 @@ const sqlanvil = $root.sqlanvil = (() => {
6268
6305
  $root.sqlanvil.PostgresOptions.encode(message.postgres, writer.uint32(/* id 28, wireType 2 =*/226).fork()).ldelim();
6269
6306
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
6270
6307
  $root.sqlanvil.SupabaseOptions.encode(message.supabase, writer.uint32(/* id 29, wireType 2 =*/234).fork()).ldelim();
6308
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
6309
+ $root.sqlanvil.MysqlOptions.encode(message.mysql, writer.uint32(/* id 30, wireType 2 =*/242).fork()).ldelim();
6271
6310
  return writer;
6272
6311
  };
6273
6312
 
@@ -6472,6 +6511,10 @@ const sqlanvil = $root.sqlanvil = (() => {
6472
6511
  message.supabase = $root.sqlanvil.SupabaseOptions.decode(reader, reader.uint32());
6473
6512
  break;
6474
6513
  }
6514
+ case 30: {
6515
+ message.mysql = $root.sqlanvil.MysqlOptions.decode(reader, reader.uint32());
6516
+ break;
6517
+ }
6475
6518
  default:
6476
6519
  reader.skipType(tag & 7);
6477
6520
  break;
@@ -6653,6 +6696,11 @@ const sqlanvil = $root.sqlanvil = (() => {
6653
6696
  if (error)
6654
6697
  return "supabase." + error;
6655
6698
  }
6699
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
6700
+ let error = $root.sqlanvil.MysqlOptions.verify(message.mysql);
6701
+ if (error)
6702
+ return "mysql." + error;
6703
+ }
6656
6704
  return null;
6657
6705
  };
6658
6706
 
@@ -6814,6 +6862,11 @@ const sqlanvil = $root.sqlanvil = (() => {
6814
6862
  throw TypeError(".sqlanvil.ActionConfig.IncrementalTableConfig.supabase: object expected");
6815
6863
  message.supabase = $root.sqlanvil.SupabaseOptions.fromObject(object.supabase);
6816
6864
  }
6865
+ if (object.mysql != null) {
6866
+ if (typeof object.mysql !== "object")
6867
+ throw TypeError(".sqlanvil.ActionConfig.IncrementalTableConfig.mysql: object expected");
6868
+ message.mysql = $root.sqlanvil.MysqlOptions.fromObject(object.mysql);
6869
+ }
6817
6870
  return message;
6818
6871
  };
6819
6872
 
@@ -6864,6 +6917,7 @@ const sqlanvil = $root.sqlanvil = (() => {
6864
6917
  object.reservation = "";
6865
6918
  object.postgres = null;
6866
6919
  object.supabase = null;
6920
+ object.mysql = null;
6867
6921
  }
6868
6922
  if (message.name != null && message.hasOwnProperty("name"))
6869
6923
  object.name = message.name;
@@ -6951,6 +7005,8 @@ const sqlanvil = $root.sqlanvil = (() => {
6951
7005
  object.postgres = $root.sqlanvil.PostgresOptions.toObject(message.postgres, options);
6952
7006
  if (message.supabase != null && message.hasOwnProperty("supabase"))
6953
7007
  object.supabase = $root.sqlanvil.SupabaseOptions.toObject(message.supabase, options);
7008
+ if (message.mysql != null && message.hasOwnProperty("mysql"))
7009
+ object.mysql = $root.sqlanvil.MysqlOptions.toObject(message.mysql, options);
6954
7010
  return object;
6955
7011
  };
6956
7012
 
@@ -13411,6 +13467,572 @@ const sqlanvil = $root.sqlanvil = (() => {
13411
13467
  return PostgresOptions;
13412
13468
  })();
13413
13469
 
13470
+ sqlanvil.MysqlOptions = (function() {
13471
+
13472
+ /**
13473
+ * Properties of a MysqlOptions.
13474
+ * @memberof sqlanvil
13475
+ * @interface IMysqlOptions
13476
+ * @property {string|null} [engine] MysqlOptions engine
13477
+ * @property {string|null} [charset] MysqlOptions charset
13478
+ * @property {string|null} [collation] MysqlOptions collation
13479
+ * @property {Array.<sqlanvil.MysqlOptions.IIndex>|null} [indexes] MysqlOptions indexes
13480
+ */
13481
+
13482
+ /**
13483
+ * Constructs a new MysqlOptions.
13484
+ * @memberof sqlanvil
13485
+ * @classdesc Represents a MysqlOptions.
13486
+ * @implements IMysqlOptions
13487
+ * @constructor
13488
+ * @param {sqlanvil.IMysqlOptions=} [properties] Properties to set
13489
+ */
13490
+ function MysqlOptions(properties) {
13491
+ this.indexes = [];
13492
+ if (properties)
13493
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
13494
+ if (properties[keys[i]] != null)
13495
+ this[keys[i]] = properties[keys[i]];
13496
+ }
13497
+
13498
+ /**
13499
+ * MysqlOptions engine.
13500
+ * @member {string} engine
13501
+ * @memberof sqlanvil.MysqlOptions
13502
+ * @instance
13503
+ */
13504
+ MysqlOptions.prototype.engine = "";
13505
+
13506
+ /**
13507
+ * MysqlOptions charset.
13508
+ * @member {string} charset
13509
+ * @memberof sqlanvil.MysqlOptions
13510
+ * @instance
13511
+ */
13512
+ MysqlOptions.prototype.charset = "";
13513
+
13514
+ /**
13515
+ * MysqlOptions collation.
13516
+ * @member {string} collation
13517
+ * @memberof sqlanvil.MysqlOptions
13518
+ * @instance
13519
+ */
13520
+ MysqlOptions.prototype.collation = "";
13521
+
13522
+ /**
13523
+ * MysqlOptions indexes.
13524
+ * @member {Array.<sqlanvil.MysqlOptions.IIndex>} indexes
13525
+ * @memberof sqlanvil.MysqlOptions
13526
+ * @instance
13527
+ */
13528
+ MysqlOptions.prototype.indexes = $util.emptyArray;
13529
+
13530
+ /**
13531
+ * Creates a new MysqlOptions instance using the specified properties.
13532
+ * @function create
13533
+ * @memberof sqlanvil.MysqlOptions
13534
+ * @static
13535
+ * @param {sqlanvil.IMysqlOptions=} [properties] Properties to set
13536
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions instance
13537
+ */
13538
+ MysqlOptions.create = function create(properties) {
13539
+ return new MysqlOptions(properties);
13540
+ };
13541
+
13542
+ /**
13543
+ * Encodes the specified MysqlOptions message. Does not implicitly {@link sqlanvil.MysqlOptions.verify|verify} messages.
13544
+ * @function encode
13545
+ * @memberof sqlanvil.MysqlOptions
13546
+ * @static
13547
+ * @param {sqlanvil.IMysqlOptions} message MysqlOptions message or plain object to encode
13548
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13549
+ * @returns {$protobuf.Writer} Writer
13550
+ */
13551
+ MysqlOptions.encode = function encode(message, writer) {
13552
+ if (!writer)
13553
+ writer = $Writer.create();
13554
+ if (message.engine != null && Object.hasOwnProperty.call(message, "engine"))
13555
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.engine);
13556
+ if (message.charset != null && Object.hasOwnProperty.call(message, "charset"))
13557
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.charset);
13558
+ if (message.collation != null && Object.hasOwnProperty.call(message, "collation"))
13559
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.collation);
13560
+ if (message.indexes != null && message.indexes.length)
13561
+ for (let i = 0; i < message.indexes.length; ++i)
13562
+ $root.sqlanvil.MysqlOptions.Index.encode(message.indexes[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
13563
+ return writer;
13564
+ };
13565
+
13566
+ /**
13567
+ * Encodes the specified MysqlOptions message, length delimited. Does not implicitly {@link sqlanvil.MysqlOptions.verify|verify} messages.
13568
+ * @function encodeDelimited
13569
+ * @memberof sqlanvil.MysqlOptions
13570
+ * @static
13571
+ * @param {sqlanvil.IMysqlOptions} message MysqlOptions message or plain object to encode
13572
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13573
+ * @returns {$protobuf.Writer} Writer
13574
+ */
13575
+ MysqlOptions.encodeDelimited = function encodeDelimited(message, writer) {
13576
+ return this.encode(message, writer).ldelim();
13577
+ };
13578
+
13579
+ /**
13580
+ * Decodes a MysqlOptions message from the specified reader or buffer.
13581
+ * @function decode
13582
+ * @memberof sqlanvil.MysqlOptions
13583
+ * @static
13584
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13585
+ * @param {number} [length] Message length if known beforehand
13586
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions
13587
+ * @throws {Error} If the payload is not a reader or valid buffer
13588
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13589
+ */
13590
+ MysqlOptions.decode = function decode(reader, length, error) {
13591
+ if (!(reader instanceof $Reader))
13592
+ reader = $Reader.create(reader);
13593
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlOptions();
13594
+ while (reader.pos < end) {
13595
+ let tag = reader.uint32();
13596
+ if (tag === error)
13597
+ break;
13598
+ switch (tag >>> 3) {
13599
+ case 1: {
13600
+ message.engine = reader.string();
13601
+ break;
13602
+ }
13603
+ case 2: {
13604
+ message.charset = reader.string();
13605
+ break;
13606
+ }
13607
+ case 3: {
13608
+ message.collation = reader.string();
13609
+ break;
13610
+ }
13611
+ case 4: {
13612
+ if (!(message.indexes && message.indexes.length))
13613
+ message.indexes = [];
13614
+ message.indexes.push($root.sqlanvil.MysqlOptions.Index.decode(reader, reader.uint32()));
13615
+ break;
13616
+ }
13617
+ default:
13618
+ reader.skipType(tag & 7);
13619
+ break;
13620
+ }
13621
+ }
13622
+ return message;
13623
+ };
13624
+
13625
+ /**
13626
+ * Decodes a MysqlOptions message from the specified reader or buffer, length delimited.
13627
+ * @function decodeDelimited
13628
+ * @memberof sqlanvil.MysqlOptions
13629
+ * @static
13630
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13631
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions
13632
+ * @throws {Error} If the payload is not a reader or valid buffer
13633
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13634
+ */
13635
+ MysqlOptions.decodeDelimited = function decodeDelimited(reader) {
13636
+ if (!(reader instanceof $Reader))
13637
+ reader = new $Reader(reader);
13638
+ return this.decode(reader, reader.uint32());
13639
+ };
13640
+
13641
+ /**
13642
+ * Verifies a MysqlOptions message.
13643
+ * @function verify
13644
+ * @memberof sqlanvil.MysqlOptions
13645
+ * @static
13646
+ * @param {Object.<string,*>} message Plain object to verify
13647
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
13648
+ */
13649
+ MysqlOptions.verify = function verify(message) {
13650
+ if (typeof message !== "object" || message === null)
13651
+ return "object expected";
13652
+ if (message.engine != null && message.hasOwnProperty("engine"))
13653
+ if (!$util.isString(message.engine))
13654
+ return "engine: string expected";
13655
+ if (message.charset != null && message.hasOwnProperty("charset"))
13656
+ if (!$util.isString(message.charset))
13657
+ return "charset: string expected";
13658
+ if (message.collation != null && message.hasOwnProperty("collation"))
13659
+ if (!$util.isString(message.collation))
13660
+ return "collation: string expected";
13661
+ if (message.indexes != null && message.hasOwnProperty("indexes")) {
13662
+ if (!Array.isArray(message.indexes))
13663
+ return "indexes: array expected";
13664
+ for (let i = 0; i < message.indexes.length; ++i) {
13665
+ let error = $root.sqlanvil.MysqlOptions.Index.verify(message.indexes[i]);
13666
+ if (error)
13667
+ return "indexes." + error;
13668
+ }
13669
+ }
13670
+ return null;
13671
+ };
13672
+
13673
+ /**
13674
+ * Creates a MysqlOptions message from a plain object. Also converts values to their respective internal types.
13675
+ * @function fromObject
13676
+ * @memberof sqlanvil.MysqlOptions
13677
+ * @static
13678
+ * @param {Object.<string,*>} object Plain object
13679
+ * @returns {sqlanvil.MysqlOptions} MysqlOptions
13680
+ */
13681
+ MysqlOptions.fromObject = function fromObject(object) {
13682
+ if (object instanceof $root.sqlanvil.MysqlOptions)
13683
+ return object;
13684
+ let message = new $root.sqlanvil.MysqlOptions();
13685
+ if (object.engine != null)
13686
+ message.engine = String(object.engine);
13687
+ if (object.charset != null)
13688
+ message.charset = String(object.charset);
13689
+ if (object.collation != null)
13690
+ message.collation = String(object.collation);
13691
+ if (object.indexes) {
13692
+ if (!Array.isArray(object.indexes))
13693
+ throw TypeError(".sqlanvil.MysqlOptions.indexes: array expected");
13694
+ message.indexes = [];
13695
+ for (let i = 0; i < object.indexes.length; ++i) {
13696
+ if (typeof object.indexes[i] !== "object")
13697
+ throw TypeError(".sqlanvil.MysqlOptions.indexes: object expected");
13698
+ message.indexes[i] = $root.sqlanvil.MysqlOptions.Index.fromObject(object.indexes[i]);
13699
+ }
13700
+ }
13701
+ return message;
13702
+ };
13703
+
13704
+ /**
13705
+ * Creates a plain object from a MysqlOptions message. Also converts values to other types if specified.
13706
+ * @function toObject
13707
+ * @memberof sqlanvil.MysqlOptions
13708
+ * @static
13709
+ * @param {sqlanvil.MysqlOptions} message MysqlOptions
13710
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
13711
+ * @returns {Object.<string,*>} Plain object
13712
+ */
13713
+ MysqlOptions.toObject = function toObject(message, options) {
13714
+ if (!options)
13715
+ options = {};
13716
+ let object = {};
13717
+ if (options.arrays || options.defaults)
13718
+ object.indexes = [];
13719
+ if (options.defaults) {
13720
+ object.engine = "";
13721
+ object.charset = "";
13722
+ object.collation = "";
13723
+ }
13724
+ if (message.engine != null && message.hasOwnProperty("engine"))
13725
+ object.engine = message.engine;
13726
+ if (message.charset != null && message.hasOwnProperty("charset"))
13727
+ object.charset = message.charset;
13728
+ if (message.collation != null && message.hasOwnProperty("collation"))
13729
+ object.collation = message.collation;
13730
+ if (message.indexes && message.indexes.length) {
13731
+ object.indexes = [];
13732
+ for (let j = 0; j < message.indexes.length; ++j)
13733
+ object.indexes[j] = $root.sqlanvil.MysqlOptions.Index.toObject(message.indexes[j], options);
13734
+ }
13735
+ return object;
13736
+ };
13737
+
13738
+ /**
13739
+ * Converts this MysqlOptions to JSON.
13740
+ * @function toJSON
13741
+ * @memberof sqlanvil.MysqlOptions
13742
+ * @instance
13743
+ * @returns {Object.<string,*>} JSON object
13744
+ */
13745
+ MysqlOptions.prototype.toJSON = function toJSON() {
13746
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
13747
+ };
13748
+
13749
+ /**
13750
+ * Gets the default type url for MysqlOptions
13751
+ * @function getTypeUrl
13752
+ * @memberof sqlanvil.MysqlOptions
13753
+ * @static
13754
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
13755
+ * @returns {string} The default type url
13756
+ */
13757
+ MysqlOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
13758
+ if (typeUrlPrefix === undefined) {
13759
+ typeUrlPrefix = "type.googleapis.com";
13760
+ }
13761
+ return typeUrlPrefix + "/sqlanvil.MysqlOptions";
13762
+ };
13763
+
13764
+ MysqlOptions.Index = (function() {
13765
+
13766
+ /**
13767
+ * Properties of an Index.
13768
+ * @memberof sqlanvil.MysqlOptions
13769
+ * @interface IIndex
13770
+ * @property {string|null} [name] Index name
13771
+ * @property {Array.<string>|null} [columns] Index columns
13772
+ * @property {boolean|null} [unique] Index unique
13773
+ */
13774
+
13775
+ /**
13776
+ * Constructs a new Index.
13777
+ * @memberof sqlanvil.MysqlOptions
13778
+ * @classdesc Represents an Index.
13779
+ * @implements IIndex
13780
+ * @constructor
13781
+ * @param {sqlanvil.MysqlOptions.IIndex=} [properties] Properties to set
13782
+ */
13783
+ function Index(properties) {
13784
+ this.columns = [];
13785
+ if (properties)
13786
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
13787
+ if (properties[keys[i]] != null)
13788
+ this[keys[i]] = properties[keys[i]];
13789
+ }
13790
+
13791
+ /**
13792
+ * Index name.
13793
+ * @member {string} name
13794
+ * @memberof sqlanvil.MysqlOptions.Index
13795
+ * @instance
13796
+ */
13797
+ Index.prototype.name = "";
13798
+
13799
+ /**
13800
+ * Index columns.
13801
+ * @member {Array.<string>} columns
13802
+ * @memberof sqlanvil.MysqlOptions.Index
13803
+ * @instance
13804
+ */
13805
+ Index.prototype.columns = $util.emptyArray;
13806
+
13807
+ /**
13808
+ * Index unique.
13809
+ * @member {boolean} unique
13810
+ * @memberof sqlanvil.MysqlOptions.Index
13811
+ * @instance
13812
+ */
13813
+ Index.prototype.unique = false;
13814
+
13815
+ /**
13816
+ * Creates a new Index instance using the specified properties.
13817
+ * @function create
13818
+ * @memberof sqlanvil.MysqlOptions.Index
13819
+ * @static
13820
+ * @param {sqlanvil.MysqlOptions.IIndex=} [properties] Properties to set
13821
+ * @returns {sqlanvil.MysqlOptions.Index} Index instance
13822
+ */
13823
+ Index.create = function create(properties) {
13824
+ return new Index(properties);
13825
+ };
13826
+
13827
+ /**
13828
+ * Encodes the specified Index message. Does not implicitly {@link sqlanvil.MysqlOptions.Index.verify|verify} messages.
13829
+ * @function encode
13830
+ * @memberof sqlanvil.MysqlOptions.Index
13831
+ * @static
13832
+ * @param {sqlanvil.MysqlOptions.IIndex} message Index message or plain object to encode
13833
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13834
+ * @returns {$protobuf.Writer} Writer
13835
+ */
13836
+ Index.encode = function encode(message, writer) {
13837
+ if (!writer)
13838
+ writer = $Writer.create();
13839
+ if (message.name != null && Object.hasOwnProperty.call(message, "name"))
13840
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
13841
+ if (message.columns != null && message.columns.length)
13842
+ for (let i = 0; i < message.columns.length; ++i)
13843
+ writer.uint32(/* id 2, wireType 2 =*/18).string(message.columns[i]);
13844
+ if (message.unique != null && Object.hasOwnProperty.call(message, "unique"))
13845
+ writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unique);
13846
+ return writer;
13847
+ };
13848
+
13849
+ /**
13850
+ * Encodes the specified Index message, length delimited. Does not implicitly {@link sqlanvil.MysqlOptions.Index.verify|verify} messages.
13851
+ * @function encodeDelimited
13852
+ * @memberof sqlanvil.MysqlOptions.Index
13853
+ * @static
13854
+ * @param {sqlanvil.MysqlOptions.IIndex} message Index message or plain object to encode
13855
+ * @param {$protobuf.Writer} [writer] Writer to encode to
13856
+ * @returns {$protobuf.Writer} Writer
13857
+ */
13858
+ Index.encodeDelimited = function encodeDelimited(message, writer) {
13859
+ return this.encode(message, writer).ldelim();
13860
+ };
13861
+
13862
+ /**
13863
+ * Decodes an Index message from the specified reader or buffer.
13864
+ * @function decode
13865
+ * @memberof sqlanvil.MysqlOptions.Index
13866
+ * @static
13867
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13868
+ * @param {number} [length] Message length if known beforehand
13869
+ * @returns {sqlanvil.MysqlOptions.Index} Index
13870
+ * @throws {Error} If the payload is not a reader or valid buffer
13871
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13872
+ */
13873
+ Index.decode = function decode(reader, length, error) {
13874
+ if (!(reader instanceof $Reader))
13875
+ reader = $Reader.create(reader);
13876
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlOptions.Index();
13877
+ while (reader.pos < end) {
13878
+ let tag = reader.uint32();
13879
+ if (tag === error)
13880
+ break;
13881
+ switch (tag >>> 3) {
13882
+ case 1: {
13883
+ message.name = reader.string();
13884
+ break;
13885
+ }
13886
+ case 2: {
13887
+ if (!(message.columns && message.columns.length))
13888
+ message.columns = [];
13889
+ message.columns.push(reader.string());
13890
+ break;
13891
+ }
13892
+ case 3: {
13893
+ message.unique = reader.bool();
13894
+ break;
13895
+ }
13896
+ default:
13897
+ reader.skipType(tag & 7);
13898
+ break;
13899
+ }
13900
+ }
13901
+ return message;
13902
+ };
13903
+
13904
+ /**
13905
+ * Decodes an Index message from the specified reader or buffer, length delimited.
13906
+ * @function decodeDelimited
13907
+ * @memberof sqlanvil.MysqlOptions.Index
13908
+ * @static
13909
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
13910
+ * @returns {sqlanvil.MysqlOptions.Index} Index
13911
+ * @throws {Error} If the payload is not a reader or valid buffer
13912
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
13913
+ */
13914
+ Index.decodeDelimited = function decodeDelimited(reader) {
13915
+ if (!(reader instanceof $Reader))
13916
+ reader = new $Reader(reader);
13917
+ return this.decode(reader, reader.uint32());
13918
+ };
13919
+
13920
+ /**
13921
+ * Verifies an Index message.
13922
+ * @function verify
13923
+ * @memberof sqlanvil.MysqlOptions.Index
13924
+ * @static
13925
+ * @param {Object.<string,*>} message Plain object to verify
13926
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
13927
+ */
13928
+ Index.verify = function verify(message) {
13929
+ if (typeof message !== "object" || message === null)
13930
+ return "object expected";
13931
+ if (message.name != null && message.hasOwnProperty("name"))
13932
+ if (!$util.isString(message.name))
13933
+ return "name: string expected";
13934
+ if (message.columns != null && message.hasOwnProperty("columns")) {
13935
+ if (!Array.isArray(message.columns))
13936
+ return "columns: array expected";
13937
+ for (let i = 0; i < message.columns.length; ++i)
13938
+ if (!$util.isString(message.columns[i]))
13939
+ return "columns: string[] expected";
13940
+ }
13941
+ if (message.unique != null && message.hasOwnProperty("unique"))
13942
+ if (typeof message.unique !== "boolean")
13943
+ return "unique: boolean expected";
13944
+ return null;
13945
+ };
13946
+
13947
+ /**
13948
+ * Creates an Index message from a plain object. Also converts values to their respective internal types.
13949
+ * @function fromObject
13950
+ * @memberof sqlanvil.MysqlOptions.Index
13951
+ * @static
13952
+ * @param {Object.<string,*>} object Plain object
13953
+ * @returns {sqlanvil.MysqlOptions.Index} Index
13954
+ */
13955
+ Index.fromObject = function fromObject(object) {
13956
+ if (object instanceof $root.sqlanvil.MysqlOptions.Index)
13957
+ return object;
13958
+ let message = new $root.sqlanvil.MysqlOptions.Index();
13959
+ if (object.name != null)
13960
+ message.name = String(object.name);
13961
+ if (object.columns) {
13962
+ if (!Array.isArray(object.columns))
13963
+ throw TypeError(".sqlanvil.MysqlOptions.Index.columns: array expected");
13964
+ message.columns = [];
13965
+ for (let i = 0; i < object.columns.length; ++i)
13966
+ message.columns[i] = String(object.columns[i]);
13967
+ }
13968
+ if (object.unique != null)
13969
+ message.unique = Boolean(object.unique);
13970
+ return message;
13971
+ };
13972
+
13973
+ /**
13974
+ * Creates a plain object from an Index message. Also converts values to other types if specified.
13975
+ * @function toObject
13976
+ * @memberof sqlanvil.MysqlOptions.Index
13977
+ * @static
13978
+ * @param {sqlanvil.MysqlOptions.Index} message Index
13979
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
13980
+ * @returns {Object.<string,*>} Plain object
13981
+ */
13982
+ Index.toObject = function toObject(message, options) {
13983
+ if (!options)
13984
+ options = {};
13985
+ let object = {};
13986
+ if (options.arrays || options.defaults)
13987
+ object.columns = [];
13988
+ if (options.defaults) {
13989
+ object.name = "";
13990
+ object.unique = false;
13991
+ }
13992
+ if (message.name != null && message.hasOwnProperty("name"))
13993
+ object.name = message.name;
13994
+ if (message.columns && message.columns.length) {
13995
+ object.columns = [];
13996
+ for (let j = 0; j < message.columns.length; ++j)
13997
+ object.columns[j] = message.columns[j];
13998
+ }
13999
+ if (message.unique != null && message.hasOwnProperty("unique"))
14000
+ object.unique = message.unique;
14001
+ return object;
14002
+ };
14003
+
14004
+ /**
14005
+ * Converts this Index to JSON.
14006
+ * @function toJSON
14007
+ * @memberof sqlanvil.MysqlOptions.Index
14008
+ * @instance
14009
+ * @returns {Object.<string,*>} JSON object
14010
+ */
14011
+ Index.prototype.toJSON = function toJSON() {
14012
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
14013
+ };
14014
+
14015
+ /**
14016
+ * Gets the default type url for Index
14017
+ * @function getTypeUrl
14018
+ * @memberof sqlanvil.MysqlOptions.Index
14019
+ * @static
14020
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
14021
+ * @returns {string} The default type url
14022
+ */
14023
+ Index.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
14024
+ if (typeUrlPrefix === undefined) {
14025
+ typeUrlPrefix = "type.googleapis.com";
14026
+ }
14027
+ return typeUrlPrefix + "/sqlanvil.MysqlOptions.Index";
14028
+ };
14029
+
14030
+ return Index;
14031
+ })();
14032
+
14033
+ return MysqlOptions;
14034
+ })();
14035
+
13414
14036
  sqlanvil.SupabaseOptions = (function() {
13415
14037
 
13416
14038
  /**
@@ -19410,6 +20032,7 @@ const sqlanvil = $root.sqlanvil = (() => {
19410
20032
  * @property {sqlanvil.IBigQueryOptions|null} [bigquery] Table bigquery
19411
20033
  * @property {sqlanvil.IPostgresOptions|null} [postgres] Table postgres
19412
20034
  * @property {sqlanvil.ISupabaseOptions|null} [supabase] Table supabase
20035
+ * @property {sqlanvil.IMysqlOptions|null} [mysql] Table mysql
19413
20036
  * @property {string|null} [fileName] Table fileName
19414
20037
  */
19415
20038
 
@@ -19627,6 +20250,14 @@ const sqlanvil = $root.sqlanvil = (() => {
19627
20250
  */
19628
20251
  Table.prototype.supabase = null;
19629
20252
 
20253
+ /**
20254
+ * Table mysql.
20255
+ * @member {sqlanvil.IMysqlOptions|null|undefined} mysql
20256
+ * @memberof sqlanvil.Table
20257
+ * @instance
20258
+ */
20259
+ Table.prototype.mysql = null;
20260
+
19630
20261
  /**
19631
20262
  * Table fileName.
19632
20263
  * @member {string} fileName
@@ -19716,6 +20347,8 @@ const sqlanvil = $root.sqlanvil = (() => {
19716
20347
  $root.sqlanvil.PostgresOptions.encode(message.postgres, writer.uint32(/* id 39, wireType 2 =*/314).fork()).ldelim();
19717
20348
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
19718
20349
  $root.sqlanvil.SupabaseOptions.encode(message.supabase, writer.uint32(/* id 40, wireType 2 =*/322).fork()).ldelim();
20350
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
20351
+ $root.sqlanvil.MysqlOptions.encode(message.mysql, writer.uint32(/* id 41, wireType 2 =*/330).fork()).ldelim();
19719
20352
  return writer;
19720
20353
  };
19721
20354
 
@@ -19862,6 +20495,10 @@ const sqlanvil = $root.sqlanvil = (() => {
19862
20495
  message.supabase = $root.sqlanvil.SupabaseOptions.decode(reader, reader.uint32());
19863
20496
  break;
19864
20497
  }
20498
+ case 41: {
20499
+ message.mysql = $root.sqlanvil.MysqlOptions.decode(reader, reader.uint32());
20500
+ break;
20501
+ }
19865
20502
  case 18: {
19866
20503
  message.fileName = reader.string();
19867
20504
  break;
@@ -20035,6 +20672,11 @@ const sqlanvil = $root.sqlanvil = (() => {
20035
20672
  if (error)
20036
20673
  return "supabase." + error;
20037
20674
  }
20675
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
20676
+ let error = $root.sqlanvil.MysqlOptions.verify(message.mysql);
20677
+ if (error)
20678
+ return "mysql." + error;
20679
+ }
20038
20680
  if (message.fileName != null && message.hasOwnProperty("fileName"))
20039
20681
  if (!$util.isString(message.fileName))
20040
20682
  return "fileName: string expected";
@@ -20219,6 +20861,11 @@ const sqlanvil = $root.sqlanvil = (() => {
20219
20861
  throw TypeError(".sqlanvil.Table.supabase: object expected");
20220
20862
  message.supabase = $root.sqlanvil.SupabaseOptions.fromObject(object.supabase);
20221
20863
  }
20864
+ if (object.mysql != null) {
20865
+ if (typeof object.mysql !== "object")
20866
+ throw TypeError(".sqlanvil.Table.mysql: object expected");
20867
+ message.mysql = $root.sqlanvil.MysqlOptions.fromObject(object.mysql);
20868
+ }
20222
20869
  if (object.fileName != null)
20223
20870
  message.fileName = String(object.fileName);
20224
20871
  return message;
@@ -20265,6 +20912,7 @@ const sqlanvil = $root.sqlanvil = (() => {
20265
20912
  object.jitCode = "";
20266
20913
  object.postgres = null;
20267
20914
  object.supabase = null;
20915
+ object.mysql = null;
20268
20916
  }
20269
20917
  if (message.type != null && message.hasOwnProperty("type"))
20270
20918
  object.type = message.type;
@@ -20337,6 +20985,8 @@ const sqlanvil = $root.sqlanvil = (() => {
20337
20985
  object.postgres = $root.sqlanvil.PostgresOptions.toObject(message.postgres, options);
20338
20986
  if (message.supabase != null && message.hasOwnProperty("supabase"))
20339
20987
  object.supabase = $root.sqlanvil.SupabaseOptions.toObject(message.supabase, options);
20988
+ if (message.mysql != null && message.hasOwnProperty("mysql"))
20989
+ object.mysql = $root.sqlanvil.MysqlOptions.toObject(message.mysql, options);
20340
20990
  return object;
20341
20991
  };
20342
20992
 
@@ -38650,8 +39300,11 @@ class MysqlExecutionSql {
38650
39300
  const target = this.resolveTarget(table.target);
38651
39301
  if (table.enumType === sqlanvil.TableType.VIEW) {
38652
39302
  if (table.materialized) {
38653
- throw new Error(`Materialized views are not supported on mysql (action ${target}). ` +
38654
- `Use a table, or emulate refresh via operations.`);
39303
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.VIEW)));
39304
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
39305
+ tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
39306
+ this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
39307
+ return tasks;
38655
39308
  }
38656
39309
  tasks.add(Task.statement(`create or replace view ${target} as ${table.query}`));
38657
39310
  return tasks;
@@ -38660,12 +39313,13 @@ class MysqlExecutionSql {
38660
39313
  const fresh = !this.shouldWriteIncrementally(table, runConfig, tableMetadata);
38661
39314
  if (fresh) {
38662
39315
  tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
38663
- tasks.add(Task.statement(`create table ${target} as ${table.query}`));
39316
+ tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
38664
39317
  if (table.uniqueKey && table.uniqueKey.length > 0) {
38665
39318
  const idx = `uq_${table.target.schema}_${table.target.name}`.slice(0, 63);
38666
39319
  const cols = table.uniqueKey.map(k => `\`${k}\``).join(", ");
38667
39320
  tasks.add(Task.statement(`alter table ${target} add unique index \`${idx}\` (${cols})`));
38668
39321
  }
39322
+ this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
38669
39323
  }
38670
39324
  else {
38671
39325
  tasks.add(Task.statement(this.upsertInto(table, tableMetadata)));
@@ -38673,7 +39327,8 @@ class MysqlExecutionSql {
38673
39327
  return tasks;
38674
39328
  }
38675
39329
  tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
38676
- tasks.add(Task.statement(`create table ${target} as ${table.query}`));
39330
+ tasks.add(Task.statement(`create table ${target}${this.tableOptions(table)} as ${table.query}`));
39331
+ this.createIndexes(table).forEach(stmt => tasks.add(Task.statement(stmt)));
38677
39332
  return tasks;
38678
39333
  }
38679
39334
  assertTasks(assertion, projectConfig) {
@@ -38710,6 +39365,42 @@ class MysqlExecutionSql {
38710
39365
  const tail = updates.length > 0 ? ` on duplicate key update ${updates}` : "";
38711
39366
  return `insert into ${target} (${backticked.join(", ")}) select ${backticked.join(", ")} from (${query}) as insertions${tail}`;
38712
39367
  }
39368
+ tableOptions(table) {
39369
+ const opts = table.mysql;
39370
+ if (!opts) {
39371
+ return "";
39372
+ }
39373
+ let suffix = "";
39374
+ if (opts.engine) {
39375
+ suffix += ` engine=${opts.engine}`;
39376
+ }
39377
+ if (opts.charset) {
39378
+ suffix += ` default charset=${opts.charset}`;
39379
+ }
39380
+ if (opts.collation) {
39381
+ suffix += ` collate=${opts.collation}`;
39382
+ }
39383
+ return suffix;
39384
+ }
39385
+ createIndexes(table) {
39386
+ var _a;
39387
+ const indexes = (_a = table.mysql) === null || _a === void 0 ? void 0 : _a.indexes;
39388
+ if (!indexes || indexes.length === 0) {
39389
+ return [];
39390
+ }
39391
+ const target = this.resolveTarget(table.target);
39392
+ return indexes.map(index => {
39393
+ const unique = index.unique ? "unique " : "";
39394
+ const cols = (index.columns || []).map(c => `\`${c}\``).join(", ");
39395
+ const name = index.name || this.defaultIndexName(table.target.name, index.columns, !!index.unique);
39396
+ return `alter table ${target} add ${unique}index \`${name}\` (${cols})`;
39397
+ });
39398
+ }
39399
+ defaultIndexName(tableName, columns, unique) {
39400
+ const parts = [tableName, ...(columns || [])].filter(Boolean);
39401
+ const suffix = unique ? "_key" : "_idx";
39402
+ return `${parts.join("_")}${suffix}`.slice(0, 63);
39403
+ }
38713
39404
  }
38714
39405
 
38715
39406
  class PostgresExecutionSql {
@@ -39110,7 +39801,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
39110
39801
  .filter(validationQuery => !!validationQuery.query);
39111
39802
  }
39112
39803
 
39113
- const version = "1.5.0";
39804
+ const version = "1.6.0";
39114
39805
  const dataformVersion = "3.0.59";
39115
39806
 
39116
39807
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -40879,6 +41570,44 @@ function convertFieldType$1(type) {
40879
41570
  return sqlanvil.Field.Primitive.UNKNOWN;
40880
41571
  }
40881
41572
  }
41573
+ function escapeMysqlString(s) {
41574
+ return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
41575
+ }
41576
+ function reconstructColumnDef(col) {
41577
+ const extra = (col.extra || "").toLowerCase();
41578
+ const notNull = col.isNullable === "NO";
41579
+ if (extra.includes("generated") && col.generationExpression) {
41580
+ const storage = extra.includes("stored") ? "STORED" : "VIRTUAL";
41581
+ return `${col.columnType} GENERATED ALWAYS AS (${col.generationExpression}) ${storage}${notNull ? " NOT NULL" : ""}`;
41582
+ }
41583
+ let def = col.columnType;
41584
+ if (col.collationName) {
41585
+ def += ` COLLATE ${col.collationName}`;
41586
+ }
41587
+ def += notNull ? " NOT NULL" : " NULL";
41588
+ def += defaultClause(col, extra);
41589
+ if (extra.includes("on update current_timestamp")) {
41590
+ def += " ON UPDATE CURRENT_TIMESTAMP";
41591
+ }
41592
+ if (extra.includes("auto_increment")) {
41593
+ def += " AUTO_INCREMENT";
41594
+ }
41595
+ return def;
41596
+ }
41597
+ function defaultClause(col, extra) {
41598
+ if (extra.includes("default_generated")) {
41599
+ const d = col.columnDefault || "";
41600
+ return /^current_timestamp/i.test(d) ? ` DEFAULT ${d}` : ` DEFAULT (${d})`;
41601
+ }
41602
+ if (col.columnDefault === null || col.columnDefault === undefined) {
41603
+ return "";
41604
+ }
41605
+ const d = col.columnDefault;
41606
+ if (d.toUpperCase() === "NULL" || /^-?\d+(\.\d+)?$/.test(d)) {
41607
+ return ` DEFAULT ${d}`;
41608
+ }
41609
+ return ` DEFAULT '${escapeMysqlString(d)}'`;
41610
+ }
40882
41611
 
40883
41612
  const INTERNAL_SCHEMAS$1 = new Set([
40884
41613
  "information_schema",
@@ -41001,12 +41730,12 @@ class MySqlDbAdapter {
41001
41730
  })));
41002
41731
  }
41003
41732
  async table(target) {
41004
- var _a;
41733
+ var _a, _b, _c;
41005
41734
  const params = [target.schema, target.name];
41006
41735
  const [tableResults, columnResults] = await Promise.all([
41007
- this.execute(`select table_type from information_schema.tables
41736
+ this.execute(`select table_type, table_comment from information_schema.tables
41008
41737
  where table_schema = ? and table_name = ?`, { params, includeQueryInError: true }),
41009
- this.execute(`select column_name, data_type, ordinal_position
41738
+ this.execute(`select column_name, data_type, ordinal_position, column_comment
41010
41739
  from information_schema.columns
41011
41740
  where table_schema = ? and table_name = ?
41012
41741
  order by ordinal_position`, { params, includeQueryInError: true })
@@ -41015,14 +41744,18 @@ class MySqlDbAdapter {
41015
41744
  return null;
41016
41745
  }
41017
41746
  const tableType = String((_a = tableResults.rows[0].table_type) !== null && _a !== void 0 ? _a : tableResults.rows[0].TABLE_TYPE).toUpperCase();
41747
+ const tableComment = String((_c = (_b = tableResults.rows[0].table_comment) !== null && _b !== void 0 ? _b : tableResults.rows[0].TABLE_COMMENT) !== null && _c !== void 0 ? _c : "");
41018
41748
  return sqlanvil.TableMetadata.create({
41019
41749
  target,
41020
41750
  type: tableType === "VIEW" ? sqlanvil.TableMetadata.Type.VIEW : sqlanvil.TableMetadata.Type.TABLE,
41751
+ description: tableComment || undefined,
41021
41752
  fields: columnResults.rows.map(row => {
41022
- var _a, _b;
41753
+ var _a, _b, _c, _d;
41754
+ const comment = String((_b = (_a = row.column_comment) !== null && _a !== void 0 ? _a : row.COLUMN_COMMENT) !== null && _b !== void 0 ? _b : "");
41023
41755
  return sqlanvil.Field.create({
41024
- name: ((_a = row.column_name) !== null && _a !== void 0 ? _a : row.COLUMN_NAME),
41025
- primitive: convertFieldType$1(((_b = row.data_type) !== null && _b !== void 0 ? _b : row.DATA_TYPE))
41756
+ name: ((_c = row.column_name) !== null && _c !== void 0 ? _c : row.COLUMN_NAME),
41757
+ primitive: convertFieldType$1(((_d = row.data_type) !== null && _d !== void 0 ? _d : row.DATA_TYPE)),
41758
+ description: comment || undefined
41026
41759
  });
41027
41760
  })
41028
41761
  });
@@ -41050,8 +41783,57 @@ class MySqlDbAdapter {
41050
41783
  includeQueryInError: true
41051
41784
  });
41052
41785
  }
41053
- async setMetadata(_action) {
41054
- return;
41786
+ async setMetadata(action) {
41787
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
41788
+ const { target, actionDescriptor } = action;
41789
+ const actualMetadata = await this.table(target);
41790
+ if (!actualMetadata) {
41791
+ return;
41792
+ }
41793
+ if (actualMetadata.type === sqlanvil.TableMetadata.Type.VIEW) {
41794
+ return;
41795
+ }
41796
+ const resolved = `\`${target.schema}\`.\`${target.name}\``;
41797
+ if (actionDescriptor === null || actionDescriptor === void 0 ? void 0 : actionDescriptor.description) {
41798
+ await this.execute(`alter table ${resolved} comment = '${escapeMysqlString(actionDescriptor.description)}'`, { includeQueryInError: true });
41799
+ }
41800
+ const columnComments = ((actionDescriptor === null || actionDescriptor === void 0 ? void 0 : actionDescriptor.columns) || []).filter(column => {
41801
+ var _a;
41802
+ return ((_a = column.path) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
41803
+ column.description != null &&
41804
+ actualMetadata.fields.some(f => f.name === column.path[0]);
41805
+ });
41806
+ if (columnComments.length === 0) {
41807
+ return;
41808
+ }
41809
+ const defResult = await this.execute(`select column_name, column_type, is_nullable, column_default, extra,
41810
+ collation_name, generation_expression
41811
+ from information_schema.columns
41812
+ where table_schema = ? and table_name = ?`, { params: [target.schema, target.name], includeQueryInError: true });
41813
+ const defByName = new Map();
41814
+ defResult.rows.forEach(row => { var _a; return defByName.set(String((_a = row.column_name) !== null && _a !== void 0 ? _a : row.COLUMN_NAME), row); });
41815
+ for (const column of columnComments) {
41816
+ const name = column.path[0];
41817
+ const row = defByName.get(name);
41818
+ if (!row) {
41819
+ continue;
41820
+ }
41821
+ const def = reconstructColumnDef({
41822
+ columnType: String((_a = row.column_type) !== null && _a !== void 0 ? _a : row.COLUMN_TYPE),
41823
+ isNullable: String((_b = row.is_nullable) !== null && _b !== void 0 ? _b : row.IS_NULLABLE),
41824
+ columnDefault: ((_d = (_c = row.column_default) !== null && _c !== void 0 ? _c : row.COLUMN_DEFAULT) !== null && _d !== void 0 ? _d : null) === null
41825
+ ? null
41826
+ : String((_e = row.column_default) !== null && _e !== void 0 ? _e : row.COLUMN_DEFAULT),
41827
+ extra: String((_g = (_f = row.extra) !== null && _f !== void 0 ? _f : row.EXTRA) !== null && _g !== void 0 ? _g : ""),
41828
+ collationName: ((_j = (_h = row.collation_name) !== null && _h !== void 0 ? _h : row.COLLATION_NAME) !== null && _j !== void 0 ? _j : null) === null
41829
+ ? null
41830
+ : String((_k = row.collation_name) !== null && _k !== void 0 ? _k : row.COLLATION_NAME),
41831
+ generationExpression: ((_m = (_l = row.generation_expression) !== null && _l !== void 0 ? _l : row.GENERATION_EXPRESSION) !== null && _m !== void 0 ? _m : null) === null
41832
+ ? null
41833
+ : String((_o = row.generation_expression) !== null && _o !== void 0 ? _o : row.GENERATION_EXPRESSION)
41834
+ });
41835
+ await this.execute(`alter table ${resolved} modify column \`${name}\` ${def} comment '${escapeMysqlString(column.description)}'`, { includeQueryInError: true });
41836
+ }
41055
41837
  }
41056
41838
  async close() {
41057
41839
  await this.queryExecutor.close();