dm-core 0.10.x 不支援!!
一直碰到這個問題:
Not unique table/alias: 'users'
SELECT `users`.`id` FROM `users` INNER JOIN `cache_friendships` ON
`users`.`id` = `cache_friendships`.`user_false_id` INNER JOIN
`users` ON `cache_friendships`.`user_true_id` = `users`.`id` WHERE
`cache_friendships`.`user_true_id` = 2 GROUP BY `users`.`id` ORDER
BY `users`.`id`
然而 ActiveRecord 產生這段:
SELECT `users`.* FROM `users` INNER JOIN `cache_friendships` ON
`users`.id = `cache_friendships`.user_false_id WHERE
((`cache_friendships`.user_true_id = 2))
我看不懂 SQL.... 只覺得 DataMapper 那未免相較之下也太長了吧?
原本覺得是 bug, 但查 source 看半天,好像又都沒錯。後來以為是
用法錯誤,調整了一下,好像又沒錯。最後只好 google datamapper +
friendship, 結果沒幾筆就看到跟我一樣的問題...
回答居然說不支援 >< 這樣我要怎麼搞啊? -_-
[DataMapper] DataMapper 0.10.1 association problem
p.s., 我喜歡這個:
>> User.relationships[:friends].via == Friendship.relationships[:user]
=> true
0 retries:
Post a Comment
Note: Only a member of this blog may post a comment.