On Tuesday, March 11, 2014 1:03:05 PM UTC-7, [email protected] wrote: > > Hello, > I'm trying to generate a query with the where statement isolated from any > where statements chained on later. Is this possible? > > So I have something like > query = db[:table].where(a: false) > > later in the code I do: > query.(b: true).or(c: true) > > This results in > SELECT * FROM "table" WHERE ((("a" IS FALSE) AND ("b" IS TRUE)) OR ("c" IS > TRUE)) > > What I want is: > SELECT * FROM "table" WHERE (("a" IS FALSE) AND (("b" IS TRUE) OR ("c" IS > TRUE))) > > With .or I can do this: > query.where({b: true} | {c: true}) > > Can I set something to ensure that the first where statement will always > be isolated? >
query = db[:table].where(a: false).from_self This uses a subselect to isolate the dataset from further changes. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
