Skip to content
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

SQLite: Escape numbers as keywords #4247

Closed
wants to merge 1 commit into from
Closed

SQLite: Escape numbers as keywords #4247

wants to merge 1 commit into from

Conversation

MyIgel
Copy link
Contributor

@MyIgel MyIgel commented Sep 2, 2020

Q A
Type bug
BC Break no
Fixed issues #4243

Summary

This fixes #4243 by escaping numbers

*/
public function isKeyword($word)
{
return parent::isKeyword($word) || is_numeric($word);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an alternative to #4246? 5 doesn't look like an SQLite keyword, so this change doesn't look right. As pointed out earlier, the problem is that an invalid key name is generated in the first place, not that it's not escaped.

Copy link
Contributor Author

@MyIgel MyIgel Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no, no one prevents a user to use numbers as FK names so it can break for them in the future. The reason its here is to not clutter \Doctrine\DBAL\Schema\AbstractAsset::getQuotedName with some numerical checks, esp. as i don't know how other databases handle this and at the end this was the fastest (aka least code change/restructuring) change

So to compare them both: The first and the second PR fix the same problem by fixing two independent bugs which in combination make changing tables with FKs impossible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're currently reevaluating the approach to quoting names leaning towards the user being responsible for quoting since the existing magic is unreliable anyways.

no one prevents a user to use numbers as FK names so it can break for them in the future

I believe it never worked, so it's a good enough preventing measure.

Regardless of that, it doesn't look like a bugfix so 2.10.x is not the right place for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least it would be the smallest hotfix for 2.10.x as its currently broken for anyone changing tables so i would consider it a bugfix? But i totally agree with the point that it definitely does not feel right to add it there (but again, its the "minimum change"/the change that i am currently comfortable to do in this project 😁)

@beberlei
Copy link
Member

beberlei commented Sep 6, 2020

This is a band-aid and its better to fix the root cause see #4246 and #4256

@beberlei beberlei closed this Sep 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants