-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Preference for quoting identifier mechanism #1436
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
Conversation
A new option is added to the SQL tab in Preferences for choosing which quoting characters must be used by the application when it inserts an identifier in SQL code. The three options supported by SQLite are available. Default quoting characters have been changed from `Grave accents` to "Double quotes" (SQL standard). This options also affect the highlighting of double quoted strings: when the SQL standard is selected, double quoted expressions are highlighted as identifiers, otherwise as literal strings.
The former quoting is expected by the tests, so the former behaviour is restored as default, until a decision about the best default value is made.
The former quoting is expected by the tests, so the former behaviour is restored as default, until a decision about the best default value is made.
|
I changed the default value to `grave accents` because it was breaking the tests. I didn't know how to run the tests until know. I'll run them before any commit. When we decide which is the best value for the default, I'll update the tests. |
| // so we rely on the user to not enter these characters when this kind of quoting is | ||
| // selected. | ||
| return '[' + id + ']'; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces a control reaches end of non-void function warning for me even though you have covered all possibilities in that switch statement. Maybe just add a default branch which falls through to DoubleQuotes?
src/sqlitetypes.cpp
Outdated
|
|
||
| QStringList Field::Datatypes = QStringList() << "INTEGER" << "TEXT" << "BLOB" << "REAL" << "NUMERIC"; | ||
|
|
||
| escapeQuoting customQuoting = GraveAccents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be made static.
|
Thanks for taking care of this! I wanted to do this a long time ago but never got around it 😄 I have already pointed out two minor things in the code but here is a more in-depth answer for each of your four points.
|
|
One extra thing here: when you change the default to double quotes and you update the tests, maybe add a few tests for the different settings - just to make sure we cover not only the default case. |
Let me explain it with images 😃 My conclusion is: we should set
even though we loose the table style for quoted table identifiers. [1] Extreme case example: from https://dbhub.io/nicva/State%20of%20the%20Sector%20-%20Volunteers%20Chapter.sqlite |
|
Heh Heh Heh. I wondered if anyone would notice the dbhub.io server is available again. It's still not GDPR compliant, but I've pinged Cristian Driga again to pick it back up, so we can start working on that too. 😄 |
Modified some tests for taking into account the new standard quoting and added some more for testing the quoting configuration and for correct parsing of different quoting styles. Default branch in escapeIdentifier() for trying to avoid warning.
…ements "SQL editor font" and "SQL editor font size" are located at the same row for saving vertical space in the Preferences dialog. Accelerator keys for "Wrap lines" and "Quotes for identifiers" have been added. Some buddies have been fixed.
|
I consider the feature now complete and it's ready for review.
|
|
@MKleusberg I'll alleviate a bit your review queue by merging this 😃 I think the important concerns are already discussed and addressed. Anyway, don't mind making a review after the merge and comment whatever you would prefer changed and I'll address it then. |
|
Thanks a lot, @mgrojo 😄 Looking at your pictures I now understand what you meant and agree with your analysis. |
Since PR #1436 we allow configuration of the identifier quotes instead of always using backticks. But in the code for detecting a custom display format on a column the assumption still was that normal columns without a custom display format are always surrounded in backticks. The result of this was that even if there is only a single display format configured for a table, no field of no column can be edited anymore. This commit restores the original state which would only disable editing for the columns with a custom display format.




A new option is added to the SQL tab in Preferences for choosing which
quoting characters must be used by the application when it inserts an
identifier in SQL code. The three options supported by SQLite are
available.
Default quoting characters have been changed from `Grave accents` to
"Double quotes" (SQL standard).
This options also affect the highlighting of double quoted strings: when
the SQL standard is selected, double quoted expressions are highlighted as
identifiers, otherwise as literal strings.
See issues #683 and #1280.
Matters to be discussed:
SQL editor font sizebox to the same row asSQL editor fontbut I was unable to do it with qtcreator and didn't dare to change it manually without knowing if the UI change would be welcome.Noneoption be available? This would left the responsibility of using appropriate identifiers to the user. I've discarded this option because it feels problematic, but it was suggested in Automatic quoting identifiers inconsistent and probably not desirable. #1280.