- Support for ActiveRecord 8.0
- Support for ActiveRecord 7.2
- Fix for running raw SQL queries that contain type casts (from aglushkov)
- Add tests for Ruby 3.3
- Drop support for Ruby 2.x
- Drop support for ActiveRecord 4.2 and 5.x
- Support for ActiveRecord 7.1
- Alias results
to_h
asattributes
to better match Rails
- Match ActiveRecord's behavior for ? methods (e.g.
record.name?
) - Additional, Rails-like formats for query params in
OccamsRecord.sql
:OccamsRecord.sql("SELECT * FROM orders WHERE user_id = :user_id", {user_id: user.id}).run
OccamsRecord.sql("SELECT * FROM orders WHERE user_id = ?", [user.id]).run
OccamsRecord.sql("SELECT * FROM orders WHERE user_id = %s", [user.id]).run
- Bugfix when eager loading a "through" association and passing in a scope
OccamsRecord.sql("SELECT name FROM ...").pluck
prints warnings if args are passed (they'll be removed in a future version)- NOTE
OccamsRecord.query(User.all).pluck(:name)
works as before
- NOTE
- Bug fixes for
#pluck
and enum values for certain combinations of ActiveRecord versions and databases - The most thoroughly tested version EVER!
- Uses a new Docker Compose-based testing system to easily test all Ruby version, ActiveRecord version, and database combinations
- Full support for ActiveRecord enums (previously, support depended on which version of ActiveRecord was used)
- Have
OccamsRecord#run
and#pluck
short-circuit with an empty array if the SQL is blank (i.e.ActiveRecord::QueryMethods#none
was used)
- Add
pluck
toOccamsRecord.sql
, like ActiveRecord's
- Bugfix for eager loading inside a 'through' association
- Improve traces for 'through' associations
- Add the
active_record_fallback
option toeager_load
to allow missing methods to automatically be forwarded to an ActiveRecord instance.
- Add an 'eager load trace' to missing association/column errors. Otherwise, in a very large set of eager loads, it can be virtually impossible to tell where the missing one is.
Example: OccamsRecord::MissingEagerLoadError: Association 'category' is unavailable on Product because it was not eager loaded! Found at root.line_items.product
- Allow
eager_load
blocks to accept an argument. If passed, the block's scope remains the outer scope, allowing instance methods, etc to be called.eager_load
andscope
can be called on the argument.
- Add the
scope
method as an alternative to passing a lambda toeager_load
.
- Support for cursors (Postgres only)
#find_each_with_cursor
#find_in_batches_with_cursor
#cursor
- Support for ActiveRecord 7.0
- Preliminary support for ActiveRecord 7.0 (tested against 7.0.0.alpha2)
- Bugfixes for Active Record 6.1 with
OccamsRecord.sql
. - Better support for other databases with
OccamsRecord.sql
.
- Support for Active Record 6.1
- Bugfix to the column used when merging belongs_to results. Use the primary key of the other table, not this one.
- Bugfix to
*_ids
methods in AR 4.2 - always use the primary key of the other model.
- Append the primary key to ORDER BY when using
find_each
unless the user passes false or a different column inappend_order_by
.
- Append the primary key to ORDER BY when using
find_each
if the primary key is likely to be included in the SELECT.
- Don't append the primary key to ORDER BY when using
find_each
. There's no guarnatee it's included in the SELECT.
- Bugfix when asking if a result
respond_to?
an*_ids
method.
- Bugfix to
eager_load_one
andeager_load_many
when any of the binds from the parent are empty.
- Bugfix to raw sql: when model is set, it should change the connection
- Support for Active Record 6
- Bugfix to
eager_load
on polymorphicbelongs_to
associations when theprimary_key:
option is used. - Bugfix to results when primary key isn't in the SELECT.
- Bugfix to
eager_load
onbelongs_to
associations when theprimary_key:
option is used.
- Allow a proc to be passed to
eager_load
and friends, e.g.eager_load(:category, &nested_eager_loading)
.
- No changes.
- Add
measureable
to find the slow query or queries.
- Wrap
find_each
/find_in_batches
in transactions to guarantee batch integrity. This can be opted out of if desired.
- Bugfix to eager loading "through" associations when something in the chain is
nil
.
- Added
OccamsRecord::Ugly.active_record
to convert records back into Active Record objects. It removes all the performance benefits, buts allows for Occams's improved eager loading and find_each/find_in_batches.
- Bugfix to
eager_load
"through" associations when using a custom name.
- Add
from
option toeager_load
(an opposite alternative toas
).
- Performance improvements!
- Added
rake bench
to measure performance improvements/regressions.
- Bugfix to eager_load through associations.
- Bugfix to eager loading
belongs_to
associations when the two models have different primary key names.
- Bugfix to ad hoc eager loaders.
- BREAKING CHANGE Swapped place of keys and values in the mapping argument for
eager_load_one
/eager_load_many
. E.g. if you hadeager_load_many(:categories, {:id => :category_id}, ...)
it would now beeager_load_many(:categories, {:category_id => :id}, ...)
. - Allowed the mapping argument of
eager_load_one
/eager_load_many
to take multiple pairs.
- Add
OccamsRecord::Query#query
to return a modified query.
- Bugfix to eager loading polymorphic associations when a record has a blank "type" column.
- When eager loading under a polymorphic association, allow associations that only exist on some types.
- Generate
widget_ids
methods ifwidgets
is eager loaded. NOTE will not work withOccamsRecord.sql
unless the model is provided!
- Bugfix to eager loading
has_one
s when there are really many.
- Bugfix to
eager_load_one
andeager_load_many
.
- Support for
:through
associations!has_and_belongs_to_many
are temporarily not supported. Polymorphic associations probably will never be.
- Add
OccamsRecord::Query#first!
- Don't include associations in
#to_h
by default. - Allow Hash-like access for results (both String and Symbol keys)
- Implement
==
so that two objects from the same table with the same primary key value are equal. - Fix
#inspect
in results so it's < 65 chars and will show up in exception messages (https://bugs.ruby-lang.org/issues/8982). - Add
#to_s
to results to return the originating model name and attributes.
- Bugfix to misc eager loaders (empty associations would sometimes be nil instead of an empty array)
- Bugfix to habtm eager loading when used with
find_each
/find_in_batches
.
- Bugfix to using ORDER BY when eager loading a
has_and_belongs_to_many
relationship.
- Support for ActiveRecord 5.2
- Include
Enumerable
inOccamsRecord::Query
andOccamsRecord::RawQuery
. - Fix
OccamsRecord::Query#first
so it doesn't modify the query in place.
- Bugfix to
eager_load_one
/eager_load_many
when there are no parent records.
- Bugfix when eager loading many-to-many associations when there are no parent records.
- Add
OccamsRecord::Query#count
to return number of rows. - Allow a block to be given to
OccamsRecord::Query#run
to modify that run's query. - Clean up error classes. Now just:
OccamsRecord::MissingColumnError
,OccamsRecord::MissingEagerLoadError
. - Raise the above errors when a column is missing during eager loading.
- Bugfix to eager loading when no parent records were returned.
- Bugfix to find each.
- Rubygems.org fucked up.
- Raise
OccamsRecord::Results::MissingEagerLoadError
if an unloaded association is called. - Raise
OccamsRecord::Results::MissingColumnSelectError
if an unselected column is called.
- Add
eager_load_one
andeager_load_many
for ad hoc, raw SQL associations.
- Change
use:
option to prepend modules instead of including them.
- Bugfix to friendly exception edge case
- Friendly exceptions when eager loading fails (usually b/c a column wasn't in the
SELECT
).
- eager_load should check subclasses for matching associations.
- For booleans in results, add
<field>?
aliases.
- Add
find_each
andfind_in_batches
for raw SQL queries.
- BREAKING CHANGE to
eager_load
. If you pass it a Proc, that Proc must now accept one argument (anActiveRecord::Relation
). You will callselect
,where
, etc, and any model scopes on it instead of calling them "magically" on nothing.
- Allow eager loading
as:
a different attribute name. - Add
OccamsRecord::Query#first
(returns only one record).
- Bugfix to null datetimes
- Bugfix - Convert datetime results to local timezone (i.e.
Time.zone
), instead of leaving them as UTC. - Add support for running raw SQL queries with
OccamsRecord.sql
.
- Improvement to selecting columngs by different names, aggregates, etc. wrt to type conversion.
- Always append the primary key to the ORDER BY clause when using find_each/find_in_batches.
- Refactor (most) eager loading merge code into a dedicated class.
- Add Query#to_a and each, to better match ActiveRecord semantics.
- Bugfix to polymorphic belongs_to eager loader. (Edge case. If all instances of an associated type were somehow missing/deleted, and the foreign keys weren't cleaned up, the eager loader would blow up.)
- Bugfix to has_and_belongs_to_many eager loader
- Add
select:
convenience option toeager_load
.
- Allow
use:
to be passed an array of Modules, instead of just one
- Initial release