Skip to content

v3.0.0

Compare
Choose a tag to compare
@solnic solnic released this 28 Apr 10:05
v3.0.0
10f6210

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