🐛 Oracle: fix comment retrieval on table with reserved keyword name#6765
🐛 Oracle: fix comment retrieval on table with reserved keyword name#6765homersimpsons wants to merge 1 commit intodoctrine:3.9.xfrom
Conversation
e047825 to
e0e54cf
Compare
|
UPD: no, this looks safer than I thought. I'll leave a comment inline. |
e0e54cf to
d2452fa
Compare
|
Please target 3.9.x though. |
74e6478 to
e6f5433
Compare
d0fb9ec to
3347eeb
Compare
src/Schema/SqliteSchemaManager.php
Outdated
| SQL | ||
| , | ||
| [$table], | ||
| [trim($table, '"')], // Unquote the identifier |
There was a problem hiding this comment.
It probably should be done here:
dbal/src/Schema/AbstractSchemaManager.php
Lines 252 to 257 in 8ce05ed
The name passed to selectTableColumns() is "normalized" but the one passed to _getPortableTableColumnList() is not.
There was a problem hiding this comment.
Thank you for the guidance, I updated the logic.
Is there any rule about where the name should be normalized and where it should be escaped?
There was a problem hiding this comment.
Is there any rule about where the name should be normalized and where it should be escaped?
The quoted name is what we receive from the user to allow them to declare that the original case of the name should be preserved (e.g. the lower-case users table should be introspected even though Oracle by default upper-cases all names). The normalized name is the result of "parsing" the user-supplied input and deriving the actual value from it.
Ideally, we want to normalize the name as soon as possible and use the normalized one downstream.
3347eeb to
c95de27
Compare
Fix SQLite comment retrieval when using quoted identifier as well
c95de27 to
31e1c67
Compare
| [], | ||
| $foreignKeys, | ||
| $tableOptionsByTable[$normalizedName] ?? [], | ||
| $tableOptionsByTable[$name] ?? [], |
There was a problem hiding this comment.
@morozov This change works for oracle but breaks for SQLite... I'm not sure of what approach should I take, but it looks like the mix between normalized / quoted names is the main issue here (and the various databases may not handle them the same).
There was a problem hiding this comment.
If you want, you can scope your pull request only to fixing the table comment, which is necessary only for Oracle (in my understanding).
If you want to fix it for SQLite / column comments as well, you can try referring to the 4.3.x branch. This code has been slightly cleaned up there, and I believe the normalized/quoted names are no longer mixed there. If that's the case, you can try to reconstruct the logic from 4.3.x here.
There was a problem hiding this comment.
This change works for oracle
I think options (and all other table objects) should be indexed by the normalized name. The quoted names are just form or user input, while the normalized ones are the actual values. E.g. on Oracle, the inputs 'users' and '"USERS"' will both be normalized to 'USERS'.
There was a problem hiding this comment.
I believe the normalized/quoted names are no longer mixed there.
I did not check whether there were mixed or no, but I confirm it works for both Oracle and SQLite there.
|
After a few attempts to fix this myself on 3.9.x, I gave up (#6891). See more details in #6764 (comment). |
Thanks for looking more deeply of this @morozov, I believe we will go directly to v4 instead of going through v3 then. I opened #6897 to still port the tests improvements. I close this merge request. |
3.9.xbranch as requested in #6765 (comment)Summary
Use
\Doctrine\DBAL\Schema\OracleSchemaManager::_getPortableTableDefinitionin\Doctrine\DBAL\Schema\OracleSchemaManager::fetchTableOptionsByTableto be consistent with\Doctrine\DBAL\Schema\AbstractSchemaManager::fetchAllAssociativeGroupedwhich calls\Doctrine\DBAL\Schema\OracleSchemaManager::_getPortableTableDefinitionThis also fixes an issue in SQLite due to the fact that the name passed to
_getPortableTableColumnListwas not always normalized.