question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom column names for closure tree table

See original GitHub issue

Custom column names for closure tree table

The Problem

Currently @Tree("closure-table") creates table with fixed name and columns entity_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 options closureTableName, ancestorColumnName, descendantColumnName

Relevant Database Driver(s)

  • [ +] postgres

Are you willing to resolve this issue by submitting a Pull Request?

  • [+ ] Yes, I have the time, but I don’t know how to start. I would need guidance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
alexey2baranovcommented, Nov 28, 2020

@nebkat I did first step. This is insert sql

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]
0reactions
pleerockcommented, Jan 12, 2021

closed by #7120

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tree Entities - typeorm - GitBook
You can specify the closure table name and/or closure table column names by setting optional parameter options into @Tree("closure-table", options) .
Read more >
Unique name constraint accross siblings in a closure tree
With this schema I'm using a unique constraint on the spaces table to verify that no sibling has the same name. The downside...
Read more >
Hierarchical Data in SQL: The Ultimate Guide
What is Hierarchical Data? Adjacency List; Nested Set; Flat Table; Bridge Table or Closure Table; Lineage Column or Path Enumeration; Summary of Methods;...
Read more >
Hierarchical data using closure table, how to ensure that a ...
I store hierarchical data in a Node-table, combined with a closure table (NodeClosure). Each node has a column "name" that should be unique ......
Read more >
Moving Subtrees in Closure Table Hierarchies
In Closure Table, we store every path in a tree, not only direct parent-child references, but also grandparent-grandchild, and every other path, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found