mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Apply feedbacks
This commit is contained in:
parent
7c6206f1a2
commit
865664315f
@ -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.
|
||||
:::
|
||||
|
||||
|
||||
@ -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
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user