Skip to content
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

Hardcoded table column names in the ClosureTable model #238

Closed
franzose opened this issue Oct 5, 2020 · 0 comments
Closed

Hardcoded table column names in the ClosureTable model #238

franzose opened this issue Oct 5, 2020 · 0 comments
Labels

Comments

@franzose
Copy link
Owner

franzose commented Oct 5, 2020

Originally reported by @devig in #234.

ClosureTable::selectRowsToInsert() uses hardcoded table column names:

 $select = "
     SELECT tbl.{$ancestor} AS ancestor, ? AS descendant, tbl.{$depth}+1 AS depth
     FROM {$table} AS tbl
     WHERE tbl.{$descendant} = ?
     UNION ALL
     SELECT ? AS ancestor, ? AS descendant, 0 AS depth
 ";

This will break SQL queries in case of non-standard column names are used. The above should be changed to the below:

$select = "
    SELECT tbl.{$ancestor} AS {$ancestor}, ? AS {$descendant}, tbl.{$depth}+1 AS {$depth}
    FROM {$table} AS tbl
    WHERE tbl.{$descendant} = ?
    UNION ALL
    SELECT ? AS {$ancestor}, ? AS {$descendant}, 0 AS {$depth}
";
@franzose franzose added the bug label Oct 5, 2020
franzose added a commit that referenced this issue Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant