sasat 0.14.6 → 0.14.7
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.
|
@@ -13,7 +13,6 @@ export class MysqlClient extends DBClient {
|
|
|
13
13
|
async transaction() {
|
|
14
14
|
const connection = mysql.createConnection(connectionConfig);
|
|
15
15
|
await promisify(connection.beginTransaction).bind(connection)();
|
|
16
|
-
await promisify(connection.query).bind(connection)('SET autocommit = 1');
|
|
17
16
|
return new MySqlTransaction(connection);
|
|
18
17
|
}
|
|
19
18
|
async release() {
|
|
@@ -21,7 +20,6 @@ export class MysqlClient extends DBClient {
|
|
|
21
20
|
this._released = true;
|
|
22
21
|
}
|
|
23
22
|
execSql(sql) {
|
|
24
|
-
console.log(sql);
|
|
25
23
|
return promisify(this.pool.query).bind(this.pool)(sql);
|
|
26
24
|
}
|
|
27
25
|
}
|
|
@@ -84,13 +84,12 @@ export class GeneratedRepositoryGenerator {
|
|
|
84
84
|
.call(qExpr.property('field').call(tsg.identifier('tableName'), tsg.string(it.name)), qExpr.property('value').call(tsg.identifier(it.name))));
|
|
85
85
|
const body = [
|
|
86
86
|
tsg.variable('const', 'tableName', tsg.identifier('fields?.tableAlias || this.tableName')),
|
|
87
|
-
tsg.
|
|
87
|
+
tsg.return(tsg.identifier(it.returnType.isArray ? 'this.find' : 'this.first').call(tsg.identifier('fields'), exps.length === 1
|
|
88
88
|
? exps[0]
|
|
89
89
|
: qExpr
|
|
90
90
|
.property('conditions')
|
|
91
91
|
.property('and')
|
|
92
|
-
.call(...exps)))
|
|
93
|
-
tsg.return(tsg.identifier(it.returnType.isArray ? 'result' : 'result[0] || null')),
|
|
92
|
+
.call(...exps))),
|
|
94
93
|
];
|
|
95
94
|
const returnType = tsg
|
|
96
95
|
.typeRef('EntityResult', [
|
|
@@ -105,7 +104,7 @@ export class GeneratedRepositoryGenerator {
|
|
|
105
104
|
.importFrom(Directory.generatedPath(Directory.paths.generatedDataSource.db, 'fields'))),
|
|
106
105
|
], new TypeReference('Promise', [
|
|
107
106
|
it.returnType.isArray ? tsg.arrayType(returnType) : tsg.unionType([returnType, tsg.typeRef('null')]),
|
|
108
|
-
]), body)
|
|
107
|
+
]), body);
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
110
|
}
|
|
@@ -58,7 +58,7 @@ export class SasatRepository {
|
|
|
58
58
|
return hydrate(result, info);
|
|
59
59
|
}
|
|
60
60
|
async first(fields, where) {
|
|
61
|
-
const result = await this.find(fields, where
|
|
61
|
+
const result = await this.find(fields, where);
|
|
62
62
|
if (result.length !== 0)
|
|
63
63
|
return result[0];
|
|
64
64
|
return null;
|