我手动编写了此查询,该查询返回了正确的结果数:
SELECT * FROM taggings WHERE taggable_id = 62097 AND taggable_type = 'SongVersion'
然后我有一个acts-as-taggable-on中的方法,该方法使用active-record编写生成的sql:
ActsAsTaggableOn::Tagging Load (0.4ms) SELECT "taggings".* FROM "taggings" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 [["taggable_id", 62097], ["taggable_type", "SongVersion"]]
但是,这不会返回任何结果。据我所知,这两个查询几乎相同。实际上,没有$参数,我可以使用ActiveRecord格式从第一个查询中获得相同的结果
SELECT "taggings".* FROM "taggings" WHERE "taggings"."taggable_id" = 62097 AND "taggings"."taggable_type" = 'SongVersion'
有什么想法为什么AR生成带有$参数的sql不会得到相同的结果?