@getstrata/core 2.2.5 → 2.2.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @getstrata/core changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.7
|
|
4
|
+
|
|
5
|
+
- Where an ordinary operation needs SQL because the framework cannot express it
|
|
6
|
+
|
|
7
|
+
## 2.2.6
|
|
8
|
+
|
|
9
|
+
- fix(cli): relay shutdown to children and simplify container launcher
|
|
10
|
+
|
|
3
11
|
## 2.2.5
|
|
4
12
|
|
|
5
13
|
- fix(starter): keep container readiness independent of API admission
|
|
@@ -40,6 +40,8 @@ type ModelWriteValues<TEntity> = Partial<TEntity>;
|
|
|
40
40
|
type QueryOrder<TEntity> = {
|
|
41
41
|
column: keyof TEntity & string;
|
|
42
42
|
direction?: "ASC" | "DESC" | "asc" | "desc";
|
|
43
|
+
/** Explicit placement; omitted retains the database's default. */
|
|
44
|
+
nulls?: "first" | "last";
|
|
43
45
|
};
|
|
44
46
|
type QueryOrderShorthand<TEntity> = Partial<Record<keyof TEntity & string, "ASC" | "DESC" | "asc" | "desc">>;
|
|
45
47
|
type QueryJoinOn = {
|
|
@@ -254,8 +254,18 @@ function normalizeOrderBy(orderBy) {
|
|
|
254
254
|
}));
|
|
255
255
|
}
|
|
256
256
|
function buildOrderByClause(tableName, orderBy) {
|
|
257
|
-
const parts = normalizeOrderBy(orderBy).map(({ column, direction }) => {
|
|
258
|
-
|
|
257
|
+
const parts = normalizeOrderBy(orderBy).map(({ column, direction, nulls }) => {
|
|
258
|
+
if (nulls !== undefined && nulls !== "first" && nulls !== "last") {
|
|
259
|
+
throw new TypeError("Invalid null ordering: expected first or last.");
|
|
260
|
+
}
|
|
261
|
+
const reference = resolveQualifiedColumn(tableName, column);
|
|
262
|
+
const ordered = `${reference} ${normalizeDirection(direction)}`;
|
|
263
|
+
if (nulls === undefined)
|
|
264
|
+
return ordered;
|
|
265
|
+
if (currentSqlDialect().driver === "mysql") {
|
|
266
|
+
return `(${reference} IS NULL) ${nulls === "first" ? "DESC" : "ASC"}, ${ordered}`;
|
|
267
|
+
}
|
|
268
|
+
return `${ordered} NULLS ${nulls.toUpperCase()}`;
|
|
259
269
|
});
|
|
260
270
|
return parts.length > 0 ? ` ORDER BY ${parts.join(", ")}` : "";
|
|
261
271
|
}
|
|
@@ -278,8 +278,18 @@ function normalizeOrderBy(orderBy) {
|
|
|
278
278
|
}));
|
|
279
279
|
}
|
|
280
280
|
function buildOrderByClause(tableName, orderBy) {
|
|
281
|
-
const parts = normalizeOrderBy(orderBy).map(({ column, direction }) => {
|
|
282
|
-
|
|
281
|
+
const parts = normalizeOrderBy(orderBy).map(({ column, direction, nulls }) => {
|
|
282
|
+
if (nulls !== undefined && nulls !== "first" && nulls !== "last") {
|
|
283
|
+
throw new TypeError("Invalid null ordering: expected first or last.");
|
|
284
|
+
}
|
|
285
|
+
const reference = resolveQualifiedColumn(tableName, column);
|
|
286
|
+
const ordered = `${reference} ${normalizeDirection(direction)}`;
|
|
287
|
+
if (nulls === undefined)
|
|
288
|
+
return ordered;
|
|
289
|
+
if (currentSqlDialect().driver === "mysql") {
|
|
290
|
+
return `(${reference} IS NULL) ${nulls === "first" ? "DESC" : "ASC"}, ${ordered}`;
|
|
291
|
+
}
|
|
292
|
+
return `${ordered} NULLS ${nulls.toUpperCase()}`;
|
|
283
293
|
});
|
|
284
294
|
return parts.length > 0 ? ` ORDER BY ${parts.join(", ")}` : "";
|
|
285
295
|
}
|
package/dist/index.js
CHANGED
|
@@ -4438,8 +4438,18 @@ function normalizeOrderBy(orderBy) {
|
|
|
4438
4438
|
}));
|
|
4439
4439
|
}
|
|
4440
4440
|
function buildOrderByClause(tableName, orderBy) {
|
|
4441
|
-
const parts = normalizeOrderBy(orderBy).map(({ column, direction }) => {
|
|
4442
|
-
|
|
4441
|
+
const parts = normalizeOrderBy(orderBy).map(({ column, direction, nulls }) => {
|
|
4442
|
+
if (nulls !== undefined && nulls !== "first" && nulls !== "last") {
|
|
4443
|
+
throw new TypeError("Invalid null ordering: expected first or last.");
|
|
4444
|
+
}
|
|
4445
|
+
const reference = resolveQualifiedColumn(tableName, column);
|
|
4446
|
+
const ordered = `${reference} ${normalizeDirection(direction)}`;
|
|
4447
|
+
if (nulls === undefined)
|
|
4448
|
+
return ordered;
|
|
4449
|
+
if (currentSqlDialect().driver === "mysql") {
|
|
4450
|
+
return `(${reference} IS NULL) ${nulls === "first" ? "DESC" : "ASC"}, ${ordered}`;
|
|
4451
|
+
}
|
|
4452
|
+
return `${ordered} NULLS ${nulls.toUpperCase()}`;
|
|
4443
4453
|
});
|
|
4444
4454
|
return parts.length > 0 ? ` ORDER BY ${parts.join(", ")}` : "";
|
|
4445
4455
|
}
|