For reference, this question was boggled, so thanks to everyone who helped unboggle it.
I'm trying to locate potential collisions of events in a booking program where events have varying lengths.
(a ≤ x && e ≥ y) || (a ≥ x && e ≤ y) || (a ≤ x && e ≤ y) || (a ≥ x && e ≥ y)
I'm using DataMapper to accomplish this, but the query I had before was wrong. I then figured out the above, but I'm not sure how to translate that into a query. Below is my incorrect query for reference.
class Table
def is_available?
return false if (TableBooking.all(:at.lte => params[:at], :at.gt => params[:ending], :ending.gt => params[:at], :ending.gte => params[:at]).count > 0)
end
end