Skip Menu |

This queue is for tickets about the DBIx-Class-Journal CPAN distribution.

Report information
The Basics
Id: 63721
Status: rejected
Priority: 0/
Queue: DBIx-Class-Journal

People
Owner: Nobody in particular
Requestors: anthony.carapetis [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.900200
Fixed in: (no value)



Subject: relation AuditHistory->change leads to reserved keyword error on join with some backends
I'm using DBIx-Class-Journal-0.900200 and DBIx-Class-0.08124 with a MySQL backend. This is perl, v5.10.0 built for i486-linux-gnu-thread-multi. mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) I've run into an issue when trying to join a FooAuditHistory resultset with the corresponding ChangeLog resultset. Here's the DBIx::Class query, generated query and the resulting error: ---------------------- $schema->_journal_schema->resultset('PlanetAuditHistory')->search({},{join => { 'change' => 'changeset'}}) SELECT me.audit_history_id, me.audit_change_id, me.id, me.name, me.diameter, me.position FROM planet_audit_history me JOIN changelog change ON change.ID = me.audit_change_id JOIN changeset changeset ON changeset.ID = change.changeset_id ORDER BY audit_change_id DESC; ERROR 1064 (42000): 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 'change ON change.ID = me.audit_change_id JOIN changeset changeset ON changeset.I' at line 1 ---------------------- Changing the alias "change" to "changelog" in the SQL query removes the error, so it seems that "change" is a reserved word in MySQL. This issue can fixed by a single change to the AuditHistory schema: diff -r old/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm new/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm 43c43 < $class->belongs_to(change => "${schema_class}::ChangeLog", 'audit_change_id'); --- Show quoted text
> $class->belongs_to(changelog => "${schema_class}::ChangeLog",
'audit_change_id'); Thanks, Anthony
On Tue Dec 07 19:01:35 2010, acarapetis wrote: Show quoted text
> Changing the alias "change" to "changelog" in the SQL query removes the > error, so it seems that "change" is a reserved word in MySQL. This issue > can fixed by a single change to the AuditHistory schema: > > diff -r old/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm > new/lib/DBIx/Class/Schema/Journal/DB/AuditHistory.pm > 43c43 > < $class->belongs_to(change => "${schema_class}::ChangeLog", > 'audit_change_id'); > ---
> > $class->belongs_to(changelog => "${schema_class}::ChangeLog",
> 'audit_change_id');
Alternately, just turn on quoting. Rob
Rejecting this as turning on quoting is the correct solution.