rom-sql

SQL support for rom-rb

MIT License

Downloads
1.4M
Stars
217
Committers
55

Bot releases are hidden (Show)

rom-sql - Latest Release

Published by flash-gordon 6 months ago

3.6.3 2024-05-06

Fixed

  • Fix using .filter with a block for aggregate functions (@flash-gordon)

Compare v3.6.2...v3.6.3

rom-sql -

Published by flash-gordon 10 months ago

3.6.2 2024-01-09

Fixed

  • Fix Hash.new warning in Ruby 3.3 (@flash-gordon)

Compare v3.6.1...v3.6.2

rom-sql -

Published by flash-gordon almost 2 years ago

Fixed

  • Mapping of cidr types in PostgreSQL to IPAddr values (@flash-gordon)

Compare v3.6.0...v3.6.1

rom-sql - v3.6.0

Published by solnic almost 2 years ago

Added

  • Add ROM::SQL::RakeSupport.migration_options for passing custom options to migrator (@wuarmin)

Changed

  • Upgraded to the latest versions of dry-rb dependencies, compatible with rom 5.3 (@flash-gordon)

Compare v3.5.0...v3.6.0

rom-sql - 4.0.0.alpha1

Published by solnic over 2 years ago

See rom 6.0 upgrade guide.

Changed

  • [internal] all plugins have been ported to the new API (via #402) (@solnic)
  • [internal] :default_views plugin was added and it's enabled by default (via #402) (@solnic)
  • [internal] indexes schema DSL is now a plugin called :schema_indexes (via #402) (@solnic)
  • [internal] Gateway#command is now used to instantiate sql-specific commands (via #402) (@solnic)

Compare v3.5.0...v4.0.0.alpha1

rom-sql -

Published by solnic over 3 years ago

Added

  • Support for using partial indixes in PG upsert commands (issue #394 fixed via #395) (@smaximov)

Fixed

  • Restore the fix for #390 that was lost by an accident in 3.3.3 and 3.4.0 (@solnic)

Compare v3.4.0...v3.5.0

rom-sql -

Published by solnic over 3 years ago

Added

  • Relation#unordered (@radar)

Compare v3.3.3...v3.4.0

rom-sql -

Published by solnic over 3 years ago

Added

  • Support for streaming composite relations (@ianks)

Compare v3.3.2...v3.3.3

rom-sql -

Published by solnic almost 4 years ago

Fixed

  • Function qualification methods no longer lose options (issue #390 fixed via #391) (@solnic)

Compare v3.3.1...v3.3.2

rom-sql -

Published by solnic almost 4 years ago

Fixed

Compare v3.3.0...v3.3.1

rom-sql -

Published by solnic almost 4 years ago

3.3.0 2020-12-28

Added

# 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', ... }]
  • Support for :pg_streaming extension (@ianks)

Fixed

  • Relation#join no longer crashes when aliased relation is used with a block (issue #369) (@abrthel)
  • Attributes aliases are properly handled when constructing queries with SQL functions (issue #370 fixed via #373) (@abrthel)

Compare v3.2.0...v3.3.0

rom-sql -

Published by flash-gordon almost 5 years ago

3.2.0 2020-01-11

Fixed

  • Keyword warnings on Ruby 2.7 (@flash-gordon)

Compare v3.1.0...v3.2.0

rom-sql -

Published by solnic almost 5 years ago

Added

  • .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 ([])
    

Fixed

  • Make Relation#wrap respect association views (@ianks)
  • Primitive JSON-compatible values such as Integer and String are automatically coerced to correct JSONB values and back if you're using a recent Sequel version (>= 5.2.0) (@flash-gordon)
  • Properly qualify relations when in Relation#union (@ianks)
  • Relation#query no longer removes order in the relation (@DNNX)

Compare v3.0.1...v3.1.0

rom-sql -

Published by solnic over 5 years ago

Fixed

  • Using joins with a relation object as the target and a block-based conditions produces correct query now (issue #331) (solnic)

Compare v3.0.0...v3.0.1

rom-sql -

Published by solnic over 5 years ago

Added

  • Join DSL so that you can use arbitrary conditions when joining relations (flash-gordon)
    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)
    
  • Support for 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) }
    
  • Relations can be accessed in DSLs with keyword arguments (flash-gordon)
    users.join(posts).select_append { |posts: | posts[:title] }
    
  • Support for .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)
  • Support for 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) }
  • Support for migrator options ie ROM::Configuration.new(:sql, migrator: { path: "my_migrations" }) (rawburt)
  • Relation#pluck works with multiple args too (timriley)

Changed

  • [BREAKING] Updated to work with dry-types 1.0.0 (flash-gordon)
  • [BREAKING] Types::Int is now Types::Integer (GustavoCaso)

Fixed

  • Using Relation#inner_join with has-many-through produces correct query (issue #279) (doriantaylor + solnic)
  • Aliased attributes are handled correctly in Relation#where (waiting-for-dev)

Compare v2.5.0...v3.0.0

rom-sql -

Published by flash-gordon over 6 years ago

v2.5.0 2018-06-08

Added

  • Support for subqueries in 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))
    

Compare v2.4.0...v2.5.0

rom-sql - 2.4.0

Published by solnic over 6 years ago

Added

  • Support for functions with Any return type ie select { concat(:first_name, ' ', :last_name).as(:name) } will set ROM::Types::Any as the type by default (GustavoCaso)
  • New Relation#as_hash method (GustavoCaso)

Compare v2.3.0...v2.4.0

rom-sql - 2.2.0

Published by solnic almost 7 years ago

v2.2.0 2017-11-02

Added

  • Relation registry is passed as an argument to DSL blocks (in select, where, order etc.), which enables syntax like select { |r| [id, r.tasks[:title]] } (solnic)
  • Support for self-referenced many-to-many associations (solnic)
  • PG's geometric types include meta data about db types (GustavoCaso)

Fixed

  • Custom schema is used correctly in command results (solnic)
  • Schemas no longer finalize PKs (this is done in core schema already) (solnic)

Compare v2.1.0...v2.2.0

rom-sql - 2.1.0

Published by solnic almost 7 years ago

v2.1.0 2017-10-23

Added

  • Support for PG's range types (v-kolesnikov)
  • Support for PG's ltree (GustavoCaso + solnic)
  • Support for the FILTER clause (flash-gordon)

Fixed

  • Schema inference works with primary keys that have custom types (ie an enum PK column) (v-kolesnikov)
  • Ruby warnings are gone (solnic)

Compare v2.0.0...v2.1.0

rom-sql - 2.0.0

Published by solnic almost 7 years ago

v2.0.0 2017-10-18

Added

  • 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') }
    

Changed

  • [BREAKING] based on rom 4.0 now (flash-gordon + solnic)
  • [BREAKING] Associates command plugin requires associations now (solnic)
  • [BREAKING] Command#transaction is gone in favor of Relation#transaction (solnic)
  • [BREAKING] PG::JSONArray, PG::JSONBArray, PG::JSONHash, and PG::JSONBHash types were dropped, use PG::JSON and PG::JSONB instead (flash-gordon)
  • [BREAKING] The 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)
  • Foreign keys are indexed by default (flash-gordon)
  • Schemas are qualified by default (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)

Fixed

  • Self-ref associations work correctly with custom FKs (solnic)
  • Aliased associations with custom FKs work correctly (solnic)
  • Defining a custom dataset block no longer prevents default views like by_pk to be defined (solnic)
  • Relation#group uses canonical schema now (solnic)

Compare v1.3.3...v2.0.0