Path: | doc/release_notes/4.7.0.txt |
Last Update: | Thu Nov 12 08:45:04 +0000 2015 |
# Window Functions using SQL::Function#over # before: select{sum(:over, :args=>:col1, :partition=>:col2){}} select{sum(:col1).over(:partition=>:col2)} # count(*) using SQL::Function#* # before: select{count(:*){}} select{count{}.*} # count(distinct col) using SQL::Function#distinct # before: select{count(:distinct, :col){}} select{count(:col).distinct}
Additionally, schema qualified functions are now supported via SQL::QualifiedIdentifier#function, and quoted functions are now supported via SQL::Identifier#function on some databases:
# "func"("col") select{func.function(:col)} # "schema"."func"("col1") select{schema__func.function(:col1)}
If the database does not support quoting function names, then Sequel will not quote them.
Album.plugin :update_or_create Album.update_or_create(:name=>'Hello') do |album| album.num_copies_sold = 1000 end
You can also use a shorter form of this, with two hashes:
Album.update_or_create({:name=>'Hello'}, {:num_copies_sold=>1000})
This plugin also adds a method named find_or_new, which does the same thing as update_or_create, except it doesn‘t persist any changes.
The auto_validations plugin uses this option to ensure that unique validations are setup correctly in subclasses using single table inheritance.