You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BabySqueel[:table] returns an object that does not respond to sift.
Now that I'm writing this, I realize it makes some sense, BabySqueel doesn't know anything about which model belongs to a table. However, would it be possible to add a model's sifter to a BabySqueel-initiated table object?
Reproduction
require'bundler/inline'require'minitest/spec'require'minitest/autorun'gemfiletruedosource'https://rubygems.org'gem'activerecord','~> 5.0.0'# which Active Record version?gem'sqlite3'gem'baby_squeel',github: 'rzane/baby_squeel'endActiveRecord::Base.establish_connection(adapter: 'sqlite3',database: ':memory:')ActiveRecord::Schema.definedocreate_table:dogs,force: truedo |t|
t.string:nameendcreate_table:people,force: truedo |t|
t.string:namet.integer:aget.string:dog_nameendendclassDog < ActiveRecord::BaseendclassPerson < ActiveRecord::Basesifter(:female){name.in?%w(angelabrittanycarol)}endclassBabySqueelTest < Minitest::Specit'does not raise an exception'dopeople=BabySqueel[:people]# Find all dogs that have a female adult bossscope=Dog.joining{people.on(people.dog_name == name)}.where.has{people.sift(:female) & (people.age >= 18)}# FIXME: This SQL may be off, the point is whether or not it raises an exception. I'm not an expert with minitest.scope.to_sql.must_equal%{ SELECT "dogs".* FROM "dogs" INNER JOIN "people" ON "people"."dog_name" = "dogs"."name" WHERE "people"."name" IN ('angela', 'brittany', 'carol') AND "people"."age" >= 18; }.squishendend
The text was updated successfully, but these errors were encountered:
Issue
BabySqueel[:table]
returns an object that does not respond tosift
.Now that I'm writing this, I realize it makes some sense, BabySqueel doesn't know anything about which model belongs to a table. However, would it be possible to add a model's sifter to a BabySqueel-initiated table object?
Reproduction
The text was updated successfully, but these errors were encountered: