Closed ucin closed 2 years ago
Thanks for reporting this!
Can you check v4.5.0 to see if this resolves your problem?
Thank you for your support @wwwouter. I still see the column is not translated according to definition
Postgres error message
column recordSector.subKey does not exist
Here is my query
.innerJoinTableOnFunction("recordSector", RecordTable, (join) => {
join.andOnVal("group", "=", "MASTER_DATA")
.andOnVal("key", "=", "SECTOR")
.andOn("subKey", "=", "sector");
})
And the table definition is still the same.
Make sure is already updated.
Hmmm, that's too bad. If I add your RecordTable
and change the "should inner join with function with other table using correct column name" test to this, it is successful:
it.only("should inner join with function with other table using correct column name", (done) => {
const typedKnex = new TypedKnex(knex({ client: "postgresql" }));
const query = typedKnex.query(UserSetting).innerJoinTableOnFunction("sector", RecordTable, (join) => {
join.andOnVal("group", "=", "MASTER_DATA").andOnVal("key", "=", "SECTOR").andOn("subKey", "=", "id");
});
const queryString = query.toQuery();
assert.equal(queryString, `select * from "userSettings" inner join "records" as "sector" on "sector"."group" = 'MASTER_DATA' and "sector"."key" = 'SECTOR' and "userSettings"."id" = "sector"."sub_key"`);
done();
});
Maybe there is another part of the query that is failing.
Could you maybe fork this repo, update "should inner join with function with other table using correct column name" with your entire query to see what is happening?
To see the test result, run npm run mocha:unit
Hi @wwwouter,
I follow your instruction and my code work without any modification! It turn out my local typed-knex
is not being updated even the version is already the latest. I'm not sure if the issue is with lerna
or npm
.
Thanks again for your assistance! I really enjoy working with typed-knex
!
Something went wrong when publishing. v4.5.1 should work
Issue type:
[X ] Question [ X] Bug report [ ] Feature request [ ] Documentation issue
Database system/driver:
[X ] Postgres [ ] MSSQL [ ] MySQL [ ] MariaDB [ ] SQLite3 [ ] Oracle [ ] Amazon Redshift
typed-knex version:
[ X]
latest
[ ]@next
[ ]0.x.x
(or put your version here)Knex.js version: 0.95.12
Query:
Table Definition:
The
subKey
column is suppose to translate into"sector"."sub_key"
Now is generating something like this
Postgres error hint: