Method: Sequel::Dataset#except
- Defined in:
- lib/sequel/dataset/query.rb
permalink #except(dataset, opts = OPTS) ⇒ Object
Adds an EXCEPT clause using a second dataset object. An EXCEPT compound dataset returns all rows in the current dataset that are not in the given dataset. Raises an InvalidOperation
if the operation is not supported. Options:
- :alias
-
Use the given value as the from_self alias
- :all
-
Set to true to use EXCEPT ALL instead of EXCEPT, so duplicate rows can occur
- :from_self
-
Set to false to not wrap the returned dataset in a from_self, use with care.
DB[:items].except(DB[:other_items])
# SELECT * FROM (SELECT * FROM items EXCEPT SELECT * FROM other_items) AS t1
DB[:items].except(DB[:other_items], all: true, from_self: false)
# SELECT * FROM items EXCEPT ALL SELECT * FROM other_items
DB[:items].except(DB[:other_items], alias: :i)
# SELECT * FROM (SELECT * FROM items EXCEPT SELECT * FROM other_items) AS i
157 158 159 160 161 |
# File 'lib/sequel/dataset/query.rb', line 157 def except(dataset, opts=OPTS) raise(InvalidOperation, "EXCEPT not supported") unless supports_intersect_except? raise(InvalidOperation, "EXCEPT ALL not supported") if opts[:all] && !supports_intersect_except_all? compound_clone(:except, dataset, opts) end |