Skip to content

Releases: nulogy/vorpal

DB view-backed models

16 Jul 16:42
Compare
Choose a tag to compare

Vorpal now supports Ruby models that are backed by DB views out of the box!

Previous versions require the following code to support view-backed models: engine.mapper_for(DomainClass).db_class.primary_key = 'id'

This is especially helpful for doing ZDT-safe database refactorings.

Fix for models based on DB views

09 Jul 00:05
Compare
Choose a tag to compare

Release 1.3.0 contained a speculative change the used the ActiveRecord::Base.primary_key method to try and determine the primary key. Apparently, ActiveRecord is unable to automatically determine the primary key for database views in PostgreSQL, so this change meant that the primary key needed to be set manually. Since this change was speculative, it is being rolled back. It may not even be necessary because of https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/PrimaryKey/ClassMethods.html.

Associating to non-PK columns

07 Jul 23:11
Compare
Choose a tag to compare

Now Vorpal can handle associating two tables when the foreign key of one table refers to a column other than the primary key of the other table.

Example

Authors Table:

+------------------+--------------------------------------+----------+
| id (Primary Key) |          uuid (Unique Key)           |   name   |
+------------------+--------------------------------------+----------+
|                1 | a1a7d616-7f8c-4351-a51b-1ed123403257 | Jane Doe |
|                2 | b01ee2d0-c8a6-47a1-a1b5-a34d23ad2e57 | John Doe |
+------------------+--------------------------------------+----------+

Posts Table:

+------------------+------------------+----------------------+--------------------------------------+
| id (Primary Key) |       name       |     description      |      author_uuid (Foreign Key)       |
+------------------+------------------+----------------------+--------------------------------------+
|                1 | Jane's birthday! | It was crazy         | a1a7d616-7f8c-4351-a51b-1ed123403257 |
|                2 | Fun with EMACS   | I wish it was faster | b01ee2d0-c8a6-47a1-a1b5-a34d23ad2e57 |
+------------------+------------------+----------------------+--------------------------------------+

We can map with the following configuration:

Vorpal.define do
  map Author do
    attributes :name, :uuid
    has_many :posts, fk: :author_uuid, primary_key: :uuid
  end

  map Post do
    attributes :name, :description
    belongs_to :author, fk: :author_uuid, primary_key: :uuid
  end
end

Remember that the contents of any column specified by the :primary_key option must be unique!

Users may also use the :unique_key_name option instead of :primary_key if they wish to be more descriptive but less Rails-compliant :)

Other notable changes

  • Optimized lookups: Vorpal will now do fewer database queries.
  • The :child_class option for has_many, has_one, and belongs_to associations has been deprecated in favour of :associated_class

Better UUID support!

26 Nov 04:59
Compare
Choose a tag to compare

Lifts the restriction that only Vorpal should be setting entity ids.

UUID Support!

25 Nov 21:48
Compare
Choose a tag to compare

Vorpal now supports UUID v4 ids!

Vorpal.define do
  # UUID v4 id!
  map Tree, primary_key_type: :uuid do
    # ..
  end

  # Also a UUID v4 id, the Rails Way!
  map Trunk, id: :uuid do
    # ..
  end

  # If you feel the need to specify an auto-incrementing integer id.
  map Branch, primary_key_type: :serial do
    # ..
  end
end

CAVEAT: Vorpal currently does NOT SUPPORT anyone but Vorpal setting the id of an entity!

Rails 6 bulk SQL operations

03 Oct 02:17
Compare
Choose a tag to compare

Vorpal now supports Rails 6 bulk insert_all and upsert_all methods for super fast creating and updating!

The activerecord-import gem is no longer required to get bulk inserts and can be removed.

Our performance benchmarks now show a 17% improvement in creation times (over using activerecord-import) and a 27% improvement in update times.

Enjoy!

Plays nicely with bundler

31 Jan 17:28
Compare
Choose a tag to compare

Merges #22 which removes a warning when running tests for projects that include Vorpal and use more recent versions of bundler.

Thanks @arturopie !

Support for Rails 6.0 and Ruby 2.7!

24 Jan 22:28
Compare
Choose a tag to compare

This release builds official support for Rails 6.0 and Ruby 2.7.

As an extra goodie, it seems like update performance has increased!

Rails 5.2

              user     system      total        real
create    0.640735   0.009528   0.650263 (  0.778304)
update    2.051961   0.187531   2.239492 (  2.752651)
load      1.127992   0.009353   1.137345 (  1.323969)
destroy   0.694419   0.004167   0.698586 (  0.928359)

Rails 6.0

              user     system      total        real
create    0.661741   0.008410   0.670151 (  0.785426)
update    1.419727   0.005630   1.425357 (  1.539234)
load      1.042127   0.006379   1.048506 (  1.156116)
destroy   0.693851   0.003333   0.697184 (  0.829565)

Support for Rails 5.1 and 5.2!

05 Oct 20:06
Compare
Choose a tag to compare

This release adds support for Rails 5.1 and 5.2 as well as makes it easier for contributors to verify that the tests are working in all supported versions of Rails (thanks to @amckinnell for his tip to use the Appraisal gem!)

Vorpal has gone gold!

26 Jun 20:03
b3728e1
Compare
Choose a tag to compare

After more than a year of use in Nulogy's production applications, Vorpal has become stable enough to warrant the big V1!

Thanks @ecbrodie for the version bump!