fix: fix working with tables with quotes in the names for postgres and cockroachdb#10993
fix: fix working with tables with quotes in the names for postgres and cockroachdb#10993gioboa merged 12 commits intotypeorm:masterfrom
Conversation
…ypeorm#10991) Fix working with tables with quotes in the names for PostgreSQL Closes: typeorm#10991
|
It looks like the failed tests (oracle and sqlite better-sqlite3 sqljs) are not related to the PR. These failures also appeared in other recent PRs. |
PR Code Suggestions ✨Latest suggestions up to 55130c5
Previous suggestionsSuggestions up to commit d9a8e8b
Suggestions up to commit d612732
Suggestions up to commit 747696a
Suggestions up to commit be73001
Suggestions up to commit d443ee3
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gioboa
left a comment
There was a problem hiding this comment.
Let's move on with this PR even though tests are in the old folders.
commit: |
|
Would be nice if the same fix would be done for |
gioboa
left a comment
There was a problem hiding this comment.
Would be nice if the same fix would be done for
CockroachQueryRunneras well :)
Done
PR Code Suggestions ✨No code suggestions found for the PR. |
…d cockroachdb (typeorm#10993) ---- Co-authored-by: gioboa <giorgiob.boa@gmail.com>
…d cockroachdb (typeorm#10993) ---- Co-authored-by: gioboa <giorgiob.boa@gmail.com>
…d cockroachdb (typeorm#10993) ---- Co-authored-by: gioboa <giorgiob.boa@gmail.com>
|
Good fix. Using quote_ident() instead of manually doing '"' || table_name || '"' is the right move — it avoids breaking when table/schema names already contain quotes, and it’s the safer way to build identifiers in Postgres. The example case (“This is the "Table Name"”) makes sense, and the change should stop getTables() from blowing up on weird legacy DBs. Also glad this got extended to CockroachQueryRunner too, since it has the same quoting problem in practice. A couple things I’d double-check:
|
…d cockroachdb (typeorm#10993) ---- Co-authored-by: gioboa <giorgiob.boa@gmail.com>
…(#10991)
Fix working with tables with quotes in the names for PostgreSQL
Closes: #10991
Description of change
There were a few changes in PostgresQueryRunner with changing quoting table_schema and table_name from '"' || "table_schema" || '"' to quote_ident("table_schema"), which allows to deal with table names containing quotes.
It's important because tables with these unusual names can exist, while sometimes it's impossible just rename those tables as this is an arbitrary database, the structure of which needs to be obtained.
Case: PostgreSQL DB containg table with the name
This is the "Table Name".Current behaviour: connection.createQueryRunner().getTables() throws an error.
Next behaviour: connection.createQueryRunner().getTables() works
Fixes #10991
Pull-Request Checklist
masterbranchnpm run formatto apply prettier formattingnpm run testpasses with this changeFixes #0000