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

SQL syntax error when viewing revisions on entities with MySQL reserved yet quoted field names. #26

Closed
bobemoe opened this issue Sep 8, 2012 · 2 comments
Labels

Comments

@bobemoe
Copy link

bobemoe commented Sep 8, 2012

Entity with fields to and from produces invalid SQL due to not being quoted is the AS part.

Fields on entity are defined as such:
/**
* @var string $to
* @Orm\Column(name="to", type="string", length=255)
*/
private $to;

SQL errors:

SELECT e.revtype, id AS id, name AS name, to AS to, from AS from, subject AS subject, body AS body FROM MailTemplate_audit e WHERE e.rev = ?' with params {"1":"4"}: 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 'to, from AS from, subject AS subject, body AS body FROM MailTemplate_audit e W' at line 1 (uncaught exception)

Quick (but untested for side affects) fix is to comment out the end of line 222 of SimpleThings\EntityAudit\AuditReader (https://github.com/simplethings/EntityAudit.git 60a5bcb)

            $columnList .= ', ' . $class->getQuotedColumnName($field, $this->platform);// .' AS ' . $field;

EDIT: Correct formatting for clarity (to and from was showing as to and from)

@andrewtch
Copy link
Contributor

@bobemoe , this should be fixed by now. Please re-check or close.

@bobemoe
Copy link
Author

bobemoe commented Jan 10, 2015

I no longer maintain the project that this affected so can't easily test. I will close this issue. Thanks.

@bobemoe bobemoe closed this as completed Jan 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants