@sqlanvil/cli 1.4.1 → 1.5.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # SQLAnvil
2
2
 
3
- **SQL workflow tool for BigQuery, Postgres, and Supabase.**
3
+ **SQL workflow tool for BigQuery, Postgres, Supabase, and MySQL/MariaDB.**
4
4
 
5
- SQLAnvil is an open-source fork of [Dataform OSS](https://github.com/dataform-co/dataform) (Apache 2.0), extended with first-class PostgreSQL and Supabase support. Define your data transformations in SQLX, have SQLAnvil compile them to idiomatic SQL, and run them against your warehouse.
5
+ SQLAnvil is an open-source fork of [Dataform OSS](https://github.com/dataform-co/dataform) (Apache 2.0), extended with first-class PostgreSQL, Supabase, and MySQL/MariaDB support. Define your data transformations in SQLX, have SQLAnvil compile them to idiomatic SQL, and run them against your warehouse.
6
6
 
7
7
  > **SQLAnvil is not affiliated with or endorsed by Google.** The Dataform name and related marks are trademarks of Google LLC. See [NOTICE](NOTICE) for attribution.
8
8
 
@@ -13,6 +13,7 @@ SQLAnvil is an open-source fork of [Dataform OSS](https://github.com/dataform-co
13
13
  - **BigQuery** — full support: partitioning, clustering, labels, materialized views, `MERGE`-based incremental upserts
14
14
  - **PostgreSQL** — idiomatic DDL: native partitioning, `INSERT ... ON CONFLICT` upserts, btree/gin/gist/brin indexes, tablespaces, fillfactor
15
15
  - **Supabase** — extends Postgres with RLS policies, Realtime publications, pgvector indexes, and Supabase Wrappers _(coming soon)_
16
+ - **MySQL / MariaDB** — portable MySQL DDL: CTAS tables, `CREATE OR REPLACE VIEW`, `ON DUPLICATE KEY UPDATE` incremental upserts (one adapter, validated against both engines)
16
17
  - **SQLX + YAML + JS** — three authoring modes: SQL with config blocks, `actions.yaml` bulk definitions, or the JavaScript API
17
18
 
18
19
  ---
package/bundle.js CHANGED
@@ -35,6 +35,7 @@ var EventEmitter = require('events');
35
35
  var Long = require('long');
36
36
  var promisePoolExecutor = require('promise-pool-executor');
37
37
  var sizeof = require('object-sizeof');
38
+ var mysql = require('mysql2/promise');
38
39
  var QueryStream = require('pg-query-stream');
39
40
  var readlineSync = require('readline-sync');
40
41
  var untildify = require('untildify');
@@ -78,6 +79,7 @@ var pg__namespace = /*#__PURE__*/_interopNamespace(pg);
78
79
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
79
80
  var Long__default = /*#__PURE__*/_interopDefaultLegacy(Long);
80
81
  var sizeof__default = /*#__PURE__*/_interopDefaultLegacy(sizeof);
82
+ var mysql__namespace = /*#__PURE__*/_interopNamespace(mysql);
81
83
  var QueryStream__default = /*#__PURE__*/_interopDefaultLegacy(QueryStream);
82
84
  var readlineSync__namespace = /*#__PURE__*/_interopNamespace(readlineSync);
83
85
  var untildify__default = /*#__PURE__*/_interopDefaultLegacy(untildify);
@@ -14949,6 +14951,327 @@ const sqlanvil = $root.sqlanvil = (() => {
14949
14951
  return SupabaseConnection;
14950
14952
  })();
14951
14953
 
14954
+ sqlanvil.MysqlConnection = (function() {
14955
+
14956
+ /**
14957
+ * Properties of a MysqlConnection.
14958
+ * @memberof sqlanvil
14959
+ * @interface IMysqlConnection
14960
+ * @property {string|null} [host] MysqlConnection host
14961
+ * @property {number|null} [port] MysqlConnection port
14962
+ * @property {string|null} [database] MysqlConnection database
14963
+ * @property {string|null} [user] MysqlConnection user
14964
+ * @property {string|null} [password] MysqlConnection password
14965
+ * @property {string|null} [sslMode] MysqlConnection sslMode
14966
+ */
14967
+
14968
+ /**
14969
+ * Constructs a new MysqlConnection.
14970
+ * @memberof sqlanvil
14971
+ * @classdesc Represents a MysqlConnection.
14972
+ * @implements IMysqlConnection
14973
+ * @constructor
14974
+ * @param {sqlanvil.IMysqlConnection=} [properties] Properties to set
14975
+ */
14976
+ function MysqlConnection(properties) {
14977
+ if (properties)
14978
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
14979
+ if (properties[keys[i]] != null)
14980
+ this[keys[i]] = properties[keys[i]];
14981
+ }
14982
+
14983
+ /**
14984
+ * MysqlConnection host.
14985
+ * @member {string} host
14986
+ * @memberof sqlanvil.MysqlConnection
14987
+ * @instance
14988
+ */
14989
+ MysqlConnection.prototype.host = "";
14990
+
14991
+ /**
14992
+ * MysqlConnection port.
14993
+ * @member {number} port
14994
+ * @memberof sqlanvil.MysqlConnection
14995
+ * @instance
14996
+ */
14997
+ MysqlConnection.prototype.port = 0;
14998
+
14999
+ /**
15000
+ * MysqlConnection database.
15001
+ * @member {string} database
15002
+ * @memberof sqlanvil.MysqlConnection
15003
+ * @instance
15004
+ */
15005
+ MysqlConnection.prototype.database = "";
15006
+
15007
+ /**
15008
+ * MysqlConnection user.
15009
+ * @member {string} user
15010
+ * @memberof sqlanvil.MysqlConnection
15011
+ * @instance
15012
+ */
15013
+ MysqlConnection.prototype.user = "";
15014
+
15015
+ /**
15016
+ * MysqlConnection password.
15017
+ * @member {string} password
15018
+ * @memberof sqlanvil.MysqlConnection
15019
+ * @instance
15020
+ */
15021
+ MysqlConnection.prototype.password = "";
15022
+
15023
+ /**
15024
+ * MysqlConnection sslMode.
15025
+ * @member {string} sslMode
15026
+ * @memberof sqlanvil.MysqlConnection
15027
+ * @instance
15028
+ */
15029
+ MysqlConnection.prototype.sslMode = "";
15030
+
15031
+ /**
15032
+ * Creates a new MysqlConnection instance using the specified properties.
15033
+ * @function create
15034
+ * @memberof sqlanvil.MysqlConnection
15035
+ * @static
15036
+ * @param {sqlanvil.IMysqlConnection=} [properties] Properties to set
15037
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection instance
15038
+ */
15039
+ MysqlConnection.create = function create(properties) {
15040
+ return new MysqlConnection(properties);
15041
+ };
15042
+
15043
+ /**
15044
+ * Encodes the specified MysqlConnection message. Does not implicitly {@link sqlanvil.MysqlConnection.verify|verify} messages.
15045
+ * @function encode
15046
+ * @memberof sqlanvil.MysqlConnection
15047
+ * @static
15048
+ * @param {sqlanvil.IMysqlConnection} message MysqlConnection message or plain object to encode
15049
+ * @param {$protobuf.Writer} [writer] Writer to encode to
15050
+ * @returns {$protobuf.Writer} Writer
15051
+ */
15052
+ MysqlConnection.encode = function encode(message, writer) {
15053
+ if (!writer)
15054
+ writer = $Writer.create();
15055
+ if (message.host != null && Object.hasOwnProperty.call(message, "host"))
15056
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.host);
15057
+ if (message.port != null && Object.hasOwnProperty.call(message, "port"))
15058
+ writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.port);
15059
+ if (message.database != null && Object.hasOwnProperty.call(message, "database"))
15060
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.database);
15061
+ if (message.user != null && Object.hasOwnProperty.call(message, "user"))
15062
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.user);
15063
+ if (message.password != null && Object.hasOwnProperty.call(message, "password"))
15064
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.password);
15065
+ if (message.sslMode != null && Object.hasOwnProperty.call(message, "sslMode"))
15066
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.sslMode);
15067
+ return writer;
15068
+ };
15069
+
15070
+ /**
15071
+ * Encodes the specified MysqlConnection message, length delimited. Does not implicitly {@link sqlanvil.MysqlConnection.verify|verify} messages.
15072
+ * @function encodeDelimited
15073
+ * @memberof sqlanvil.MysqlConnection
15074
+ * @static
15075
+ * @param {sqlanvil.IMysqlConnection} message MysqlConnection message or plain object to encode
15076
+ * @param {$protobuf.Writer} [writer] Writer to encode to
15077
+ * @returns {$protobuf.Writer} Writer
15078
+ */
15079
+ MysqlConnection.encodeDelimited = function encodeDelimited(message, writer) {
15080
+ return this.encode(message, writer).ldelim();
15081
+ };
15082
+
15083
+ /**
15084
+ * Decodes a MysqlConnection message from the specified reader or buffer.
15085
+ * @function decode
15086
+ * @memberof sqlanvil.MysqlConnection
15087
+ * @static
15088
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
15089
+ * @param {number} [length] Message length if known beforehand
15090
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15091
+ * @throws {Error} If the payload is not a reader or valid buffer
15092
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
15093
+ */
15094
+ MysqlConnection.decode = function decode(reader, length, error) {
15095
+ if (!(reader instanceof $Reader))
15096
+ reader = $Reader.create(reader);
15097
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlConnection();
15098
+ while (reader.pos < end) {
15099
+ let tag = reader.uint32();
15100
+ if (tag === error)
15101
+ break;
15102
+ switch (tag >>> 3) {
15103
+ case 1: {
15104
+ message.host = reader.string();
15105
+ break;
15106
+ }
15107
+ case 2: {
15108
+ message.port = reader.uint32();
15109
+ break;
15110
+ }
15111
+ case 3: {
15112
+ message.database = reader.string();
15113
+ break;
15114
+ }
15115
+ case 4: {
15116
+ message.user = reader.string();
15117
+ break;
15118
+ }
15119
+ case 5: {
15120
+ message.password = reader.string();
15121
+ break;
15122
+ }
15123
+ case 6: {
15124
+ message.sslMode = reader.string();
15125
+ break;
15126
+ }
15127
+ default:
15128
+ reader.skipType(tag & 7);
15129
+ break;
15130
+ }
15131
+ }
15132
+ return message;
15133
+ };
15134
+
15135
+ /**
15136
+ * Decodes a MysqlConnection message from the specified reader or buffer, length delimited.
15137
+ * @function decodeDelimited
15138
+ * @memberof sqlanvil.MysqlConnection
15139
+ * @static
15140
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
15141
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15142
+ * @throws {Error} If the payload is not a reader or valid buffer
15143
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
15144
+ */
15145
+ MysqlConnection.decodeDelimited = function decodeDelimited(reader) {
15146
+ if (!(reader instanceof $Reader))
15147
+ reader = new $Reader(reader);
15148
+ return this.decode(reader, reader.uint32());
15149
+ };
15150
+
15151
+ /**
15152
+ * Verifies a MysqlConnection message.
15153
+ * @function verify
15154
+ * @memberof sqlanvil.MysqlConnection
15155
+ * @static
15156
+ * @param {Object.<string,*>} message Plain object to verify
15157
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
15158
+ */
15159
+ MysqlConnection.verify = function verify(message) {
15160
+ if (typeof message !== "object" || message === null)
15161
+ return "object expected";
15162
+ if (message.host != null && message.hasOwnProperty("host"))
15163
+ if (!$util.isString(message.host))
15164
+ return "host: string expected";
15165
+ if (message.port != null && message.hasOwnProperty("port"))
15166
+ if (!$util.isInteger(message.port))
15167
+ return "port: integer expected";
15168
+ if (message.database != null && message.hasOwnProperty("database"))
15169
+ if (!$util.isString(message.database))
15170
+ return "database: string expected";
15171
+ if (message.user != null && message.hasOwnProperty("user"))
15172
+ if (!$util.isString(message.user))
15173
+ return "user: string expected";
15174
+ if (message.password != null && message.hasOwnProperty("password"))
15175
+ if (!$util.isString(message.password))
15176
+ return "password: string expected";
15177
+ if (message.sslMode != null && message.hasOwnProperty("sslMode"))
15178
+ if (!$util.isString(message.sslMode))
15179
+ return "sslMode: string expected";
15180
+ return null;
15181
+ };
15182
+
15183
+ /**
15184
+ * Creates a MysqlConnection message from a plain object. Also converts values to their respective internal types.
15185
+ * @function fromObject
15186
+ * @memberof sqlanvil.MysqlConnection
15187
+ * @static
15188
+ * @param {Object.<string,*>} object Plain object
15189
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15190
+ */
15191
+ MysqlConnection.fromObject = function fromObject(object) {
15192
+ if (object instanceof $root.sqlanvil.MysqlConnection)
15193
+ return object;
15194
+ let message = new $root.sqlanvil.MysqlConnection();
15195
+ if (object.host != null)
15196
+ message.host = String(object.host);
15197
+ if (object.port != null)
15198
+ message.port = object.port >>> 0;
15199
+ if (object.database != null)
15200
+ message.database = String(object.database);
15201
+ if (object.user != null)
15202
+ message.user = String(object.user);
15203
+ if (object.password != null)
15204
+ message.password = String(object.password);
15205
+ if (object.sslMode != null)
15206
+ message.sslMode = String(object.sslMode);
15207
+ return message;
15208
+ };
15209
+
15210
+ /**
15211
+ * Creates a plain object from a MysqlConnection message. Also converts values to other types if specified.
15212
+ * @function toObject
15213
+ * @memberof sqlanvil.MysqlConnection
15214
+ * @static
15215
+ * @param {sqlanvil.MysqlConnection} message MysqlConnection
15216
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
15217
+ * @returns {Object.<string,*>} Plain object
15218
+ */
15219
+ MysqlConnection.toObject = function toObject(message, options) {
15220
+ if (!options)
15221
+ options = {};
15222
+ let object = {};
15223
+ if (options.defaults) {
15224
+ object.host = "";
15225
+ object.port = 0;
15226
+ object.database = "";
15227
+ object.user = "";
15228
+ object.password = "";
15229
+ object.sslMode = "";
15230
+ }
15231
+ if (message.host != null && message.hasOwnProperty("host"))
15232
+ object.host = message.host;
15233
+ if (message.port != null && message.hasOwnProperty("port"))
15234
+ object.port = message.port;
15235
+ if (message.database != null && message.hasOwnProperty("database"))
15236
+ object.database = message.database;
15237
+ if (message.user != null && message.hasOwnProperty("user"))
15238
+ object.user = message.user;
15239
+ if (message.password != null && message.hasOwnProperty("password"))
15240
+ object.password = message.password;
15241
+ if (message.sslMode != null && message.hasOwnProperty("sslMode"))
15242
+ object.sslMode = message.sslMode;
15243
+ return object;
15244
+ };
15245
+
15246
+ /**
15247
+ * Converts this MysqlConnection to JSON.
15248
+ * @function toJSON
15249
+ * @memberof sqlanvil.MysqlConnection
15250
+ * @instance
15251
+ * @returns {Object.<string,*>} JSON object
15252
+ */
15253
+ MysqlConnection.prototype.toJSON = function toJSON() {
15254
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
15255
+ };
15256
+
15257
+ /**
15258
+ * Gets the default type url for MysqlConnection
15259
+ * @function getTypeUrl
15260
+ * @memberof sqlanvil.MysqlConnection
15261
+ * @static
15262
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
15263
+ * @returns {string} The default type url
15264
+ */
15265
+ MysqlConnection.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
15266
+ if (typeUrlPrefix === undefined) {
15267
+ typeUrlPrefix = "type.googleapis.com";
15268
+ }
15269
+ return typeUrlPrefix + "/sqlanvil.MysqlConnection";
15270
+ };
15271
+
15272
+ return MysqlConnection;
15273
+ })();
15274
+
14952
15275
  sqlanvil.WarehouseConfig = (function() {
14953
15276
 
14954
15277
  /**
@@ -14958,6 +15281,7 @@ const sqlanvil = $root.sqlanvil = (() => {
14958
15281
  * @property {sqlanvil.IBigQueryConnection|null} [bigquery] WarehouseConfig bigquery
14959
15282
  * @property {sqlanvil.IPostgresConnection|null} [postgres] WarehouseConfig postgres
14960
15283
  * @property {sqlanvil.ISupabaseConnection|null} [supabase] WarehouseConfig supabase
15284
+ * @property {sqlanvil.IMysqlConnection|null} [mysql] WarehouseConfig mysql
14961
15285
  */
14962
15286
 
14963
15287
  /**
@@ -14999,17 +15323,25 @@ const sqlanvil = $root.sqlanvil = (() => {
14999
15323
  */
15000
15324
  WarehouseConfig.prototype.supabase = null;
15001
15325
 
15326
+ /**
15327
+ * WarehouseConfig mysql.
15328
+ * @member {sqlanvil.IMysqlConnection|null|undefined} mysql
15329
+ * @memberof sqlanvil.WarehouseConfig
15330
+ * @instance
15331
+ */
15332
+ WarehouseConfig.prototype.mysql = null;
15333
+
15002
15334
  // OneOf field names bound to virtual getters and setters
15003
15335
  let $oneOfFields;
15004
15336
 
15005
15337
  /**
15006
15338
  * WarehouseConfig connection.
15007
- * @member {"bigquery"|"postgres"|"supabase"|undefined} connection
15339
+ * @member {"bigquery"|"postgres"|"supabase"|"mysql"|undefined} connection
15008
15340
  * @memberof sqlanvil.WarehouseConfig
15009
15341
  * @instance
15010
15342
  */
15011
15343
  Object.defineProperty(WarehouseConfig.prototype, "connection", {
15012
- get: $util.oneOfGetter($oneOfFields = ["bigquery", "postgres", "supabase"]),
15344
+ get: $util.oneOfGetter($oneOfFields = ["bigquery", "postgres", "supabase", "mysql"]),
15013
15345
  set: $util.oneOfSetter($oneOfFields)
15014
15346
  });
15015
15347
 
@@ -15043,6 +15375,8 @@ const sqlanvil = $root.sqlanvil = (() => {
15043
15375
  $root.sqlanvil.PostgresConnection.encode(message.postgres, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
15044
15376
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
15045
15377
  $root.sqlanvil.SupabaseConnection.encode(message.supabase, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
15378
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
15379
+ $root.sqlanvil.MysqlConnection.encode(message.mysql, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
15046
15380
  return writer;
15047
15381
  };
15048
15382
 
@@ -15091,6 +15425,10 @@ const sqlanvil = $root.sqlanvil = (() => {
15091
15425
  message.supabase = $root.sqlanvil.SupabaseConnection.decode(reader, reader.uint32());
15092
15426
  break;
15093
15427
  }
15428
+ case 4: {
15429
+ message.mysql = $root.sqlanvil.MysqlConnection.decode(reader, reader.uint32());
15430
+ break;
15431
+ }
15094
15432
  default:
15095
15433
  reader.skipType(tag & 7);
15096
15434
  break;
@@ -15155,6 +15493,16 @@ const sqlanvil = $root.sqlanvil = (() => {
15155
15493
  return "supabase." + error;
15156
15494
  }
15157
15495
  }
15496
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
15497
+ if (properties.connection === 1)
15498
+ return "connection: multiple values";
15499
+ properties.connection = 1;
15500
+ {
15501
+ let error = $root.sqlanvil.MysqlConnection.verify(message.mysql);
15502
+ if (error)
15503
+ return "mysql." + error;
15504
+ }
15505
+ }
15158
15506
  return null;
15159
15507
  };
15160
15508
 
@@ -15185,6 +15533,11 @@ const sqlanvil = $root.sqlanvil = (() => {
15185
15533
  throw TypeError(".sqlanvil.WarehouseConfig.supabase: object expected");
15186
15534
  message.supabase = $root.sqlanvil.SupabaseConnection.fromObject(object.supabase);
15187
15535
  }
15536
+ if (object.mysql != null) {
15537
+ if (typeof object.mysql !== "object")
15538
+ throw TypeError(".sqlanvil.WarehouseConfig.mysql: object expected");
15539
+ message.mysql = $root.sqlanvil.MysqlConnection.fromObject(object.mysql);
15540
+ }
15188
15541
  return message;
15189
15542
  };
15190
15543
 
@@ -15216,6 +15569,11 @@ const sqlanvil = $root.sqlanvil = (() => {
15216
15569
  if (options.oneofs)
15217
15570
  object.connection = "supabase";
15218
15571
  }
15572
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
15573
+ object.mysql = $root.sqlanvil.MysqlConnection.toObject(message.mysql, options);
15574
+ if (options.oneofs)
15575
+ object.connection = "mysql";
15576
+ }
15219
15577
  return object;
15220
15578
  };
15221
15579
 
@@ -37904,6 +38262,9 @@ class CompilationSql {
37904
38262
  }
37905
38263
  return `"${database}"."${schema}"."${name}"`;
37906
38264
  }
38265
+ if (this.warehouse === "mysql") {
38266
+ return `\`${schema}\`.\`${name}\``;
38267
+ }
37907
38268
  if (!database) {
37908
38269
  return `\`${schema}.${name}\``;
37909
38270
  }
@@ -37920,6 +38281,9 @@ class CompilationSql {
37920
38281
  if (this.warehouse === "postgres" || this.warehouse === "supabase") {
37921
38282
  return `"${col.replace(/"/g, '""')}"`;
37922
38283
  }
38284
+ if (this.warehouse === "mysql") {
38285
+ return `\`${col.replace(/`/g, "``")}\``;
38286
+ }
37923
38287
  return col;
37924
38288
  };
37925
38289
  const commaSeparatedColumns = indexCols.map(quoteCol).join(", ");
@@ -38265,6 +38629,89 @@ when not matched then
38265
38629
  }
38266
38630
  }
38267
38631
 
38632
+ class MysqlExecutionSql {
38633
+ constructor(project, sqlanvilCoreVersion, uniqueIdGenerator = () => Math.random().toString(36).substring(2)) {
38634
+ this.project = project;
38635
+ this.sqlanvilCoreVersion = sqlanvilCoreVersion;
38636
+ this.uniqueIdGenerator = uniqueIdGenerator;
38637
+ this.CompilationSql = new CompilationSql(project, sqlanvilCoreVersion);
38638
+ }
38639
+ resolveTarget(target) {
38640
+ return this.CompilationSql.resolveTarget(target);
38641
+ }
38642
+ dropIfExists(target, type) {
38643
+ if (type === sqlanvil.TableMetadata.Type.VIEW) {
38644
+ return `drop view if exists ${this.resolveTarget(target)}`;
38645
+ }
38646
+ return `drop table if exists ${this.resolveTarget(target)}`;
38647
+ }
38648
+ publishTasks(table, runConfig, tableMetadata) {
38649
+ const tasks = new Tasks();
38650
+ const target = this.resolveTarget(table.target);
38651
+ if (table.enumType === sqlanvil.TableType.VIEW) {
38652
+ 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.`);
38655
+ }
38656
+ tasks.add(Task.statement(`create or replace view ${target} as ${table.query}`));
38657
+ return tasks;
38658
+ }
38659
+ if (table.enumType === sqlanvil.TableType.INCREMENTAL) {
38660
+ const fresh = !this.shouldWriteIncrementally(table, runConfig, tableMetadata);
38661
+ if (fresh) {
38662
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
38663
+ tasks.add(Task.statement(`create table ${target} as ${table.query}`));
38664
+ if (table.uniqueKey && table.uniqueKey.length > 0) {
38665
+ const idx = `uq_${table.target.schema}_${table.target.name}`.slice(0, 63);
38666
+ const cols = table.uniqueKey.map(k => `\`${k}\``).join(", ");
38667
+ tasks.add(Task.statement(`alter table ${target} add unique index \`${idx}\` (${cols})`));
38668
+ }
38669
+ }
38670
+ else {
38671
+ tasks.add(Task.statement(this.upsertInto(table, tableMetadata)));
38672
+ }
38673
+ return tasks;
38674
+ }
38675
+ tasks.add(Task.statement(this.dropIfExists(table.target, sqlanvil.TableMetadata.Type.TABLE)));
38676
+ tasks.add(Task.statement(`create table ${target} as ${table.query}`));
38677
+ return tasks;
38678
+ }
38679
+ assertTasks(assertion, projectConfig) {
38680
+ const tasks = new Tasks();
38681
+ const target = this.resolveTarget(assertion.target);
38682
+ tasks.add(Task.statement(this.dropIfExists(assertion.target, sqlanvil.TableMetadata.Type.VIEW)));
38683
+ tasks.add(Task.statement(`create or replace view ${target} as ${assertion.query}`));
38684
+ tasks.add(Task.assertion(`select sum(1) as row_count from ${target}`));
38685
+ return tasks;
38686
+ }
38687
+ shouldWriteIncrementally(table, runConfig, tableMetadata) {
38688
+ return (!runConfig.fullRefresh &&
38689
+ !!tableMetadata &&
38690
+ tableMetadata.type === sqlanvil.TableMetadata.Type.TABLE);
38691
+ }
38692
+ getIncrementalQuery(table) {
38693
+ return table.incrementalQuery || table.query;
38694
+ }
38695
+ upsertInto(table, tableMetadata) {
38696
+ const target = this.resolveTarget(table.target);
38697
+ const columns = ((tableMetadata === null || tableMetadata === void 0 ? void 0 : tableMetadata.fields) || []).map(f => f.name);
38698
+ const query = this.getIncrementalQuery(table);
38699
+ if (columns.length === 0) {
38700
+ return `insert into ${target} select * from (${query}) as insertions`;
38701
+ }
38702
+ const backticked = columns.map(c => `\`${c}\``);
38703
+ const uniqueKey = table.uniqueKey || [];
38704
+ const updates = uniqueKey.length > 0
38705
+ ? columns
38706
+ .filter(c => !uniqueKey.includes(c))
38707
+ .map(c => `\`${c}\` = values(\`${c}\`)`)
38708
+ .join(", ")
38709
+ : "";
38710
+ const tail = updates.length > 0 ? ` on duplicate key update ${updates}` : "";
38711
+ return `insert into ${target} (${backticked.join(", ")}) select ${backticked.join(", ")} from (${query}) as insertions${tail}`;
38712
+ }
38713
+ }
38714
+
38268
38715
  class PostgresExecutionSql {
38269
38716
  constructor(project, sqlanvilCoreVersion, uniqueIdGenerator = () => Math.random().toString(36).substring(2)) {
38270
38717
  this.project = project;
@@ -38576,6 +39023,9 @@ class ExecutionSql {
38576
39023
  if (warehouse === "postgres" || warehouse === "supabase") {
38577
39024
  this.delegate = new PostgresExecutionSql(project, sqlanvilCoreVersion, uniqueIdGenerator);
38578
39025
  }
39026
+ else if (warehouse === "mysql") {
39027
+ this.delegate = new MysqlExecutionSql(project, sqlanvilCoreVersion, uniqueIdGenerator);
39028
+ }
38579
39029
  else {
38580
39030
  this.delegate = new BigQueryExecutionSql(project, sqlanvilCoreVersion, uniqueIdGenerator);
38581
39031
  }
@@ -38660,7 +39110,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
38660
39110
  .filter(validationQuery => !!validationQuery.query);
38661
39111
  }
38662
39112
 
38663
- const version = "1.4.1";
39113
+ const version = "1.5.0";
38664
39114
  const dataformVersion = "3.0.59";
38665
39115
 
38666
39116
  async function build(compiledGraph, runConfig, dbadapter) {
@@ -38921,6 +39371,13 @@ function read(credentialsPath, warehouse = "bigquery") {
38921
39371
  throw new Error(`Error reading credentials file: ${e.message}`);
38922
39372
  }
38923
39373
  const warehouseCredentials = __rest(credentialsAsJson, ["connections"]);
39374
+ if (warehouse.toLowerCase() === "mysql") {
39375
+ const credentials = verifyObjectMatchesProto(sqlanvil.MysqlConnection, warehouseCredentials);
39376
+ if (!credentials.host) {
39377
+ throw new Error(`Error reading credentials file: the host field is required`);
39378
+ }
39379
+ return credentials;
39380
+ }
38924
39381
  const isPostgres = warehouse.toLowerCase() === "postgres" || warehouse.toLowerCase() === "supabase";
38925
39382
  if (isPostgres) {
38926
39383
  const credentials = verifyObjectMatchesProto(sqlanvil.PostgresConnection, warehouseCredentials);
@@ -38995,6 +39452,17 @@ function postgresCredentialsTemplate(warehouse) {
38995
39452
  };
38996
39453
  return `${JSON.stringify(template, null, 2)}\n`;
38997
39454
  }
39455
+ function mysqlCredentialsTemplate() {
39456
+ const template = {
39457
+ host: "localhost",
39458
+ port: 3306,
39459
+ database: "sqlanvil",
39460
+ user: "root",
39461
+ password: "",
39462
+ sslMode: "disable"
39463
+ };
39464
+ return `${JSON.stringify(template, null, 2)}\n`;
39465
+ }
38998
39466
  async function init(projectDir, projectConfig) {
38999
39467
  const workflowSettingsYamlPath = path__namespace.join(projectDir, "workflow_settings.yaml");
39000
39468
  const packageJsonPath = path__namespace.join(projectDir, "package.json");
@@ -39046,7 +39514,7 @@ async function init(projectDir, projectConfig) {
39046
39514
  fs__namespace$1.writeFileSync(gitignorePath, gitIgnoreContents);
39047
39515
  filesWritten.push(gitignorePath);
39048
39516
  if (!isBigQuery) {
39049
- fs__namespace$1.writeFileSync(path__namespace.join(projectDir, CREDENTIALS_FILENAME), postgresCredentialsTemplate(warehouse));
39517
+ fs__namespace$1.writeFileSync(path__namespace.join(projectDir, CREDENTIALS_FILENAME), warehouse === "mysql" ? mysqlCredentialsTemplate() : postgresCredentialsTemplate(warehouse));
39050
39518
  filesWritten.push(path__namespace.join(projectDir, CREDENTIALS_FILENAME));
39051
39519
  }
39052
39520
  const definitionsDir = path__namespace.join(projectDir, "definitions");
@@ -40249,11 +40717,11 @@ function convertField(field) {
40249
40717
  });
40250
40718
  }
40251
40719
  else {
40252
- result.primitive = convertFieldType$1(field.type);
40720
+ result.primitive = convertFieldType$2(field.type);
40253
40721
  }
40254
40722
  return sqlanvil.Field.create(result);
40255
40723
  }
40256
- function convertFieldType$1(type) {
40724
+ function convertFieldType$2(type) {
40257
40725
  switch (String(type).toUpperCase()) {
40258
40726
  case "FLOAT":
40259
40727
  case "FLOAT64":
@@ -40326,6 +40794,270 @@ function createBigQueryError(jobMetadata) {
40326
40794
  return error;
40327
40795
  }
40328
40796
 
40797
+ class MySqlPoolExecutor {
40798
+ constructor(config, options) {
40799
+ this.pool = mysql__namespace.createPool(Object.assign(Object.assign({}, config), { connectionLimit: (options === null || options === void 0 ? void 0 : options.concurrencyLimit) || 10, waitForConnections: true, multipleStatements: false }));
40800
+ }
40801
+ async verifyConnection() {
40802
+ const conn = await this.pool.getConnection();
40803
+ try {
40804
+ await conn.query("select 1");
40805
+ }
40806
+ finally {
40807
+ conn.release();
40808
+ }
40809
+ }
40810
+ async withClientLock(callback) {
40811
+ const conn = await this.pool.getConnection();
40812
+ let released = false;
40813
+ const releaseOnce = () => {
40814
+ if (released) {
40815
+ return;
40816
+ }
40817
+ released = true;
40818
+ conn.release();
40819
+ };
40820
+ try {
40821
+ return await callback({
40822
+ execute: async (statement, options = { rowLimit: 1000 }) => {
40823
+ const [rows] = await conn.query(statement, options.params || []);
40824
+ const arr = Array.isArray(rows) ? rows : [];
40825
+ return options.rowLimit && arr.length > options.rowLimit
40826
+ ? arr.slice(0, options.rowLimit)
40827
+ : arr;
40828
+ }
40829
+ });
40830
+ }
40831
+ finally {
40832
+ releaseOnce();
40833
+ }
40834
+ }
40835
+ async close() {
40836
+ await this.pool.end();
40837
+ }
40838
+ }
40839
+ function convertFieldType$1(type) {
40840
+ switch (String(type).toUpperCase()) {
40841
+ case "FLOAT":
40842
+ case "DOUBLE":
40843
+ case "REAL":
40844
+ return sqlanvil.Field.Primitive.FLOAT;
40845
+ case "TINYINT":
40846
+ case "SMALLINT":
40847
+ case "MEDIUMINT":
40848
+ case "INT":
40849
+ case "INTEGER":
40850
+ case "BIGINT":
40851
+ case "YEAR":
40852
+ case "BIT":
40853
+ return sqlanvil.Field.Primitive.INTEGER;
40854
+ case "DECIMAL":
40855
+ case "DEC":
40856
+ case "NUMERIC":
40857
+ case "FIXED":
40858
+ return sqlanvil.Field.Primitive.NUMERIC;
40859
+ case "BOOL":
40860
+ case "BOOLEAN":
40861
+ return sqlanvil.Field.Primitive.BOOLEAN;
40862
+ case "CHAR":
40863
+ case "VARCHAR":
40864
+ case "TINYTEXT":
40865
+ case "TEXT":
40866
+ case "MEDIUMTEXT":
40867
+ case "LONGTEXT":
40868
+ case "ENUM":
40869
+ case "SET":
40870
+ case "JSON":
40871
+ case "TIME":
40872
+ return sqlanvil.Field.Primitive.STRING;
40873
+ case "DATE":
40874
+ return sqlanvil.Field.Primitive.DATE;
40875
+ case "DATETIME":
40876
+ case "TIMESTAMP":
40877
+ return sqlanvil.Field.Primitive.TIMESTAMP;
40878
+ default:
40879
+ return sqlanvil.Field.Primitive.UNKNOWN;
40880
+ }
40881
+ }
40882
+
40883
+ const INTERNAL_SCHEMAS$1 = new Set([
40884
+ "information_schema",
40885
+ "mysql",
40886
+ "performance_schema",
40887
+ "sys"
40888
+ ]);
40889
+ class MySqlDbAdapter {
40890
+ constructor(queryExecutor) {
40891
+ this.queryExecutor = queryExecutor;
40892
+ }
40893
+ static async create(credentials, options) {
40894
+ const sslMode = (credentials.sslMode || "").toLowerCase();
40895
+ const ssl = !(options === null || options === void 0 ? void 0 : options.disableSslForTestsOnly) && sslMode && sslMode !== "disable"
40896
+ ?
40897
+ { rejectUnauthorized: false }
40898
+ : undefined;
40899
+ const queryExecutor = new MySqlPoolExecutor({
40900
+ host: credentials.host,
40901
+ port: credentials.port || 3306,
40902
+ user: credentials.user,
40903
+ password: credentials.password,
40904
+ database: credentials.database || undefined,
40905
+ ssl
40906
+ }, options);
40907
+ try {
40908
+ await queryExecutor.verifyConnection();
40909
+ }
40910
+ catch (e) {
40911
+ await queryExecutor.close().catch(() => undefined);
40912
+ throw new ErrorWithCause(`Could not connect to MySQL at ${credentials.host}:${credentials.port || 3306} ` +
40913
+ `as "${credentials.user}": ${e.message}`, e);
40914
+ }
40915
+ return new MySqlDbAdapter(queryExecutor);
40916
+ }
40917
+ async execute(statement, options = { rowLimit: 1000, byteLimit: 1024 * 1024 }) {
40918
+ return await this.withClientLock(client => client.execute(statement, options));
40919
+ }
40920
+ async executeRaw(statement, options = { rowLimit: 1000 }) {
40921
+ const result = await this.execute(statement, options);
40922
+ return Object.assign(Object.assign({}, result), { schema: [] });
40923
+ }
40924
+ async withClientLock(callback) {
40925
+ return await this.queryExecutor.withClientLock(client => callback({
40926
+ execute: async (stmt, opts = { rowLimit: 1000, byteLimit: 1024 * 1024 }) => {
40927
+ try {
40928
+ const rows = await client.execute(stmt, { params: opts.params, rowLimit: opts.rowLimit });
40929
+ return { rows, metadata: {} };
40930
+ }
40931
+ catch (e) {
40932
+ if (opts.includeQueryInError) {
40933
+ throw new Error(`Error encountered while running "${stmt}": ${e.message}`);
40934
+ }
40935
+ throw new ErrorWithCause(`Error executing mysql query: ${e.message}`, e);
40936
+ }
40937
+ },
40938
+ executeRaw: async (stmt, opts = { rowLimit: 1000 }) => {
40939
+ const positional = opts.params ? Object.values(opts.params) : undefined;
40940
+ const rows = await client.execute(stmt, { params: positional, rowLimit: opts.rowLimit });
40941
+ return { rows, schema: [], metadata: {} };
40942
+ }
40943
+ }));
40944
+ }
40945
+ async evaluate(queryOrAction) {
40946
+ const validationQueries = collectEvaluationQueries(queryOrAction, false, (query) => !!query ? `explain ${query}` : "").map((validationQuery, index) => ({ index, validationQuery }));
40947
+ const validationQueriesWithoutWrappers = collectEvaluationQueries(queryOrAction, false);
40948
+ const queryEvaluations = new Array();
40949
+ for (const { index, validationQuery } of validationQueries) {
40950
+ let evaluationResponse = {
40951
+ status: sqlanvil.QueryEvaluation.QueryEvaluationStatus.SUCCESS
40952
+ };
40953
+ try {
40954
+ await this.execute(validationQuery.query);
40955
+ }
40956
+ catch (e) {
40957
+ evaluationResponse = {
40958
+ status: sqlanvil.QueryEvaluation.QueryEvaluationStatus.FAILURE,
40959
+ error: sqlanvil.QueryEvaluationError.create({
40960
+ message: (e === null || e === void 0 ? void 0 : e.message) ? String(e.message) : String(e)
40961
+ })
40962
+ };
40963
+ }
40964
+ queryEvaluations.push(sqlanvil.QueryEvaluation.create(Object.assign(Object.assign({}, evaluationResponse), { incremental: validationQuery.incremental, query: validationQueriesWithoutWrappers[index].query })));
40965
+ }
40966
+ return queryEvaluations;
40967
+ }
40968
+ async tables(_database, schema) {
40969
+ const params = [];
40970
+ let schemaClause = "";
40971
+ if (schema) {
40972
+ schemaClause = "and table_schema = ?";
40973
+ params.push(schema);
40974
+ }
40975
+ const queryResult = await this.execute(`select table_name, table_schema
40976
+ from information_schema.tables
40977
+ where table_schema not in ('information_schema', 'mysql', 'performance_schema', 'sys')
40978
+ ${schemaClause}`, { params, rowLimit: 10000, includeQueryInError: true });
40979
+ const targets = queryResult.rows.map(row => ({
40980
+ schema: row.table_schema,
40981
+ name: row.table_name
40982
+ }));
40983
+ return await Promise.all(targets.map(target => this.table(target)));
40984
+ }
40985
+ async search(searchText, options = { limit: 1000 }) {
40986
+ const results = await this.execute(`select tables.table_schema as table_schema, tables.table_name as table_name
40987
+ from information_schema.tables as tables
40988
+ left join information_schema.columns columns
40989
+ on tables.table_schema = columns.table_schema
40990
+ and tables.table_name = columns.table_name
40991
+ where tables.table_schema like ?
40992
+ or tables.table_name like ?
40993
+ or columns.column_name like ?
40994
+ group by 1, 2`, {
40995
+ params: [`%${searchText}%`, `%${searchText}%`, `%${searchText}%`],
40996
+ rowLimit: options.limit
40997
+ });
40998
+ return await Promise.all(results.rows.map(row => this.table({
40999
+ schema: row.table_schema,
41000
+ name: row.table_name
41001
+ })));
41002
+ }
41003
+ async table(target) {
41004
+ var _a;
41005
+ const params = [target.schema, target.name];
41006
+ const [tableResults, columnResults] = await Promise.all([
41007
+ this.execute(`select table_type from information_schema.tables
41008
+ where table_schema = ? and table_name = ?`, { params, includeQueryInError: true }),
41009
+ this.execute(`select column_name, data_type, ordinal_position
41010
+ from information_schema.columns
41011
+ where table_schema = ? and table_name = ?
41012
+ order by ordinal_position`, { params, includeQueryInError: true })
41013
+ ]);
41014
+ if (tableResults.rows.length === 0) {
41015
+ return null;
41016
+ }
41017
+ const tableType = String((_a = tableResults.rows[0].table_type) !== null && _a !== void 0 ? _a : tableResults.rows[0].TABLE_TYPE).toUpperCase();
41018
+ return sqlanvil.TableMetadata.create({
41019
+ target,
41020
+ type: tableType === "VIEW" ? sqlanvil.TableMetadata.Type.VIEW : sqlanvil.TableMetadata.Type.TABLE,
41021
+ fields: columnResults.rows.map(row => {
41022
+ var _a, _b;
41023
+ 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))
41026
+ });
41027
+ })
41028
+ });
41029
+ }
41030
+ async deleteTable(target) {
41031
+ const metadata = await this.table(target);
41032
+ if (!metadata) {
41033
+ return;
41034
+ }
41035
+ const kind = metadata.type === sqlanvil.TableMetadata.Type.VIEW ? "view" : "table";
41036
+ await this.execute(`drop ${kind} if exists \`${target.schema}\`.\`${target.name}\``, {
41037
+ includeQueryInError: true
41038
+ });
41039
+ }
41040
+ async schemas(_database) {
41041
+ const result = await this.execute(`select schema_name from information_schema.schemata`, {
41042
+ includeQueryInError: true
41043
+ });
41044
+ return result.rows
41045
+ .map(row => { var _a; return ((_a = row.schema_name) !== null && _a !== void 0 ? _a : row.SCHEMA_NAME); })
41046
+ .filter(name => !INTERNAL_SCHEMAS$1.has(name));
41047
+ }
41048
+ async createSchema(_database, schema) {
41049
+ await this.execute(`create database if not exists \`${schema}\``, {
41050
+ includeQueryInError: true
41051
+ });
41052
+ }
41053
+ async setMetadata(_action) {
41054
+ return;
41055
+ }
41056
+ async close() {
41057
+ await this.queryExecutor.close();
41058
+ }
41059
+ }
41060
+
40329
41061
  const maybeInitializePg = (() => {
40330
41062
  let initialized = false;
40331
41063
  return () => {
@@ -42105,7 +42837,7 @@ const icebergOption = option("iceberg", {
42105
42837
  const warehouseOption = option("warehouse", {
42106
42838
  describe: "Target warehouse for the new project.",
42107
42839
  type: "string",
42108
- choices: ["bigquery", "postgres", "supabase"],
42840
+ choices: ["bigquery", "postgres", "supabase", "mysql"],
42109
42841
  default: "supabase"
42110
42842
  });
42111
42843
  const testConnectionOptionName = "test-connection";
@@ -42382,6 +43114,9 @@ function runCli() {
42382
43114
  else if (warehouse.toLowerCase() === "postgres") {
42383
43115
  dbadapter = await PostgresDbAdapter.create(readCredentials);
42384
43116
  }
43117
+ else if (warehouse.toLowerCase() === "mysql") {
43118
+ dbadapter = await MySqlDbAdapter.create(readCredentials);
43119
+ }
42385
43120
  else {
42386
43121
  dbadapter = new BigQueryDbAdapter(readCredentials);
42387
43122
  }
@@ -42455,6 +43190,9 @@ function runCli() {
42455
43190
  else if (warehouse.toLowerCase() === "postgres") {
42456
43191
  dbadapter = await PostgresDbAdapter.create(readCredentials);
42457
43192
  }
43193
+ else if (warehouse.toLowerCase() === "mysql") {
43194
+ dbadapter = await MySqlDbAdapter.create(readCredentials);
43195
+ }
42458
43196
  else {
42459
43197
  dbadapter = new BigQueryDbAdapter(readCredentials);
42460
43198
  }
package/package.json CHANGED
@@ -9,6 +9,7 @@
9
9
  "js-beautify": "^1.10.2",
10
10
  "js-yaml": "^4.1.1",
11
11
  "moo": "^0.5.0",
12
+ "mysql2": "^3.11.0",
12
13
  "object-sizeof": "^1.6.1",
13
14
  "parse-duration": "^1.0.0",
14
15
  "pg": "^8.11.3",
@@ -61,7 +62,7 @@
61
62
  "bin": {
62
63
  "sqlanvil": "bundle.js"
63
64
  },
64
- "version": "1.4.1",
65
+ "version": "1.5.0",
65
66
  "name": "@sqlanvil/cli",
66
67
  "description": "sqlanvil command line interface.",
67
68
  "main": "bundle.js"
package/worker_bundle.js CHANGED
@@ -14892,6 +14892,327 @@ const sqlanvil = $root.sqlanvil = (() => {
14892
14892
  return SupabaseConnection;
14893
14893
  })();
14894
14894
 
14895
+ sqlanvil.MysqlConnection = (function() {
14896
+
14897
+ /**
14898
+ * Properties of a MysqlConnection.
14899
+ * @memberof sqlanvil
14900
+ * @interface IMysqlConnection
14901
+ * @property {string|null} [host] MysqlConnection host
14902
+ * @property {number|null} [port] MysqlConnection port
14903
+ * @property {string|null} [database] MysqlConnection database
14904
+ * @property {string|null} [user] MysqlConnection user
14905
+ * @property {string|null} [password] MysqlConnection password
14906
+ * @property {string|null} [sslMode] MysqlConnection sslMode
14907
+ */
14908
+
14909
+ /**
14910
+ * Constructs a new MysqlConnection.
14911
+ * @memberof sqlanvil
14912
+ * @classdesc Represents a MysqlConnection.
14913
+ * @implements IMysqlConnection
14914
+ * @constructor
14915
+ * @param {sqlanvil.IMysqlConnection=} [properties] Properties to set
14916
+ */
14917
+ function MysqlConnection(properties) {
14918
+ if (properties)
14919
+ for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
14920
+ if (properties[keys[i]] != null)
14921
+ this[keys[i]] = properties[keys[i]];
14922
+ }
14923
+
14924
+ /**
14925
+ * MysqlConnection host.
14926
+ * @member {string} host
14927
+ * @memberof sqlanvil.MysqlConnection
14928
+ * @instance
14929
+ */
14930
+ MysqlConnection.prototype.host = "";
14931
+
14932
+ /**
14933
+ * MysqlConnection port.
14934
+ * @member {number} port
14935
+ * @memberof sqlanvil.MysqlConnection
14936
+ * @instance
14937
+ */
14938
+ MysqlConnection.prototype.port = 0;
14939
+
14940
+ /**
14941
+ * MysqlConnection database.
14942
+ * @member {string} database
14943
+ * @memberof sqlanvil.MysqlConnection
14944
+ * @instance
14945
+ */
14946
+ MysqlConnection.prototype.database = "";
14947
+
14948
+ /**
14949
+ * MysqlConnection user.
14950
+ * @member {string} user
14951
+ * @memberof sqlanvil.MysqlConnection
14952
+ * @instance
14953
+ */
14954
+ MysqlConnection.prototype.user = "";
14955
+
14956
+ /**
14957
+ * MysqlConnection password.
14958
+ * @member {string} password
14959
+ * @memberof sqlanvil.MysqlConnection
14960
+ * @instance
14961
+ */
14962
+ MysqlConnection.prototype.password = "";
14963
+
14964
+ /**
14965
+ * MysqlConnection sslMode.
14966
+ * @member {string} sslMode
14967
+ * @memberof sqlanvil.MysqlConnection
14968
+ * @instance
14969
+ */
14970
+ MysqlConnection.prototype.sslMode = "";
14971
+
14972
+ /**
14973
+ * Creates a new MysqlConnection instance using the specified properties.
14974
+ * @function create
14975
+ * @memberof sqlanvil.MysqlConnection
14976
+ * @static
14977
+ * @param {sqlanvil.IMysqlConnection=} [properties] Properties to set
14978
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection instance
14979
+ */
14980
+ MysqlConnection.create = function create(properties) {
14981
+ return new MysqlConnection(properties);
14982
+ };
14983
+
14984
+ /**
14985
+ * Encodes the specified MysqlConnection message. Does not implicitly {@link sqlanvil.MysqlConnection.verify|verify} messages.
14986
+ * @function encode
14987
+ * @memberof sqlanvil.MysqlConnection
14988
+ * @static
14989
+ * @param {sqlanvil.IMysqlConnection} message MysqlConnection message or plain object to encode
14990
+ * @param {$protobuf.Writer} [writer] Writer to encode to
14991
+ * @returns {$protobuf.Writer} Writer
14992
+ */
14993
+ MysqlConnection.encode = function encode(message, writer) {
14994
+ if (!writer)
14995
+ writer = $Writer.create();
14996
+ if (message.host != null && Object.hasOwnProperty.call(message, "host"))
14997
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.host);
14998
+ if (message.port != null && Object.hasOwnProperty.call(message, "port"))
14999
+ writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.port);
15000
+ if (message.database != null && Object.hasOwnProperty.call(message, "database"))
15001
+ writer.uint32(/* id 3, wireType 2 =*/26).string(message.database);
15002
+ if (message.user != null && Object.hasOwnProperty.call(message, "user"))
15003
+ writer.uint32(/* id 4, wireType 2 =*/34).string(message.user);
15004
+ if (message.password != null && Object.hasOwnProperty.call(message, "password"))
15005
+ writer.uint32(/* id 5, wireType 2 =*/42).string(message.password);
15006
+ if (message.sslMode != null && Object.hasOwnProperty.call(message, "sslMode"))
15007
+ writer.uint32(/* id 6, wireType 2 =*/50).string(message.sslMode);
15008
+ return writer;
15009
+ };
15010
+
15011
+ /**
15012
+ * Encodes the specified MysqlConnection message, length delimited. Does not implicitly {@link sqlanvil.MysqlConnection.verify|verify} messages.
15013
+ * @function encodeDelimited
15014
+ * @memberof sqlanvil.MysqlConnection
15015
+ * @static
15016
+ * @param {sqlanvil.IMysqlConnection} message MysqlConnection message or plain object to encode
15017
+ * @param {$protobuf.Writer} [writer] Writer to encode to
15018
+ * @returns {$protobuf.Writer} Writer
15019
+ */
15020
+ MysqlConnection.encodeDelimited = function encodeDelimited(message, writer) {
15021
+ return this.encode(message, writer).ldelim();
15022
+ };
15023
+
15024
+ /**
15025
+ * Decodes a MysqlConnection message from the specified reader or buffer.
15026
+ * @function decode
15027
+ * @memberof sqlanvil.MysqlConnection
15028
+ * @static
15029
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
15030
+ * @param {number} [length] Message length if known beforehand
15031
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15032
+ * @throws {Error} If the payload is not a reader or valid buffer
15033
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
15034
+ */
15035
+ MysqlConnection.decode = function decode(reader, length, error) {
15036
+ if (!(reader instanceof $Reader))
15037
+ reader = $Reader.create(reader);
15038
+ let end = length === undefined ? reader.len : reader.pos + length, message = new $root.sqlanvil.MysqlConnection();
15039
+ while (reader.pos < end) {
15040
+ let tag = reader.uint32();
15041
+ if (tag === error)
15042
+ break;
15043
+ switch (tag >>> 3) {
15044
+ case 1: {
15045
+ message.host = reader.string();
15046
+ break;
15047
+ }
15048
+ case 2: {
15049
+ message.port = reader.uint32();
15050
+ break;
15051
+ }
15052
+ case 3: {
15053
+ message.database = reader.string();
15054
+ break;
15055
+ }
15056
+ case 4: {
15057
+ message.user = reader.string();
15058
+ break;
15059
+ }
15060
+ case 5: {
15061
+ message.password = reader.string();
15062
+ break;
15063
+ }
15064
+ case 6: {
15065
+ message.sslMode = reader.string();
15066
+ break;
15067
+ }
15068
+ default:
15069
+ reader.skipType(tag & 7);
15070
+ break;
15071
+ }
15072
+ }
15073
+ return message;
15074
+ };
15075
+
15076
+ /**
15077
+ * Decodes a MysqlConnection message from the specified reader or buffer, length delimited.
15078
+ * @function decodeDelimited
15079
+ * @memberof sqlanvil.MysqlConnection
15080
+ * @static
15081
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
15082
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15083
+ * @throws {Error} If the payload is not a reader or valid buffer
15084
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
15085
+ */
15086
+ MysqlConnection.decodeDelimited = function decodeDelimited(reader) {
15087
+ if (!(reader instanceof $Reader))
15088
+ reader = new $Reader(reader);
15089
+ return this.decode(reader, reader.uint32());
15090
+ };
15091
+
15092
+ /**
15093
+ * Verifies a MysqlConnection message.
15094
+ * @function verify
15095
+ * @memberof sqlanvil.MysqlConnection
15096
+ * @static
15097
+ * @param {Object.<string,*>} message Plain object to verify
15098
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
15099
+ */
15100
+ MysqlConnection.verify = function verify(message) {
15101
+ if (typeof message !== "object" || message === null)
15102
+ return "object expected";
15103
+ if (message.host != null && message.hasOwnProperty("host"))
15104
+ if (!$util.isString(message.host))
15105
+ return "host: string expected";
15106
+ if (message.port != null && message.hasOwnProperty("port"))
15107
+ if (!$util.isInteger(message.port))
15108
+ return "port: integer expected";
15109
+ if (message.database != null && message.hasOwnProperty("database"))
15110
+ if (!$util.isString(message.database))
15111
+ return "database: string expected";
15112
+ if (message.user != null && message.hasOwnProperty("user"))
15113
+ if (!$util.isString(message.user))
15114
+ return "user: string expected";
15115
+ if (message.password != null && message.hasOwnProperty("password"))
15116
+ if (!$util.isString(message.password))
15117
+ return "password: string expected";
15118
+ if (message.sslMode != null && message.hasOwnProperty("sslMode"))
15119
+ if (!$util.isString(message.sslMode))
15120
+ return "sslMode: string expected";
15121
+ return null;
15122
+ };
15123
+
15124
+ /**
15125
+ * Creates a MysqlConnection message from a plain object. Also converts values to their respective internal types.
15126
+ * @function fromObject
15127
+ * @memberof sqlanvil.MysqlConnection
15128
+ * @static
15129
+ * @param {Object.<string,*>} object Plain object
15130
+ * @returns {sqlanvil.MysqlConnection} MysqlConnection
15131
+ */
15132
+ MysqlConnection.fromObject = function fromObject(object) {
15133
+ if (object instanceof $root.sqlanvil.MysqlConnection)
15134
+ return object;
15135
+ let message = new $root.sqlanvil.MysqlConnection();
15136
+ if (object.host != null)
15137
+ message.host = String(object.host);
15138
+ if (object.port != null)
15139
+ message.port = object.port >>> 0;
15140
+ if (object.database != null)
15141
+ message.database = String(object.database);
15142
+ if (object.user != null)
15143
+ message.user = String(object.user);
15144
+ if (object.password != null)
15145
+ message.password = String(object.password);
15146
+ if (object.sslMode != null)
15147
+ message.sslMode = String(object.sslMode);
15148
+ return message;
15149
+ };
15150
+
15151
+ /**
15152
+ * Creates a plain object from a MysqlConnection message. Also converts values to other types if specified.
15153
+ * @function toObject
15154
+ * @memberof sqlanvil.MysqlConnection
15155
+ * @static
15156
+ * @param {sqlanvil.MysqlConnection} message MysqlConnection
15157
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
15158
+ * @returns {Object.<string,*>} Plain object
15159
+ */
15160
+ MysqlConnection.toObject = function toObject(message, options) {
15161
+ if (!options)
15162
+ options = {};
15163
+ let object = {};
15164
+ if (options.defaults) {
15165
+ object.host = "";
15166
+ object.port = 0;
15167
+ object.database = "";
15168
+ object.user = "";
15169
+ object.password = "";
15170
+ object.sslMode = "";
15171
+ }
15172
+ if (message.host != null && message.hasOwnProperty("host"))
15173
+ object.host = message.host;
15174
+ if (message.port != null && message.hasOwnProperty("port"))
15175
+ object.port = message.port;
15176
+ if (message.database != null && message.hasOwnProperty("database"))
15177
+ object.database = message.database;
15178
+ if (message.user != null && message.hasOwnProperty("user"))
15179
+ object.user = message.user;
15180
+ if (message.password != null && message.hasOwnProperty("password"))
15181
+ object.password = message.password;
15182
+ if (message.sslMode != null && message.hasOwnProperty("sslMode"))
15183
+ object.sslMode = message.sslMode;
15184
+ return object;
15185
+ };
15186
+
15187
+ /**
15188
+ * Converts this MysqlConnection to JSON.
15189
+ * @function toJSON
15190
+ * @memberof sqlanvil.MysqlConnection
15191
+ * @instance
15192
+ * @returns {Object.<string,*>} JSON object
15193
+ */
15194
+ MysqlConnection.prototype.toJSON = function toJSON() {
15195
+ return this.constructor.toObject(this, $protobuf__namespace.util.toJSONOptions);
15196
+ };
15197
+
15198
+ /**
15199
+ * Gets the default type url for MysqlConnection
15200
+ * @function getTypeUrl
15201
+ * @memberof sqlanvil.MysqlConnection
15202
+ * @static
15203
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
15204
+ * @returns {string} The default type url
15205
+ */
15206
+ MysqlConnection.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
15207
+ if (typeUrlPrefix === undefined) {
15208
+ typeUrlPrefix = "type.googleapis.com";
15209
+ }
15210
+ return typeUrlPrefix + "/sqlanvil.MysqlConnection";
15211
+ };
15212
+
15213
+ return MysqlConnection;
15214
+ })();
15215
+
14895
15216
  sqlanvil.WarehouseConfig = (function() {
14896
15217
 
14897
15218
  /**
@@ -14901,6 +15222,7 @@ const sqlanvil = $root.sqlanvil = (() => {
14901
15222
  * @property {sqlanvil.IBigQueryConnection|null} [bigquery] WarehouseConfig bigquery
14902
15223
  * @property {sqlanvil.IPostgresConnection|null} [postgres] WarehouseConfig postgres
14903
15224
  * @property {sqlanvil.ISupabaseConnection|null} [supabase] WarehouseConfig supabase
15225
+ * @property {sqlanvil.IMysqlConnection|null} [mysql] WarehouseConfig mysql
14904
15226
  */
14905
15227
 
14906
15228
  /**
@@ -14942,17 +15264,25 @@ const sqlanvil = $root.sqlanvil = (() => {
14942
15264
  */
14943
15265
  WarehouseConfig.prototype.supabase = null;
14944
15266
 
15267
+ /**
15268
+ * WarehouseConfig mysql.
15269
+ * @member {sqlanvil.IMysqlConnection|null|undefined} mysql
15270
+ * @memberof sqlanvil.WarehouseConfig
15271
+ * @instance
15272
+ */
15273
+ WarehouseConfig.prototype.mysql = null;
15274
+
14945
15275
  // OneOf field names bound to virtual getters and setters
14946
15276
  let $oneOfFields;
14947
15277
 
14948
15278
  /**
14949
15279
  * WarehouseConfig connection.
14950
- * @member {"bigquery"|"postgres"|"supabase"|undefined} connection
15280
+ * @member {"bigquery"|"postgres"|"supabase"|"mysql"|undefined} connection
14951
15281
  * @memberof sqlanvil.WarehouseConfig
14952
15282
  * @instance
14953
15283
  */
14954
15284
  Object.defineProperty(WarehouseConfig.prototype, "connection", {
14955
- get: $util.oneOfGetter($oneOfFields = ["bigquery", "postgres", "supabase"]),
15285
+ get: $util.oneOfGetter($oneOfFields = ["bigquery", "postgres", "supabase", "mysql"]),
14956
15286
  set: $util.oneOfSetter($oneOfFields)
14957
15287
  });
14958
15288
 
@@ -14986,6 +15316,8 @@ const sqlanvil = $root.sqlanvil = (() => {
14986
15316
  $root.sqlanvil.PostgresConnection.encode(message.postgres, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
14987
15317
  if (message.supabase != null && Object.hasOwnProperty.call(message, "supabase"))
14988
15318
  $root.sqlanvil.SupabaseConnection.encode(message.supabase, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
15319
+ if (message.mysql != null && Object.hasOwnProperty.call(message, "mysql"))
15320
+ $root.sqlanvil.MysqlConnection.encode(message.mysql, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
14989
15321
  return writer;
14990
15322
  };
14991
15323
 
@@ -15034,6 +15366,10 @@ const sqlanvil = $root.sqlanvil = (() => {
15034
15366
  message.supabase = $root.sqlanvil.SupabaseConnection.decode(reader, reader.uint32());
15035
15367
  break;
15036
15368
  }
15369
+ case 4: {
15370
+ message.mysql = $root.sqlanvil.MysqlConnection.decode(reader, reader.uint32());
15371
+ break;
15372
+ }
15037
15373
  default:
15038
15374
  reader.skipType(tag & 7);
15039
15375
  break;
@@ -15098,6 +15434,16 @@ const sqlanvil = $root.sqlanvil = (() => {
15098
15434
  return "supabase." + error;
15099
15435
  }
15100
15436
  }
15437
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
15438
+ if (properties.connection === 1)
15439
+ return "connection: multiple values";
15440
+ properties.connection = 1;
15441
+ {
15442
+ let error = $root.sqlanvil.MysqlConnection.verify(message.mysql);
15443
+ if (error)
15444
+ return "mysql." + error;
15445
+ }
15446
+ }
15101
15447
  return null;
15102
15448
  };
15103
15449
 
@@ -15128,6 +15474,11 @@ const sqlanvil = $root.sqlanvil = (() => {
15128
15474
  throw TypeError(".sqlanvil.WarehouseConfig.supabase: object expected");
15129
15475
  message.supabase = $root.sqlanvil.SupabaseConnection.fromObject(object.supabase);
15130
15476
  }
15477
+ if (object.mysql != null) {
15478
+ if (typeof object.mysql !== "object")
15479
+ throw TypeError(".sqlanvil.WarehouseConfig.mysql: object expected");
15480
+ message.mysql = $root.sqlanvil.MysqlConnection.fromObject(object.mysql);
15481
+ }
15131
15482
  return message;
15132
15483
  };
15133
15484
 
@@ -15159,6 +15510,11 @@ const sqlanvil = $root.sqlanvil = (() => {
15159
15510
  if (options.oneofs)
15160
15511
  object.connection = "supabase";
15161
15512
  }
15513
+ if (message.mysql != null && message.hasOwnProperty("mysql")) {
15514
+ object.mysql = $root.sqlanvil.MysqlConnection.toObject(message.mysql, options);
15515
+ if (options.oneofs)
15516
+ object.connection = "mysql";
15517
+ }
15162
15518
  return object;
15163
15519
  };
15164
15520