finder-sql

Porting complicated has_many relationships to Rails >4.1 (without finder_sql)

纵然是瞬间 提交于 2019-12-30 06:53:51
问题 I am porting a Rails app to Rails 4.2. This Rails app contains some rather complex manual SQL code in associations - partly due to DB optimizations (e.g. subselects instead of JOINs), partly due to no feasible alternative at the time of writing (Rails 3.0), partly surely due to lack of knowledge (I hope, at least - that would be easy to solve). Example: An InternalMessage class. Messages can be sent between users (Recipients of an InternalMessage, and 'deletions' of messages, are stored in

finder_sql does not parse string with Rails

旧时模样 提交于 2019-12-06 08:59:41
问题 I have the problem that the query I use for finder_sql is not parsed correctly before it is handed over to PostgreSQL resulting in a database syntax error. To illustrate the problem I just used the example code from here: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html I only changed class_name to "User" as I don't have a person model but this does not matter here. has_many :subscribers, :class_name => "User", :finder_sql => 'SELECT DISTINCT people.* ' + 'FROM

Porting complicated has_many relationships to Rails >4.1 (without finder_sql)

久未见 提交于 2019-11-30 21:07:05
I am porting a Rails app to Rails 4.2. This Rails app contains some rather complex manual SQL code in associations - partly due to DB optimizations (e.g. subselects instead of JOINs), partly due to no feasible alternative at the time of writing (Rails 3.0), partly surely due to lack of knowledge (I hope, at least - that would be easy to solve). Example: An InternalMessage class. Messages can be sent between users (Recipients of an InternalMessage, and 'deletions' of messages, are stored in InternalMessagesRecipients, since there can be several) and they can be read, replied to, forwarded and