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

Doctrine is not Auto-Escaping Columns #5874

Closed
alexgurrola opened this issue Jun 14, 2016 · 9 comments
Closed

Doctrine is not Auto-Escaping Columns #5874

alexgurrola opened this issue Jun 14, 2016 · 9 comments

Comments

@alexgurrola
Copy link

We have an entity with the column 'limit', but this is a reserved keyword in MySQL. Logically, Doctrine ORM should be Auto-Escaping these Columns, but it's stuck in this ideology that we must escape them in the Column name.

An exception occurred while executing 'INSERT INTO content_stream (pagingType, limit, enableSearch, siteId, vendorId, time, timeEdit, timeStatus, status, userId, editUserId, viewVersionId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["pager", null, 0, 13, null, 1465943902, 1465943902, null, 1, 4, 4, 38064]:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit, enableSearch, siteId, vendorId, time, timeEdit, timeStatus, status, userI' at line 1

According to Issue #2409, we tried the following workaround.

@Column(name="`limit`")

This does work for our current situation, but this is a very fragile train of logic and Doctrine ORM should be providing this level of safety, regardless of whether it is a reserved keyword or not.

@phansys
Copy link
Contributor

phansys commented Jun 14, 2016

See #2409.

@Ocramius Ocramius changed the title Critical: Doctrine Auto-Escaping Columns Doctrine is not Auto-Escaping Columns Jun 15, 2016
@Ocramius
Copy link
Member

This is a well known limitation documented at http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases

We will change this for Doctrine 3.x, but for 2.x, auto-quoting of identifiers is a no-go, mostly because of case sensitivity issues.

Please note that this doesn't cause security issues per se, as mappings are not user input, but static application information.

@alexgurrola
Copy link
Author

alexgurrola commented Jun 20, 2016

@Ocramius Understood. Since this is the case, is there a way to check out Doctrine 3.x? All of my searching has turned up null.

@Ocramius
Copy link
Member

Check the develop branch

@Ocramius
Copy link
Member

@richRemer you know that we still get email notifications, even if you delete messages, right?

@richRemer
Copy link

richRemer commented Oct 19, 2017 via email

@acataluddi
Copy link

This is a well known limitation documented at http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/limitations-and-known-issues.html#identifier-quoting-and-legacy-databases

Hi, is there any way to escape reserved words in XML metatdata? Putting `reserved` works but breaks the XSD validation.

Thanks,
Adriano

@ToonSpinISAAC
Copy link

The documentation page mention seems to have been moved here.

@GitFoxDev
Copy link

Doctrine 3.1. The problem is relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants