orange-orm 5.0.0-beta.9 → 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/dist/index.browser.mjs +5 -19
- package/dist/index.mjs +5 -19
- package/docs/changelog.md +3 -0
- package/package.json +1 -1
- package/src/getManyDto.js +4 -18
- package/src/table/relation/newOneLeg.js +1 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -10102,7 +10102,7 @@ function requireNewOneLeg () {
|
|
|
10102
10102
|
c.expand = relation.expand;
|
|
10103
10103
|
|
|
10104
10104
|
c.accept = function(visitor) {
|
|
10105
|
-
visitor.visitOne(c);
|
|
10105
|
+
return visitor.visitOne(c);
|
|
10106
10106
|
};
|
|
10107
10107
|
|
|
10108
10108
|
return c;
|
|
@@ -10994,8 +10994,6 @@ function requireGetManyDto$1 () {
|
|
|
10994
10994
|
}
|
|
10995
10995
|
|
|
10996
10996
|
let span = spanFromParent || strategyToSpan(table, strategy);
|
|
10997
|
-
if (!spanFromParent)
|
|
10998
|
-
assignAliases(span, table._dbName);
|
|
10999
10997
|
let alias = table._dbName;
|
|
11000
10998
|
|
|
11001
10999
|
const query = newQuery(context, table, filter, span, alias);
|
|
@@ -11003,13 +11001,6 @@ function requireGetManyDto$1 () {
|
|
|
11003
11001
|
return decode(context, strategy, span, await res[0], undefined, updateParent);
|
|
11004
11002
|
}
|
|
11005
11003
|
|
|
11006
|
-
function assignAliases(span, alias) {
|
|
11007
|
-
span._alias = alias;
|
|
11008
|
-
span.legs.forEach((leg) => {
|
|
11009
|
-
assignAliases(leg.span, alias + leg.name);
|
|
11010
|
-
});
|
|
11011
|
-
}
|
|
11012
|
-
|
|
11013
11004
|
function newCreateRow(span) {
|
|
11014
11005
|
let columnsMap = span.columns;
|
|
11015
11006
|
const columns = span.table._columns.filter(column => !columnsMap || columnsMap.get(column));
|
|
@@ -11095,8 +11086,6 @@ function requireGetManyDto$1 () {
|
|
|
11095
11086
|
const fkIds = new Array(rows.length);
|
|
11096
11087
|
const getIds = createGetIds();
|
|
11097
11088
|
const aggregateKeys = Object.keys(span.aggregates);
|
|
11098
|
-
const aliasPrefix = span._alias ? 's' + span._alias : null;
|
|
11099
|
-
const useAlias = aliasPrefix && rowsLength > 0 && Object.prototype.hasOwnProperty.call(rows[0], aliasPrefix + '0');
|
|
11100
11089
|
|
|
11101
11090
|
const outRows = new Array(rowsLength);
|
|
11102
11091
|
const createRow = newCreateRow(span);
|
|
@@ -11106,9 +11095,8 @@ function requireGetManyDto$1 () {
|
|
|
11106
11095
|
let outRow = createRow();
|
|
11107
11096
|
let pkWithNullCount = 0;
|
|
11108
11097
|
for (let j = 0; j < columnsLength; j++) {
|
|
11109
|
-
const key = useAlias ? (aliasPrefix + j) : keys[j];
|
|
11110
11098
|
if (j < primaryColumnsLength) {
|
|
11111
|
-
if (row[
|
|
11099
|
+
if (row[keys[j]] === null)
|
|
11112
11100
|
pkWithNullCount++;
|
|
11113
11101
|
if (pkWithNullCount === primaryColumnsLength) {
|
|
11114
11102
|
outRow = null;
|
|
@@ -11116,14 +11104,13 @@ function requireGetManyDto$1 () {
|
|
|
11116
11104
|
}
|
|
11117
11105
|
}
|
|
11118
11106
|
const column = columns[j];
|
|
11119
|
-
outRow[column.alias] = column.decode(context, row[
|
|
11107
|
+
outRow[column.alias] = column.decode(context, row[keys[j]]);
|
|
11120
11108
|
}
|
|
11121
11109
|
|
|
11122
11110
|
for (let j = 0; j < aggregateKeys.length; j++) {
|
|
11123
11111
|
const key = aggregateKeys[j];
|
|
11124
11112
|
const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
|
|
11125
|
-
|
|
11126
|
-
outRow[key] = parse(context, value);
|
|
11113
|
+
outRow[key] = parse(context, row[keys[j + columnsLength]]);
|
|
11127
11114
|
}
|
|
11128
11115
|
|
|
11129
11116
|
outRows[i] = outRow;
|
|
@@ -11137,8 +11124,7 @@ function requireGetManyDto$1 () {
|
|
|
11137
11124
|
span._rowsMap = rowsMap;
|
|
11138
11125
|
span._ids = fkIds;
|
|
11139
11126
|
|
|
11140
|
-
|
|
11141
|
-
keys.splice(0, columnsLength + aggregateKeys.length);
|
|
11127
|
+
keys.splice(0, columnsLength + aggregateKeys.length);
|
|
11142
11128
|
if (span.legs.toArray().length === 0)
|
|
11143
11129
|
return outRows;
|
|
11144
11130
|
|
package/dist/index.mjs
CHANGED
|
@@ -10103,7 +10103,7 @@ function requireNewOneLeg () {
|
|
|
10103
10103
|
c.expand = relation.expand;
|
|
10104
10104
|
|
|
10105
10105
|
c.accept = function(visitor) {
|
|
10106
|
-
visitor.visitOne(c);
|
|
10106
|
+
return visitor.visitOne(c);
|
|
10107
10107
|
};
|
|
10108
10108
|
|
|
10109
10109
|
return c;
|
|
@@ -10995,8 +10995,6 @@ function requireGetManyDto$1 () {
|
|
|
10995
10995
|
}
|
|
10996
10996
|
|
|
10997
10997
|
let span = spanFromParent || strategyToSpan(table, strategy);
|
|
10998
|
-
if (!spanFromParent)
|
|
10999
|
-
assignAliases(span, table._dbName);
|
|
11000
10998
|
let alias = table._dbName;
|
|
11001
10999
|
|
|
11002
11000
|
const query = newQuery(context, table, filter, span, alias);
|
|
@@ -11004,13 +11002,6 @@ function requireGetManyDto$1 () {
|
|
|
11004
11002
|
return decode(context, strategy, span, await res[0], undefined, updateParent);
|
|
11005
11003
|
}
|
|
11006
11004
|
|
|
11007
|
-
function assignAliases(span, alias) {
|
|
11008
|
-
span._alias = alias;
|
|
11009
|
-
span.legs.forEach((leg) => {
|
|
11010
|
-
assignAliases(leg.span, alias + leg.name);
|
|
11011
|
-
});
|
|
11012
|
-
}
|
|
11013
|
-
|
|
11014
11005
|
function newCreateRow(span) {
|
|
11015
11006
|
let columnsMap = span.columns;
|
|
11016
11007
|
const columns = span.table._columns.filter(column => !columnsMap || columnsMap.get(column));
|
|
@@ -11096,8 +11087,6 @@ function requireGetManyDto$1 () {
|
|
|
11096
11087
|
const fkIds = new Array(rows.length);
|
|
11097
11088
|
const getIds = createGetIds();
|
|
11098
11089
|
const aggregateKeys = Object.keys(span.aggregates);
|
|
11099
|
-
const aliasPrefix = span._alias ? 's' + span._alias : null;
|
|
11100
|
-
const useAlias = aliasPrefix && rowsLength > 0 && Object.prototype.hasOwnProperty.call(rows[0], aliasPrefix + '0');
|
|
11101
11090
|
|
|
11102
11091
|
const outRows = new Array(rowsLength);
|
|
11103
11092
|
const createRow = newCreateRow(span);
|
|
@@ -11107,9 +11096,8 @@ function requireGetManyDto$1 () {
|
|
|
11107
11096
|
let outRow = createRow();
|
|
11108
11097
|
let pkWithNullCount = 0;
|
|
11109
11098
|
for (let j = 0; j < columnsLength; j++) {
|
|
11110
|
-
const key = useAlias ? (aliasPrefix + j) : keys[j];
|
|
11111
11099
|
if (j < primaryColumnsLength) {
|
|
11112
|
-
if (row[
|
|
11100
|
+
if (row[keys[j]] === null)
|
|
11113
11101
|
pkWithNullCount++;
|
|
11114
11102
|
if (pkWithNullCount === primaryColumnsLength) {
|
|
11115
11103
|
outRow = null;
|
|
@@ -11117,14 +11105,13 @@ function requireGetManyDto$1 () {
|
|
|
11117
11105
|
}
|
|
11118
11106
|
}
|
|
11119
11107
|
const column = columns[j];
|
|
11120
|
-
outRow[column.alias] = column.decode(context, row[
|
|
11108
|
+
outRow[column.alias] = column.decode(context, row[keys[j]]);
|
|
11121
11109
|
}
|
|
11122
11110
|
|
|
11123
11111
|
for (let j = 0; j < aggregateKeys.length; j++) {
|
|
11124
11112
|
const key = aggregateKeys[j];
|
|
11125
11113
|
const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
|
|
11126
|
-
|
|
11127
|
-
outRow[key] = parse(context, value);
|
|
11114
|
+
outRow[key] = parse(context, row[keys[j + columnsLength]]);
|
|
11128
11115
|
}
|
|
11129
11116
|
|
|
11130
11117
|
outRows[i] = outRow;
|
|
@@ -11138,8 +11125,7 @@ function requireGetManyDto$1 () {
|
|
|
11138
11125
|
span._rowsMap = rowsMap;
|
|
11139
11126
|
span._ids = fkIds;
|
|
11140
11127
|
|
|
11141
|
-
|
|
11142
|
-
keys.splice(0, columnsLength + aggregateKeys.length);
|
|
11128
|
+
keys.splice(0, columnsLength + aggregateKeys.length);
|
|
11143
11129
|
if (span.legs.toArray().length === 0)
|
|
11144
11130
|
return outRows;
|
|
11145
11131
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
__5.0.0__
|
|
3
3
|
Breaking: `getAll` was removed. Use `getMany` instead (now with the same signature as the removed `getAll`).
|
|
4
|
+
Breaking: `getOne` no longer accepts a filter as the first argument. Move the filter to the strategy `where` clause (same pattern as `getMany`).
|
|
4
5
|
ExpressJS: Before/after hooks to facilitate row-level security [#135](https://github.com/alfateam/orange-orm/issues/135)
|
|
5
6
|
SQLite: Support for invoking user-defined functions [#145](https://github.com/alfateam/orange-orm/issues/145)
|
|
6
7
|
Support for enums [#100](https://github.com/alfateam/orange-orm/issues/100)
|
|
8
|
+
__4.9.2__
|
|
9
|
+
Bugfix: getManyDto/getMany with parallel hasOne + discriminator could return null columns. [#147](https://github.com/alfateam/orange-orm/issues/147)
|
|
7
10
|
__4.9.1__
|
|
8
11
|
Fix: Avoid double-quoting aliases in discriminator join SQL [#144](https://github.com/alfateam/orange-orm/issues/144)
|
|
9
12
|
__4.9.0__
|
package/package.json
CHANGED
package/src/getManyDto.js
CHANGED
|
@@ -13,8 +13,6 @@ async function getManyDto(context, table, filter, strategy, spanFromParent, upda
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
let span = spanFromParent || strategyToSpan(table, strategy);
|
|
16
|
-
if (!spanFromParent)
|
|
17
|
-
assignAliases(span, table._dbName);
|
|
18
16
|
let alias = table._dbName;
|
|
19
17
|
|
|
20
18
|
const query = newQuery(context, table, filter, span, alias);
|
|
@@ -22,13 +20,6 @@ async function getManyDto(context, table, filter, strategy, spanFromParent, upda
|
|
|
22
20
|
return decode(context, strategy, span, await res[0], undefined, updateParent);
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
function assignAliases(span, alias) {
|
|
26
|
-
span._alias = alias;
|
|
27
|
-
span.legs.forEach((leg) => {
|
|
28
|
-
assignAliases(leg.span, alias + leg.name);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
23
|
function newCreateRow(span) {
|
|
33
24
|
let columnsMap = span.columns;
|
|
34
25
|
const columns = span.table._columns.filter(column => !columnsMap || columnsMap.get(column));
|
|
@@ -114,8 +105,6 @@ async function decode(context, strategy, span, rows, keys = rows.length > 0 ? Ob
|
|
|
114
105
|
const fkIds = new Array(rows.length);
|
|
115
106
|
const getIds = createGetIds();
|
|
116
107
|
const aggregateKeys = Object.keys(span.aggregates);
|
|
117
|
-
const aliasPrefix = span._alias ? 's' + span._alias : null;
|
|
118
|
-
const useAlias = aliasPrefix && rowsLength > 0 && Object.prototype.hasOwnProperty.call(rows[0], aliasPrefix + '0');
|
|
119
108
|
|
|
120
109
|
const outRows = new Array(rowsLength);
|
|
121
110
|
const createRow = newCreateRow(span);
|
|
@@ -125,9 +114,8 @@ async function decode(context, strategy, span, rows, keys = rows.length > 0 ? Ob
|
|
|
125
114
|
let outRow = createRow();
|
|
126
115
|
let pkWithNullCount = 0;
|
|
127
116
|
for (let j = 0; j < columnsLength; j++) {
|
|
128
|
-
const key = useAlias ? (aliasPrefix + j) : keys[j];
|
|
129
117
|
if (j < primaryColumnsLength) {
|
|
130
|
-
if (row[
|
|
118
|
+
if (row[keys[j]] === null)
|
|
131
119
|
pkWithNullCount++;
|
|
132
120
|
if (pkWithNullCount === primaryColumnsLength) {
|
|
133
121
|
outRow = null;
|
|
@@ -135,14 +123,13 @@ async function decode(context, strategy, span, rows, keys = rows.length > 0 ? Ob
|
|
|
135
123
|
}
|
|
136
124
|
}
|
|
137
125
|
const column = columns[j];
|
|
138
|
-
outRow[column.alias] = column.decode(context, row[
|
|
126
|
+
outRow[column.alias] = column.decode(context, row[keys[j]]);
|
|
139
127
|
}
|
|
140
128
|
|
|
141
129
|
for (let j = 0; j < aggregateKeys.length; j++) {
|
|
142
130
|
const key = aggregateKeys[j];
|
|
143
131
|
const parse = span.aggregates[key].column?.decode || ((context, arg) => Number.parseFloat(arg));
|
|
144
|
-
|
|
145
|
-
outRow[key] = parse(context, value);
|
|
132
|
+
outRow[key] = parse(context, row[keys[j + columnsLength]]);
|
|
146
133
|
}
|
|
147
134
|
|
|
148
135
|
outRows[i] = outRow;
|
|
@@ -156,8 +143,7 @@ async function decode(context, strategy, span, rows, keys = rows.length > 0 ? Ob
|
|
|
156
143
|
span._rowsMap = rowsMap;
|
|
157
144
|
span._ids = fkIds;
|
|
158
145
|
|
|
159
|
-
|
|
160
|
-
keys.splice(0, columnsLength + aggregateKeys.length);
|
|
146
|
+
keys.splice(0, columnsLength + aggregateKeys.length);
|
|
161
147
|
if (span.legs.toArray().length === 0)
|
|
162
148
|
return outRows;
|
|
163
149
|
|