Wrong table/field names used in query construction
See original GitHub issueWhile working on pull request #408, I’ve noticed that resolving the backend name of fields and tables is either brittle (lots and lots of duplicate code building the name from multiple object attributes) or already broken (Table.sqlsafe
returns the correct backend name only when Table._rname
is set or the table is not aliased, otherwise it’ll return the alias which may either not exist in the database or refer to a completely different table).
I’ve introduced a new property Table.real_name
in PR #408 that always returns the correct backend name of the table. However, fixing all instances of this problem is beyond the scope of that pull request so I’m reporting this here for later. Field
doesn’t have any property returning the correct full backend name/internal colname either because the Field.sqlsafe
property relies on broken Table.sqlsafe
. Whether to fix the existing properties or introduce new ones is open for debate.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
I’ve barely started refactoring and I’m already seeing
Table._tablename
used in places where it definitely doesn’t belong. When I open the pull request for this, get ready for a flood of FIXMEs in places which I can’t test myself.The pull request is now ready to be merged so I’m closing this.