Bug in acts_as_list?

I’m using UUIDs as keys into my database (stored as CHAR(36)), and
additionally have a model that is set to act as a list. In this
scenario, I
believe that the queries that Acts::List generate are invalid, caused by
being strings rather than integers.

System info:
Rails: 1.1.4
MySQL: 4.0.26

This is the failing query:
mysql> SELECT * FROM children WHERE (parent_id =
e73fd179-e412-452e-8ac2-b7aac4db4ed4) ORDER BY position DESC LIMIT 1;

ERROR 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
‘ac2-b7aac4db4ed4) ORDER BY position DESC LIMIT 1’ at line 1

However, if you put the ID in quotes, everything is OK:
mysql> SELECT * FROM children WHERE (parent_id =
‘e73fd179-e412-452e-8ac2-b7aac4db4ed4’) ORDER BY position DESC LIMIT 1;

Empty set (0.00 sec)

Note that when using find(), Rails itself uses quotes, for example:
mysql> SELECT * FROM accounts WHERE (accounts.id =
‘c5af5c43-47b3-4e95-a2b7-313b22320945’) LIMIT 1;

This is my first post to the list, so I’m not sure where to file bug
reports. Trac was down at the time of writing, so I couldn’t query for
prior reports either.

If any additional info is needed, I can provide it. Any workarounds
be welcome, as well. For now, I’m just going to switch my development
database to integer keys.

Jared Hanson

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs