In active record I can do the following:
User.where("").to_sql
=> "SELECT \"users\".* FROM \"users\" "
I'd like to make a method that uses Arel to create a predicate to pass as an argument to where. In some cases, I'd like that method to return a predicate with the property,
pred.to_sql
=> ""
that is, I would like the empty predicate. My goal is to be able to have the following,
User.where(my_method).to_sql
always be a valid query.
Using Arel, how can I create this empty predicate? I had a hard time googling this, because empty tends to fill the search with questions about empty query results.
Aucun commentaire:
Enregistrer un commentaire