Closed donecarlo closed 3 years ago
The line referenced makes it so a new loader is created IF the target key and primary key are not the same, so the loader will be created in your scenario. Removing the if should not change anything in your scenario. The default handling is just to use the primary key loader.
Not sure why the schema is being ignored.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Scenario: Queries wit associations using
belongsTo
fails as the actual SQL query does not include the schema when referencing a specific table -- e.gSELECT * FROM [TABLE_NAME]
instead ofSELECT * FROM [schema_name].[TABLE_NAME]
which causes the query to fail.Expected: It is expected that the schema name would still be included when executing the SQL query
Additional notes: After some checking, it seems that the root cause is within the following line: https://github.com/mickhansen/dataloader-sequelize/blob/9a8db90630e0ac632f2f42f107f13c43fd308fe1/src/index.js#L426
In my schemas, the targetKey and the primaryKeyAttribute are not the same, hence the loader is not set up properly. Should we have a default handling for this? For my testing, I just removed the
if
condition and it seemed to work fine, though I'm not sure if this should be the actual fix