@travetto/model-mysql 7.1.4 → 8.0.0-alpha.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-mysql",
3
- "version": "7.1.4",
3
+ "version": "8.0.0-alpha.1",
4
4
  "type": "module",
5
5
  "description": "MySQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
6
6
  "keywords": [
@@ -28,15 +28,15 @@
28
28
  "directory": "module/model-mysql"
29
29
  },
30
30
  "dependencies": {
31
- "@travetto/config": "^7.1.4",
32
- "@travetto/context": "^7.1.4",
33
- "@travetto/model": "^7.1.4",
34
- "@travetto/model-query": "^7.1.4",
35
- "@travetto/model-sql": "^7.1.4",
36
- "mysql2": "^3.16.0"
31
+ "@travetto/config": "^8.0.0-alpha.1",
32
+ "@travetto/context": "^8.0.0-alpha.1",
33
+ "@travetto/model": "^8.0.0-alpha.1",
34
+ "@travetto/model-query": "^8.0.0-alpha.1",
35
+ "@travetto/model-sql": "^8.0.0-alpha.1",
36
+ "mysql2": "^3.19.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@travetto/cli": "^7.1.4"
39
+ "@travetto/cli": "^8.0.0-alpha.1"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "@travetto/cli": {
package/src/connection.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createPool } from 'mysql2';
2
- import type { PoolConnection, Pool, OkPacket, ResultSetHeader } from 'mysql2/promise';
2
+ import type { PoolConnection, Pool, OkPacket, ResultSetHeader, TypeCastField } from 'mysql2/promise';
3
3
 
4
4
  import { castTo, JSONUtil, ShutdownManager } from '@travetto/runtime';
5
5
  import type { AsyncContext } from '@travetto/context';
@@ -35,6 +35,7 @@ export class MySQLConnection extends Connection<PoolConnection> {
35
35
  database: this.#config.database,
36
36
  host: this.#config.host,
37
37
  port: this.#config.port,
38
+ supportBigNumbers: true,
38
39
  timezone: '+00:00',
39
40
  typeCast: this.typeCast.bind(this),
40
41
  ...(this.#config.options || {})
@@ -47,13 +48,17 @@ export class MySQLConnection extends Connection<PoolConnection> {
47
48
  /**
48
49
  * Support some basic type support for JSON data
49
50
  */
50
- typeCast(field: unknown, next: () => unknown): unknown {
51
+ typeCast(field: TypeCastField, next: () => unknown): unknown {
51
52
  const result = next();
52
- if (typeof result === 'string' && (field && typeof field === 'object' && 'type' in field) && (field.type === 'JSON' || field.type === 'BLOB')) {
53
- if (result.charAt(0) === '{' && result.charAt(result.length - 1) === '}') {
54
- try {
55
- return JSONUtil.parseSafe(result);
56
- } catch { }
53
+ switch (field.type) {
54
+ case 'JSON':
55
+ case 'BLOB': {
56
+ if (typeof result === 'string' && result.charAt(0) === '{' && result.charAt(result.length - 1) === '}') {
57
+ try {
58
+ return JSONUtil.fromUTF8(result);
59
+ } catch { }
60
+ }
61
+ break;
57
62
  }
58
63
  }
59
64
  return result;
@@ -1,6 +1,6 @@
1
1
  import type { ServiceDescriptor } from '@travetto/cli';
2
2
 
3
- const version = process.env.MYSQL_VERSION || '9.5';
3
+ const version = process.env.MYSQL_VERSION || '9.6';
4
4
 
5
5
  export const service: ServiceDescriptor = {
6
6
  name: 'mysql',