New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom column names for closure tree table #7068
Comments
Best place to start would be typeorm/src/decorator/tree/Tree.ts Line 11 in c4a36da
options parameter here that would allow those extra parameters to be defined (see other decorators such as @Column for examples). Make sure in this case to only allow options to be provided if the tree type is "closure" .
From there simply add Alternative would be to make a copy of this:
to here:
But your proposed solution is better. |
Need help ! You can see forked code |
My bad, you will have to store typeorm/src/metadata/EntityMetadata.ts Line 505 in c4a36da
|
@nebkat OK, nice may i use new syntax ? |
Unfortunately we're stuck on TypeScript 3.6 which doesn't support that syntax, but I'm trying to get that changed here #6810 (comment) |
@nebkat |
You could allow a |
@nebkat callback function sounds good. I'm going this way |
@nebkat CREATE TABLE "category_xyz_closure_closure" ("ancestor_xyz_id" integer NOT NULL, "descendant_xyz_id" integer NOT NULL, CONSTRAINT "PK_2b72e01be985428bb18e3157522" PRIMARY KEY ("ancestor_xyz_id", "descendant_xyz_id"))
query: INSERT INTO "category_xyz_closure_closure"("ancestor_xyz_id", "descendant_xyz_id") VALUES ($1, $2) -- PARAMETERS: [1,1] |
looks like tree repository ignores some metadata. i got this sql when try to save entity. query failed: INSERT INTO "category_xyz_closure_closure" ("ancestor_xyz_id", "descendant_xyz_id") SELECT "ancestor_xyz_id", $1 FROM "category_xyz_closure_closure" WHERE "id_descendant" = $2 -- PARAMETERS: [2,1]
|
Check |
@nebkat query: INSERT INTO "category"("name", "parentCategoryId") VALUES ($1, $2) RETURNING "id" -- PARAMETERS: ["a11",1]
query: INSERT INTO "category_xyz_closure_closure"("ancestor_xyz_id", "descendant_xyz_id") VALUES ($1, $2) -- PARAMETERS: [2,2]
query: INSERT INTO "category_xyz_closure_closure" ("ancestor_xyz_id", "descendant_xyz_id") SELECT "ancestor_xyz_id", $1 FROM "category_xyz_closure_closure" WHERE "descendant_xyz_id" = $2 -- PARAMETERS: [2,1] |
@nebkat |
It shouldn't, but make sure you test everything. You can add new tests in |
do you think it is ok if I copy-paste this test and just extend entity definition? |
@nebkat Or maybe I just need to call every method without expect() checks, because expect checks were done in original test? |
unable to run docker-compose because of this error
may I skip oracle test before pull request? |
@nebkat how is a going? Why do you hold PR? |
closed by #7120 |
Custom column names for closure tree table
The Problem
Currently
@Tree("closure-table")
creates table with fixed name and columnsentity_closure
,id_ancestor
,id_descendant
. There is no possibility to customize this naming. This not works with legacy database schema.The Solution
Append
@Tree("closure-table")
with additional optionsclosureTableName
,ancestorColumnName
,descendantColumnName
Relevant Database Driver(s)
postgres
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: