You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When querying a child entity's relation where tuples that satisfy said relation exist in the database, an array containing said tuples' data mapped into regular objects should be returned instead of the empty array.
Actual Behavior
In the case where the specification for two separate child entities inherits a set of fields off a common entity and each of the two child entities both define a field f, corresponding to a @OneToMany relation r1 for the first entity and another @OneToMany relation r2 for the second entity, the following behaviour is observable:
Querying data for r1 (the first relation of the first entity) in an instance of the first child entity will correctly retrieve the records and populate an array with them;
Querying data for r2 (the second relation of the second entity) in an instance of the second child entity will always result inn an empty array;
Performing a reverse lookup on the entity mentioned by the relation r2 will properly yield the content that should have been in the @OneToMany relation for the instance of the second entity.
Steps to Reproduce
This is a minimum reproducible example in the necessary detail as to help discussion and provide context for the issue at hand:
Assume that data is present to satisfy relationProperty in one instance of FirstChildEntity and one of SecondChildEntity:
Awaiting on instance1.relationProperty will always retrieve the existing correct data from the database;
Awaiting on instance2.relationProperty will always result in an empty array, regardless of data for said relation being present in the database.
My Environment
Dependency
Version
Operating System
macOS Big Sur Version 11.3.1 (20E241)
Node.js version
v15.14.0
Typescript version
v4.2.3
TypeORM version
v0.2.24
Additional Context
Important: In the example above, the relevant relation was specified through the class property relationProperty for both child entities, if we change the property name for just one of the entities then the relation data is correctly retrieved from the database.
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, and I know how to start.
Yes, I have the time, but I don't know how to start. I would need guidance.
No, I don't have the time, although I believe I could do it if I had the time...
No, I don't have the time and I wouldn't even know how to start.
The text was updated successfully, but these errors were encountered:
Update: upon consulting the ORM logs, I noticed that when awaiting on relationProperty for SecondChildEntity, the resulting PSQL query will FROM the wrong table, i.e. the one for FirstMentionedEntity.
In essence, the query for the second instance's relationProperty retrieval will look like:
SELECT (...) FROM "first_child_entity" "relationProperty" WHERE "relationProperty"."childEntityId" IN ($1)
Which mentions the table name for FirstChildEntity.
@pleerock, I believe that eager relations also show this behaviour, this was actually one of the things I tried to see if I could fix the problem, to no avail.
Issue Description
Expected Behavior
When querying a child entity's relation where tuples that satisfy said relation exist in the database, an array containing said tuples' data mapped into regular objects should be returned instead of the empty array.
Actual Behavior
In the case where the specification for two separate child entities inherits a set of fields off a common entity and each of the two child entities both define a field
f
, corresponding to a@OneToMany
relationr1
for the first entity and another@OneToMany
relationr2
for the second entity, the following behaviour is observable:r1
(the first relation of the first entity) in an instance of the first child entity will correctly retrieve the records and populate an array with them;r2
(the second relation of the second entity) in an instance of the second child entity will always result inn an empty array;r2
will properly yield the content that should have been in the@OneToMany
relation for the instance of the second entity.Steps to Reproduce
This is a minimum reproducible example in the necessary detail as to help discussion and provide context for the issue at hand:
FirstChildEntity
:SecondChildEntity
:FirstMentionedEntity
:SecondMentionedEntity
to have a similar shape/definition:relationProperty
in one instance ofFirstChildEntity
and one ofSecondChildEntity
:instance1.relationProperty
will always retrieve the existing correct data from the database;instance2.relationProperty
will always result in an empty array, regardless of data for said relation being present in the database.My Environment
Additional Context
Important: In the example above, the relevant relation was specified through the class property
relationProperty
for both child entities, if we change the property name for just one of the entities then the relation data is correctly retrieved from the database.Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: