leoric 2.8.4 → 2.8.5
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/History.md +10 -0
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/adapters/sequelize.d.ts +5 -4
- package/src/bone.js +5 -4
- package/src/drivers/abstract/attribute.js +1 -1
- package/src/spell.js +5 -1
- package/src/types/abstract_bone.d.ts +2 -2
- package/src/types/common.d.ts +7 -1
package/History.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
2.8.5 / 2022-09-21
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
## What's Changed
|
|
5
|
+
* fix: deletedAt should always be checked when associating models by @cyjake in https://github.com/cyjake/leoric/pull/347
|
|
6
|
+
* fix: generic type for getDataValue by @vagusX in https://github.com/cyjake/leoric/pull/346
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.8.4...v2.8.5
|
|
10
|
+
|
|
1
11
|
2.8.4 / 2022-09-20
|
|
2
12
|
==================
|
|
3
13
|
|
package/index.d.ts
CHANGED
|
@@ -76,8 +76,8 @@ export default class Realm {
|
|
|
76
76
|
|
|
77
77
|
query<T extends typeof Bone>(sql: string, values?: Array<Literal>, options?: RawQueryOptions & { model?: T }): Promise<{ rows: T extends typeof Bone ? InstanceType<T>[] : Object[], fields?: Object[], affectedRows?: number }>;
|
|
78
78
|
|
|
79
|
-
transaction<T extends (connection: Connection) => Generator>(callback: T): Promise<GeneratorReturnType<ReturnType<T>>>;
|
|
80
|
-
transaction<T extends (connection: Connection) => Promise<any>>(callback: T): Promise<ReturnType<T>>;
|
|
79
|
+
transaction<T extends (options: { connection: Connection }) => Generator>(callback: T): Promise<GeneratorReturnType<ReturnType<T>>>;
|
|
80
|
+
transaction<T extends (options: { connection: Connection }) => Promise<any>>(callback: T): Promise<ReturnType<T>>;
|
|
81
81
|
|
|
82
82
|
sync(options?: SyncOptions): Promise<void>;
|
|
83
83
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attributes, Literal, OperatorCondition,
|
|
1
|
+
import {
|
|
2
|
+
Attributes, Literal, OperatorCondition,
|
|
3
3
|
BoneOptions, ResultSet, Raw,
|
|
4
4
|
SetOptions, BeforeHooksType, AfterHooksType,
|
|
5
5
|
QueryOptions, OrderOptions, QueryResult
|
|
@@ -181,8 +181,9 @@ export class SequelizeBone extends AbstractBone {
|
|
|
181
181
|
where(): { [key: string]: number | bigint | string };
|
|
182
182
|
set(key: string, value: Literal | Literal[]): void;
|
|
183
183
|
get(key?: string): Literal | { [key: string]: Literal };
|
|
184
|
-
setDataValue(key:
|
|
185
|
-
getDataValue(
|
|
184
|
+
setDataValue<T, Key extends keyof T>(this: T, key: Key, value: T[Key]): void;
|
|
185
|
+
getDataValue<T>(this: T): T;
|
|
186
|
+
getDataValue<T, Key extends keyof T>(this: T, key: Key): T[Key];
|
|
186
187
|
previous(key?: string): Literal | Literal[] | { [key: string]: Literal | Literal[] };
|
|
187
188
|
isSoftDeleted(): boolean;
|
|
188
189
|
|
package/src/bone.js
CHANGED
|
@@ -1016,6 +1016,9 @@ class Bone {
|
|
|
1016
1016
|
if (columnInfo && attribute.type instanceof DataTypes.DATE && attribute.type.precision == null) {
|
|
1017
1017
|
attribute.type.precision = columnInfo.datetimePrecision;
|
|
1018
1018
|
}
|
|
1019
|
+
// if (columnInfo && columnInfo.defaultValue != null && attribute.defaultValue === undefined) {
|
|
1020
|
+
// attribute.defaultValue = columnInfo.defaultValue;
|
|
1021
|
+
// }
|
|
1019
1022
|
}
|
|
1020
1023
|
|
|
1021
1024
|
const primaryKey = Object.keys(attributes).find(key => attributes[key].primaryKey);
|
|
@@ -1263,10 +1266,8 @@ class Bone {
|
|
|
1263
1266
|
throw new Error(`unable to use virtual attribute ${opts.foreignKey} as foreign key in model ${Model.name}`);
|
|
1264
1267
|
}
|
|
1265
1268
|
|
|
1266
|
-
const { deletedAt } =
|
|
1267
|
-
if (Model.attributes[deletedAt]
|
|
1268
|
-
opts.where = { [deletedAt]: null };
|
|
1269
|
-
}
|
|
1269
|
+
const { deletedAt } = Model.timestamps;
|
|
1270
|
+
if (Model.attributes[deletedAt]) opts.where = { [deletedAt]: null, ...opts.where };
|
|
1270
1271
|
this.associations[name] = { ...opts, Model };
|
|
1271
1272
|
}
|
|
1272
1273
|
|
|
@@ -131,7 +131,7 @@ class Attribute {
|
|
|
131
131
|
|
|
132
132
|
equals(columnInfo) {
|
|
133
133
|
if (!columnInfo) return false;
|
|
134
|
-
const props = [ 'allowNull', 'dataType', 'primaryKey' ];
|
|
134
|
+
const props = [ 'allowNull', 'dataType', 'defaultValue', 'primaryKey' ];
|
|
135
135
|
for (const prop of props) {
|
|
136
136
|
// SQLite has default value as string even if data type is integer
|
|
137
137
|
if (this[prop] != columnInfo[prop]) {
|
package/src/spell.js
CHANGED
|
@@ -165,7 +165,11 @@ function joinOnConditions(spell, BaseModel, baseName, refName, { where, associat
|
|
|
165
165
|
};
|
|
166
166
|
if (!where) where = association.where;
|
|
167
167
|
if (where) {
|
|
168
|
-
const whereConditions =
|
|
168
|
+
const whereConditions = parseConditions(BaseModel, where).reduce((result, condition) => {
|
|
169
|
+
if (!result) return condition;
|
|
170
|
+
return { type: 'op', name: 'and', args: [ result, condition ] };
|
|
171
|
+
});
|
|
172
|
+
walkExpr(whereConditions, node => {
|
|
169
173
|
if (node.type == 'id') node.qualifiers = [refName];
|
|
170
174
|
});
|
|
171
175
|
return { type: 'op', name: 'and', args: [ onConditions, whereConditions ] };
|
|
@@ -215,8 +215,8 @@ export class AbstractBone {
|
|
|
215
215
|
* yield Muscle.create({ boneId: bone.id, bar: 1 })
|
|
216
216
|
* });
|
|
217
217
|
*/
|
|
218
|
-
static transaction<T extends (connection: Connection) => Generator>(callback: T): Promise<GeneratorReturnType<ReturnType<T>>>;
|
|
219
|
-
static transaction<T extends (connection: Connection) => Promise<any>>(callback: T): Promise<ReturnType<T>>;
|
|
218
|
+
static transaction<T extends (options: { connection: Connection }) => Generator>(callback: T): Promise<GeneratorReturnType<ReturnType<T>>>;
|
|
219
|
+
static transaction<T extends (options: { connection: Connection }) => Promise<any>>(callback: T): Promise<ReturnType<T>>;
|
|
220
220
|
|
|
221
221
|
static describe(): Promise<{[key: string]: any[]}>;
|
|
222
222
|
|
package/src/types/common.d.ts
CHANGED
|
@@ -36,8 +36,14 @@ export interface Connection {
|
|
|
36
36
|
*/
|
|
37
37
|
query(
|
|
38
38
|
query: string,
|
|
39
|
-
values
|
|
39
|
+
values?: Array<Literal | Literal[]>,
|
|
40
40
|
): Promise<QueryResult>;
|
|
41
|
+
|
|
42
|
+
query(
|
|
43
|
+
query: string,
|
|
44
|
+
values?: Array<Literal | Literal[]>,
|
|
45
|
+
callback?: (err: Error, result: QueryResult) => void,
|
|
46
|
+
): void
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
export declare class Pool {
|