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
sqlite3 iterdump fails on column with reserved name #53959
Comments
Sqlite3 fails to dump a database with column names that are keywords. |
Here is a patch that may resolve the bug. |
The second patch contains also fixes for some places where the rules described in http://www.sqlite.org/lang_keywords.html are not followed. |
It also fails if table or column names contain double quote. |
Thank you for the report and patch. Some bug tracker tips:
Regarding the code itself: a) I don’t understand why you added quotes around names that seemed fine without them (for example in “SELECT name”). b) I find the master line difficult to read: “q += ",".join(["'||quote(\"" + col.replace('"', '""') + "\")||'" for col in column_names])”. You’re using backslashes since there are both single and double quotes, but I would use triple-quoted strings here. I also find string formatting more readable than string concatenation: 'blah blah "{}" blah'.format(thing.replace('"', '""')). c) Minor style thing: A generator expression works as fine as a list comprehension in str.join (that is, ",".join(i for i in source) == ";".join([i for i in source])). Thanks again! |
Thank you for the review. I have very limited time to use on this. So even when I'd like to make everything easy for you, have the time you give to python be as productive as possible, I can not. But I'll respond to your comments on the patch. a) I added the quotes to every identifier based on a comment in sqlite documentation "SQLite adds new keywords from time to time when it takes on new features. So to prevent your code from being broken by future enhancements, you should normally quote any identifier that is an English language word, even if you do not have to." While fixing one place, I fixed it to follow this recommendation in other places as well. b) I added quotes using backslashes because it was consistent. The table name was already quoted like that. I agree it could be clearer. c) I know. I only tried to make minimal changes targeted only to the issues at hand. I did not want to hide the fixes in middlde of changes to style. |
a) Thanks for the explanation. This would be a useful comment in the source. b) It’s not uncommon to make cosmetic changes in the same commit as a bugfix. Readability is valued. |
I just encountered this issue today. So, it's been several months, will the patch be merged into the master branch ? Or will this never be fixed ? |
Hi Lucas. Have you read my previous message? The patch needs to be updated. Would you like to do it? |
Sure, I can have a try at it and address the issues you pointed out. The URL to the guidelines you provided gives a 404. In what form exactly would you like the patch to be ? I wouldn't mind either adding to the test suite, but I'm not sure how to do that. |
|
My patch contains two new dump tests which originally fail, and the fixes to the code that makes them pass. |
Here is finally an update to my patch modified according to comments received. It should apply on 2.7 and 3.3 branches. |
Marko's last patch looks good to me. |
Petri, I think you can go ahead. Lucas, thanks for your help, even though your patch is not used. |
New changeset 60aa7dacb605 by Petri Lehtinen in branch '2.7': New changeset 4b105d328fe7 by Petri Lehtinen in branch '3.2': New changeset 5d0f7b275fe9 by Petri Lehtinen in branch 'default': |
Note that the use of 'format' in the 2.7 patch caused a regression (% causes an implicit promotion to unicode, .format does not). See bpo-15109. |
For the record, this patch also introduced another regression (bpo-15545). |
New changeset 2cdb599172ab by R David Murray in branch '3.2': New changeset 6a85894c428f by R David Murray in branch '3.3': New changeset 7a62b5ee32ec by R David Murray in branch 'default': New changeset bb4e4f0cec2e by R David Murray in branch '2.7': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: