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.

Wrong table/field names used in query construction

See original GitHub issue

While 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:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nextghostcommented, Dec 17, 2016

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.

0reactions
nextghostcommented, Jan 23, 2017

The pull request is now ready to be merged so I’m closing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automate Table Field Names In Query - SQLServerCentral
Basically, when you look at the table determines what column names you see. There's no particularly good reason to EVER use a table...
Read more >
1. Query Construction - Access Data Analysis Cookbook [Book]
Chapter 1. Query Construction Select queries are an essential part of any database system. These queries, which passively gather data (without changing the ......
Read more >
MySQL query to get column names? - Stack Overflow
The best way is to use the INFORMATION_SCHEMA metadata virtual database. Specifically the INFORMATION_SCHEMA.COLUMNS table.
Read more >
query building error, need quotes around table field's name #57
Hello, I am using this package with Laravel 5 and Oracle 11. ... query building error, need quotes around table field's name #57....
Read more >
postgresql - List all columns for a specified table
I know the data is inside that database, so I want to do a little bit of reverse-engineering. Given a table name, is...
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