Apply feedbacks

This commit is contained in:
Alexandre Bodin 2019-04-02 09:50:19 +02:00
parent 7c6206f1a2
commit 865664315f
3 changed files with 21 additions and 21 deletions

View File

@ -74,9 +74,6 @@ To achieve this, there are two options:
:::
::: warning
If you are using SQL, the deep filtering will not working if you have the same model twice in your filters
e.g: `GET /posts?tags.labels.posts.title=tag 1`
This feature isn't available for the `upload` plugin.
:::

View File

@ -48,7 +48,9 @@ const buildJoinsAndFilter = (qb, model, whereClauses) => {
aliasMap[name] = 1;
}
return `${name}_${aliasMap[name]++}`;
const alias = `${name}_${aliasMap[name]}`;
aliasMap[name] += 1;
return alias;
};
/**
@ -94,23 +96,24 @@ const buildJoinsAndFilter = (qb, model, whereClauses) => {
}`,
`${destinationInfo.alias}.${destinationInfo.model.primaryKey}`
);
} else {
const externalKey =
assoc.type === 'collection'
? `${destinationInfo.alias}.${assoc.via}`
: `${destinationInfo.alias}.${destinationInfo.model.primaryKey}`;
const internalKey =
assoc.type === 'collection'
? `${originInfo.alias}.${originInfo.model.primaryKey}`
: `${originInfo.alias}.${assoc.alias}`;
qb.leftJoin(
`${destinationInfo.model.collectionName} AS ${destinationInfo.alias}`,
externalKey,
internalKey
);
return;
}
const externalKey =
assoc.type === 'collection'
? `${destinationInfo.alias}.${assoc.via}`
: `${destinationInfo.alias}.${destinationInfo.model.primaryKey}`;
const internalKey =
assoc.type === 'collection'
? `${originInfo.alias}.${originInfo.model.primaryKey}`
: `${originInfo.alias}.${assoc.alias}`;
qb.leftJoin(
`${destinationInfo.model.collectionName} AS ${destinationInfo.alias}`,
externalKey,
internalKey
);
};
/**

View File

@ -26,7 +26,7 @@ const test = async () => {
};
const main = async () => {
const database = process.argv.length > 2 ? process.argv.slice(2).join(' ') : databases.postgres;
const database = process.argv.length > 2 ? process.argv.slice(2).join(' ') : databases.sqlite;
try {
await cleanTestApp(appName);