Bot releases are visible (Hide)
.filter
with a block for aggregate functions (@flash-gordon)Published by solnic almost 2 years ago
Published by solnic over 2 years ago
:default_views
plugin was added and it's enabled by default (via #402) (@solnic)indexes
schema DSL is now a plugin called :schema_indexes
(via #402) (@solnic)Gateway#command
is now used to instantiate sql-specific commands (via #402) (@solnic):pg_streaming
plugin no longer crashes when there's no sequel_pg and now you need to require the plugin explicitly (@solnic)Relation#full_text_search
that provides an API for PostgreSQL's Full Text Search (@ianks)# Don't forget to activate the plugin
conf.plugin(:sql, relations: :pg_full_text_search)
posts.full_text_search([:title], 'tutorials', language: 'english')
# => [{ title: 'A Tutorial about SQL', ... }]
:pg_streaming
extension (@ianks)Relation#join
no longer crashes when aliased relation is used with a block (issue #369) (@abrthel).nullify
that turns the result set of any relation into an empty set. Analogue of ActiveRecord#none
(@ianks + @flash-gordon)
# Don't forget to activate the plugin
conf.relation(:users) do
use :nullify
end
users.nullify.count # => will always be 0
users.nullify.to_a # => will always be empty ([])
Relation#wrap
respect association views (@ianks)Relation#union
(@ianks)Relation#query
no longer removes order in the relation (@DNNX)users.join(tasks) { |users:, tasks:|
tasks[:user_id].is(users[:id]) & users[:name].is('John')
}
You also can use table aliases, however the setup is a bit hairy:
# self-join "users" with itself using "authors" as an alias
authors = users.as(:authors).qualified(:authors)
result = users.join(authors) { |users: |
users[:id].is(authors[:id])
}.select(:name)
CASE
expression (wmaciejak + flash-gordon)
# matching expression result
users.select_append { id.case(1 => string('one'), else: string('something else')).as(:one_or_else) }
# searching for `true` result
users.select_append { string::case(id.is(1) => 'one', else: 'else').as(:one_or_else) }
users.join(posts).select_append { |posts: | posts[:title] }
.exists
in the projection DSL (flash-gordon)
users.select_append { |posts: |
exists(posts.where(posts[:user_id] => id)).as(:has_posts)
}
Relation#unfiltered
returns an unrestricted relation (removes restrictions from WHERE
and HAVING
) (flash-gordon)WITHIN GROUP
in the function DSL has been enhanced with block syntax (flash-gordon) # previously available version
households.project { float::percentile_cont(0.5).within_group(income).as(:percentile) }
# using the new syntax
households.project { float::percentile_cont(0.5).within_group { income }.as(:percentile) }
ROM::Configuration.new(:sql, migrator: { path: "my_migrations" })
(rawburt)Relation#pluck
works with multiple args too (timriley)dry-types 1.0.0
(flash-gordon)Types::Int
is now Types::Integer
(GustavoCaso)Relation#inner_join
with has-many-through produces correct query (issue #279) (doriantaylor + solnic)Relation#where
(waiting-for-dev)SELECT
and WHERE
🎉 (flash-gordon)
tasks = relations[:tasks]
users = relations[:users]
user_tasks = tasks.where(tasks[:user_id].is(users[:id]))
tasks_count = user_tasks.select { int::count(id) }
users.select_append(tasks_count.as(:tasks_count))
Published by solnic over 6 years ago
Any
return type ie select { concat(:first_name, ' ', :last_name).as(:name) }
will set ROM::Types::Any
as the type by default (GustavoCaso)Relation#as_hash
method (GustavoCaso)Published by solnic almost 7 years ago
select
, where
, order
etc.), which enables syntax like select { |r| [id, r.tasks[:title]] }
(solnic)Published by solnic almost 7 years ago
ltree
(GustavoCaso + solnic)FILTER
clause (flash-gordon)Published by solnic almost 7 years ago
Support for schema plugins (flash-gordon)
Support for auto migrations (flash-gordon)
Add DLS for describing table indexes (flash-gordon)
schema do
indexes do
index :name, name: :unique_name, unique: true
index :props, type: :gin
index :name, name: :long_names_only, predicate: 'length(name) > 10'
index :user_id, :title, name: :composite_idx
end
end
Support for composite indexes in the auto-restrictions plugin (flash-gordon)
SQL::Gateway#call
calls a SQL function (flash-gordon)
gateway.(:upper, 'foo') # => "FOO"
gateway.(:pg_advisory_xact_lock, 1234) # => nil
SQL::Gateway#run
executes a SQL string, e.g. a DDL statement (flash-gordon)
gateway.run('set session IntervalStyle to default')
SQL::Relation#exists
joins a relation with the EXISTS
operator (flash-gordon)
users.exists(posts) # => users with posts
Support for processing a relation in batches (flash-gordon)
users.each_batch(size: 100) do |rel|
rel.
command(:update).
call(name: users[:first_name].concat(users[:last_name])
end
SQL::Relation#import
inserts data from another relation using the INSERT ... AS SELECT
syntax which is often far more effective than row-by-row processing and an ordinary multi-insert. Relations defined on another gateway are also supported, and in this case, the implementation falls back to the multi-insert strategy (flash-gordon)
users.import(authors.select { first_name.concat(last_name).as(:name) })
Support for tinytext
, text
, mediumtext
, and `longtext data types in MySQL (panthomakos)
The new pg_explain
plugin for getting query plans on PostgreSQL (flash-gordon)
users.by_pk(1).explain(format: :json, analyze: true)
Support for window function calls
employees.select { [dep_no, salary, int::avg(salary).over(partition: dep_no, order: id).as(:avg_salary)] }
Function result can be negated, also ROM::SQL::Function#not
was added (flash-gordon)
users.where { !lower(name).is('John') }
users.where { lower(name).not('John') }
Associates
command plugin requires associations now (solnic)Command#transaction
is gone in favor of Relation#transaction
(solnic)PG::JSONArray
, PG::JSONBArray
, PG::JSONHash
, and PG::JSONBHash
types were dropped, use PG::JSON
and PG::JSONB
instead (flash-gordon)pg_hstore
extension now doesn't get loaded automatically, use the :extension
option to load it on config initialization (flash-gordon)ManyToOne
no longer uses a join (solnic)AutoCombine
and AutoWrap
plugins were removed as this functionality is provided by core API (solnic)PG::JSON
, PG::JSONB
, and PG::Array
now all have read types so that they return plain Hash/Array values instead of Sequel's wrappers (flash-gordon)by_pk
to be defined (solnic)Relation#group
uses canonical schema now (solnic)