Comments (3)
I see, that's unfortunate but you still helped me a lot, thank you.
Patching typeorm with npx patch-package works for now as a temporarily solution
Maybe it's possible to make relationLoadStrategy configurable for now but actually should be solved on typeorms end
Leaving the patch here:
diff --git a/node_modules/typeorm/browser/query-builder/SelectQueryBuilder.js b/node_modules/typeorm/browser/query-builder/SelectQueryBuilder.js
index c78a50f..c4e90e6 100644
--- a/node_modules/typeorm/browser/query-builder/SelectQueryBuilder.js
+++ b/node_modules/typeorm/browser/query-builder/SelectQueryBuilder.js
@@ -2052,7 +2052,12 @@ export class SelectQueryBuilder extends QueryBuilder {
const queryStrategyRelationIdLoader = new QueryStrategyRelationIdLoader(this.connection, queryRunner);
await Promise.all(this.relationMetadatas.map(async (relation) => {
const relationTarget = relation.inverseEntityMetadata.target;
- const relationAlias = relation.inverseEntityMetadata.targetName;
+ const relationAlias = this.connection.namingStrategy.joinTableName(
+ relation.propertyName,
+ relation.inverseEntityMetadata.name,
+ relation.propertyName,
+ relation.inverseSidePropertyPath,
+ );
const select = Array.isArray(this.findOptions.select)
? OrmUtils.propertyPathsToTruthyObject(this.findOptions.select)
: this.findOptions.select;
diff --git a/node_modules/typeorm/query-builder/SelectQueryBuilder.js b/node_modules/typeorm/query-builder/SelectQueryBuilder.js
index 8eda00e..fdf7e7c 100644
--- a/node_modules/typeorm/query-builder/SelectQueryBuilder.js
+++ b/node_modules/typeorm/query-builder/SelectQueryBuilder.js
@@ -2055,7 +2055,11 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder {
const queryStrategyRelationIdLoader = new RelationIdLoader_2.RelationIdLoader(this.connection, queryRunner);
await Promise.all(this.relationMetadatas.map(async (relation) => {
const relationTarget = relation.inverseEntityMetadata.target;
- const relationAlias = relation.inverseEntityMetadata.targetName;
+ const relationAlias = this.connection.namingStrategy.joinTableName(
+ relation.propertyName,
+ relation.propertyName,
+ relation.inverseSidePropertyPath,
+ )
const select = Array.isArray(this.findOptions.select)
? OrmUtils_1.OrmUtils.propertyPathsToTruthyObject(this.findOptions.select)
: this.findOptions.select;
File: typeorm+0.3.20.patch
from vendure.
Thanks for the report. I'm looking into this, and it appears it may well be a bug inside TypeORM. I have defined the "poster" custom field and when I attempt to load a product detail in the Admin UI, I get the reported error. Debugging through all the generated SQL queries generated by this request, I get to the specific one that fails:
SELECT `Asset`.`createdAt` AS `Asset_createdAt`,
`Asset`.`updatedAt` AS `Asset_updatedAt`,
`Asset`.`name` AS `Asset_name`,
`Asset`.`type` AS `Asset_type`,
`Asset`.`mimeType` AS `Asset_mimeType`,
`Asset`.`width` AS `Asset_width`,
`Asset`.`height` AS `Asset_height`,
`Asset`.`fileSize` AS `Asset_fileSize`,
`Asset`.`source` AS `Asset_source`,
`Asset`.`preview` AS `Asset_preview`,
`Asset`.`focalPoint` AS `Asset_focalPoint`,
`Asset`.`id` AS `Asset_id`,
`Asset`.`customFieldsPosterid` AS `Asset_customFieldsPosterid`,
`Asset`.`customFields__fix_relational_custom_fields__` AS `Asset_customFields__fix_relational_custom_fields__`,
`Asset`.`createdAt` AS `Asset_createdAt`,
`Asset`.`updatedAt` AS `Asset_updatedAt`,
`Asset`.`name` AS `Asset_name`,
`Asset`.`type` AS `Asset_type`,
`Asset`.`mimeType` AS `Asset_mimeType`,
`Asset`.`width` AS `Asset_width`,
`Asset`.`height` AS `Asset_height`,
`Asset`.`fileSize` AS `Asset_fileSize`,
`Asset`.`source` AS `Asset_source`,
`Asset`.`preview` AS `Asset_preview`,
`Asset`.`focalPoint` AS `Asset_focalPoint`,
`Asset`.`id` AS `Asset_id`,
`Asset`.`customFieldsPosterid` AS `Asset_customFieldsPosterid`,
`Asset`.`customFields__fix_relational_custom_fields__` AS `Asset_customFields__fix_relational_custom_fields__`
FROM `asset` `Asset`
INNER JOIN `asset` `Asset` ON `Asset`.`customFieldsPosterid` = `Asset`.`id`
WHERE `Asset`.`id` IN (?)
with the following stack trace:
I'm investigating whether there is any kind of work-around we can perform on our side.
from vendure.
Given the following custom field config:
customFields: {
Asset: [
{
type: 'relation',
entity: Asset,
name: 'self',
nullable: true,
},
],
},
here's a minimal query to the Admin or Shop API which reproduces the error:
{
product(id: 1) {
featuredAsset {
customFields {
self {
id
}
}
}
}
}
Interestingly, running the same query against collection
will not produce the error. This may be due to the fact that there is currently a work-around which causes the collection query to opt-out of the relationLoadStrategy: 'query'
strategy of TypeORM.
This is supported by the fact that if I comment out this line, the error will not appear.
So we can narrow this down to the internal implementation in TypeORM of the "query" relationLoadStrategy - something that has proven a source of bugs in the past. Which is very unfortunate because it brings huge performance improvements overall.
On further investigation I believe we are running into exactly this bug:
from vendure.
Related Issues (20)
- Admin UI: Metrics widget doesn't show numbers on hover: `Invalid language tag: en-` HOT 1
- Listing options do not show up when selecting facets, and scrolls multiply when this functionality is found HOT 2
- EntityHydrator does not shorten jointable alias names anymore
- RFC: Migration of the Admin UI from Clarity to Tailwind
- PostgreSQL Databases with SSL enforced not supported by create and populate
- Returning a new config object from a plugin's configuration function breaks
- Search by collection returns `null` for `productVariantAsset` even though set in admin dashboard HOT 7
- support to change trackInventory for channel
- Different cookies (shop & admin) don't work anymore with Vendure 2.2.6 HOT 3
- Multi-Vendor setup extremely slow on loading HOT 1
- Cancel item does not affect the Payment Settled amount
- Implement relational structured data for products
- Include Address based tax zone strategy in core
- New Product Error at 2.2.6
- Add edit link to product variant management page
- Adding product variant with no price gives no error
- Add new product with variant price lower than 0.01 HOT 1
- Replace faker with a maintained version of the package HOT 1
- Add description and page tabs to custom route component
- Move Mollie back to Payments API instead of Orders API HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vendure.