mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Flush on MariaDB fails to Syntax error #6380
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @NikoGrano on GitHub (Jan 9, 2020).
Originally assigned to: @lcobucci on GitHub.
Bug Report
Summary
I am trying to persist entity with to the database. It fails.
Current behaviour
How to reproduce
I have Entity extending abstract entity.
When trying to do following, I will get mentioned failure.
I do not expect you to fix this, if this is bug with my code, but as I have this code publicly available, it might help you. Repository is available here
Expected behaviour
Entity gets persisted.
Next Steps in debugging
I will be trying to run this under MariaDB 10.3. However, it should not affect this at all and do not wait me while I do it.Same error under 10.3.21
@NikoGrano commented on GitHub (Jan 9, 2020):
Ref https://github.com/doctrine/dbal/issues/3815
@NikoGrano commented on GitHub (Jan 10, 2020):
I tried to debug this following way:
bin/console doctrine:schema:update --force. This worked fine as it should, but when I try again persist on that Entity, I got this errorBut, when I try run query via DB CLI, it works fine.
Query working directly on DB.
This seems like, either of ORM or DBAL is generating faulty query for the database.
@nikophil commented on GitHub (Jan 10, 2020):
i guess
indexis a reserved word in sql, you have to explicitely escape it in your column declaration in the entity(notice the wrapping backticks)
@NikoGrano commented on GitHub (Jan 10, 2020):
Yes, it works now. Thank you. (Closing due this is not anymore issue, but needs discussing.)
Shouldn't this be automatically detected by ORM? Like, if field name would map into reserved word it would add backticks automatically?
@nikophil commented on GitHub (Jan 10, 2020):
i don't know why this is not directly handled, maybe a doctrine expert could answer that, i'm curious as well, i had this problem at some time which is tricky to detect
@Ocramius @alcaeus
@NikoGrano commented on GitHub (Jan 12, 2020):
Reopening to gain attention.
@alcaeus commented on GitHub (Jan 13, 2020):
Sorry, don't use ORM or MariaDB, so I have no clue. There's also no need to go close/reopen issues - just because it's at the top of my notification list doesn't mean I'll get to it any faster.
@NikoGrano commented on GitHub (Jan 13, 2020):
Related to most of databases anyways, tought it will go past, if you see this as closed. Will be waiting for you reply.
@lcobucci commented on GitHub (Jan 13, 2020):
This is a documented behaviour of v2.x: https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/basic-mapping.html#quoting-reserved-words
Things are changing for new versions but this is what we have for now.
@NikoGrano commented on GitHub (Jan 13, 2020):
@lcobucci Can you answer to this? So is this going to be fixed in future to be working automatically or can I create PR for it and fix it.
@lcobucci commented on GitHub (Jan 13, 2020):
What I meant with "things are changing for new versions" is that it's already implemented for v3.0-dev and won't be ported back on v2.x unless we manage to have BC-compatible implementation.
Not having automatic quoting isn't seen as a bug but a missing feature, so such implementation should come in a minor release (and not a patch). Feel free to send a PR 😁