Sha256: 4b0cc71c35bc2568dd3d2da079f05d6601b51aad036060511f1e88bcee088d4c
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'mr' require 'test/support/models/area' class SetData include MR::ReadModel field :id, :primary_key, 'filtered_areas.id' field :name, :string, 'filtered_areas.name' from_subquery do read_model do select 'areas.id, areas.name' from AreaRecord where do |params| AreaRecord.where("areas.name LIKE ?", "#{params[:match_start]}%") end union do select 'areas.id, areas.name' from AreaRecord where do |params| AreaRecord.where("areas.name LIKE ?", "#{params[:other_match_start]}%") end end intersect do select 'areas.id, areas.name' from AreaRecord where do |params| AreaRecord.where("areas.name LIKE ?", "%#{params[:match_end]}") end end except do select 'areas.id, areas.name' from AreaRecord where do |params| AreaRecord.where("areas.name LIKE ?", "%#{params[:non_match]}%") end end end as 'filtered_areas' end find_attr 'filtered_areas.id' end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mr-0.35.2 | test/support/read_models/set_data.rb |