-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): Fix "contains" list filter operator for postgres
- Loading branch information
1 parent
50fbae6
commit c3898a6
Showing
4 changed files
with
46 additions
and
34 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
packages/core/src/service/helpers/list-query-builder/get-column-metadata.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Type } from '@vendure/common/lib/shared-types'; | ||
import { Connection } from 'typeorm'; | ||
import { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata'; | ||
|
||
export function getColumnMetadata<T>(connection: Connection, entity: Type<T>) { | ||
const metadata = connection.getMetadata(entity); | ||
const columns = metadata.columns; | ||
let translationColumns: ColumnMetadata[] = []; | ||
const relations = metadata.relations; | ||
|
||
const translationRelation = relations.find(r => r.propertyName === 'translations'); | ||
if (translationRelation) { | ||
const translationMetadata = connection.getMetadata(translationRelation.type); | ||
translationColumns = columns.concat(translationMetadata.columns.filter(c => !c.relationMetadata)); | ||
} | ||
const alias = metadata.name.toLowerCase(); | ||
return { columns, translationColumns, alias }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters