allbut
rel.allbut([:a, :b, ...])rel.allbut(['a', 'b', ...])Problem
Section titled “Problem”Remove some attributes from a relation (this might cause some tuples to become duplicates of others and thus be removed).
Example: What are the different T-shirt variants we stock, if we disregard colors?
Description
Section titled “Description”Identical to project except that it keeps all attributes except those specified in the argument.
Requirements
Section titled “Requirements”The specified attributes must be part of the input relation’s heading.
Examples
Section titled “Examples”Consult the Overview page for the data model used in this example.
suppliers.allbut([:city]).to_a=>[{:sid=>"S1", :name=>"Smith", :status=>20}, {:sid=>"S2", :name=>"Jones", :status=>10}, {:sid=>"S3", :name=>"Blake", :status=>30}, {:sid=>"S4", :name=>"Clark", :status=>20}, {:sid=>"S5", :name=>"Adams", :status=>30}]Generated SQL
Section titled “Generated SQL”SELECT DISTINCT `t1`.`sid`, `t1`.`name`, `t1`.`status`FROM `suppliers` AS 't1'suppliers.allbut(['city']).toArray()
// =>// [{ sid: "S1", name: "Smith", status: 20 },// { sid: "S2", name: "Jones", status: 10 },// { sid: "S3", name: "Blake", status: 30 },// { sid: "S4", name: "Clark", status: 20 },// { sid: "S5", name: "Adams", status: 30 }]