Skip to content

Commit

Permalink
Bug76 (#77)
Browse files Browse the repository at this point in the history
* comment in tests for offset

* Fix problem with relation filter - closes #76

---------

Co-authored-by: Lars-Erik Roald <[email protected]>
  • Loading branch information
lroal and Lars-Erik Roald authored Mar 29, 2024
1 parent 2dbb60d commit 4804c19
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/table/relatedTable/where.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ let newRelatedTable = _newRelatedTable;
const negotiateRawSqlFilter = require('../column/negotiateRawSqlFilter');
let tryGetSessionContext = require('../tryGetSessionContext');

function newWhere(relations, _depth) {
function newWhere(_relations, _depth) {

function where(fn) {
const includeMany = tryGetSessionContext()?.engine === 'mssql';
let { relations, alias } = extract(includeMany);
let { relations, alias } = extract(includeMany, _relations);
const table = relations[relations.length - 1].childTable;
if (!relations[0].isMany || includeMany)
table._rootAlias = alias;
Expand All @@ -17,27 +17,27 @@ function newWhere(relations, _depth) {
delete table._rootAlias;
return anyFilter;
}
catch(e) {
catch (e) {
delete table._rootAlias;
throw e;
}
}
return where;

function extract(includeMany) {
function extract(includeMany, relations) {
let alias = relations[0].toLeg().table._dbName;
let result = [];
for (let i = 0; i < relations.length; i++) {
if (relations[i].isMany && !includeMany) {
result = [];
alias = relations[0].toLeg().table._dbName;
result = [relations[i]];
alias = relations[i].toLeg().table._dbName;
}
else {
result.push(relations[i]);
alias += relations[i].toLeg().name;
}
}
return { relations, alias};
return { relations: result, alias };
}

}
Expand Down

0 comments on commit 4804c19

Please sign in to comment.