@travetto/model-mysql 5.0.0-rc.8 → 5.0.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 +3 -3
- package/package.json +8 -8
- package/src/connection.ts +2 -3
- package/src/dialect.ts +2 -3
package/README.md
CHANGED
|
@@ -42,11 +42,12 @@ export class Init {
|
|
|
42
42
|
}
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
where the [SQLModelConfig](https://github.com/travetto/travetto/tree/main/module/model-sql/src/config.ts#
|
|
45
|
+
where the [SQLModelConfig](https://github.com/travetto/travetto/tree/main/module/model-sql/src/config.ts#L8) is defined by:
|
|
46
46
|
|
|
47
47
|
**Code: Structure of SQLModelConfig**
|
|
48
48
|
```typescript
|
|
49
49
|
import { Config } from '@travetto/config';
|
|
50
|
+
import { asFull } from '@travetto/runtime';
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* SQL Model Config
|
|
@@ -88,8 +89,7 @@ export class SQLModelConfig<T extends {} = {}> {
|
|
|
88
89
|
/**
|
|
89
90
|
* Raw client options
|
|
90
91
|
*/
|
|
91
|
-
|
|
92
|
-
options: T = {} as T;
|
|
92
|
+
options: T = asFull({});
|
|
93
93
|
}
|
|
94
94
|
```
|
|
95
95
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-mysql",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "MySQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sql",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"directory": "module/model-mysql"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/config": "^5.0.0
|
|
31
|
-
"@travetto/context": "^5.0.0
|
|
32
|
-
"@travetto/model": "^5.0.0
|
|
33
|
-
"@travetto/model-query": "^5.0.0
|
|
34
|
-
"@travetto/model-sql": "^5.0.0
|
|
35
|
-
"mysql2": "^3.
|
|
30
|
+
"@travetto/config": "^5.0.0",
|
|
31
|
+
"@travetto/context": "^5.0.0",
|
|
32
|
+
"@travetto/model": "^5.0.0",
|
|
33
|
+
"@travetto/model-query": "^5.0.0",
|
|
34
|
+
"@travetto/model-sql": "^5.0.0",
|
|
35
|
+
"mysql2": "^3.11.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/command": "^5.0.0
|
|
38
|
+
"@travetto/command": "^5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/command": {
|
package/src/connection.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createPool } from 'mysql2';
|
|
2
2
|
|
|
3
|
-
import { ShutdownManager } from '@travetto/runtime';
|
|
3
|
+
import { castTo, ShutdownManager } from '@travetto/runtime';
|
|
4
4
|
import { AsyncContext } from '@travetto/context';
|
|
5
5
|
import { ExistsError } from '@travetto/model';
|
|
6
6
|
import { Connection, SQLModelConfig } from '@travetto/model-sql';
|
|
@@ -69,8 +69,7 @@ export class MySQLConnection extends Connection<PoolConnection> {
|
|
|
69
69
|
if (isSimplePacket(results[0])) {
|
|
70
70
|
return { records: [], count: results[0].affectedRows };
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
const records: T[] = [...results].map(v => ({ ...v }) as T);
|
|
72
|
+
const records: T[] = [...results].map(v => castTo({ ...v }));
|
|
74
73
|
return { records, count: records.length };
|
|
75
74
|
}
|
|
76
75
|
} catch (err) {
|
package/src/dialect.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FieldConfig } from '@travetto/schema';
|
|
|
2
2
|
import { Injectable } from '@travetto/di';
|
|
3
3
|
import { AsyncContext } from '@travetto/context';
|
|
4
4
|
import { WhereClause } from '@travetto/model-query';
|
|
5
|
-
import { Class } from '@travetto/runtime';
|
|
5
|
+
import { castTo, Class } from '@travetto/runtime';
|
|
6
6
|
import { ModelType } from '@travetto/model';
|
|
7
7
|
import { SQLModelConfig, SQLDialect } from '@travetto/model-sql';
|
|
8
8
|
import { VisitStack } from '@travetto/model-sql/src/internal/util';
|
|
@@ -80,8 +80,7 @@ export class MySQLDialect extends SQLDialect {
|
|
|
80
80
|
* Define column modification
|
|
81
81
|
*/
|
|
82
82
|
getModifyColumnSQL(stack: VisitStack[]): string {
|
|
83
|
-
|
|
84
|
-
const field = stack[stack.length - 1] as FieldConfig;
|
|
83
|
+
const field: FieldConfig = castTo(stack[stack.length - 1]);
|
|
85
84
|
return `ALTER TABLE ${this.parentTable(stack)} MODIFY COLUMN ${this.getColumnDefinition(field)};`;
|
|
86
85
|
}
|
|
87
86
|
|