invoca / aggregate Goto Github PK
View Code? Open in Web Editor NEWA no-sql style key value store with migrations and data validations
License: MIT License
A no-sql style key value store with migrations and data validations
License: MIT License
When adding a new aggregate_attribute
with a default value, e.g.
aggregate_attribute :days, :integer, default: 0
The new attribute when added to an ActiveRecord object that already has serialized data in its aggregate storage column will not have its default value applied, and will instead have a value of nil
.
Example
aggregate_attribute :description, :string
aggregate_attribute :friendly_label, :string
person = Person.create!
person.set!(description: "very cool", friendly_label: "Jim")
aggregate_attribute :description, :string
aggregate_attribute :friendly_label, :string
aggregate_attribute :favorite_number, :integer, default: 0
person
for favorite_number
will be nil
instead of 0
, which is confusing.person = Person.find(ID) # Assume it's the same person record as above
person.favorite_number == nil
An important note is that the person
record will not have a favorite_number
key in its serialized aggregate data that's stored in the DB.
Currently tests won't run for Rails 6 because they of this error.
master => ~/invoca/aggregate/ bundle exec appraisal rails-6 ruby test/unit/aggregate_store_test.rb
>> BUNDLE_GEMFILE=/Users/orabani/invoca/aggregate/gemfiles/rails_6.gemfile bundle exec ruby test/unit/aggregate_store_test.rb
Traceback (most recent call last):
5: from test/unit/aggregate_store_test.rb:3:in `<main>'
4: from test/unit/aggregate_store_test.rb:3:in `require_relative'
3: from /Users/orabani/invoca/aggregate/test/test_helper.rb:6:in `<top (required)>'
2: from /Users/orabani/invoca/aggregate/test/test_helper.rb:6:in `require'
1: from /Users/orabani/invoca/aggregate/lib/aggregate.rb:6:in `<top (required)>'
/Users/orabani/invoca/aggregate/lib/aggregate.rb:6:in `require': cannot load such file -- active_record/define_callbacks (LoadError)
This is happening because the require
d module was removed in Rails 6.
Update: For now we've blocked support for Rails >= 6.1, but we'll need to address this once we get to the point where we'll want/need to support those later versions.
id_or_value.to_i
within Aggregate::ForeignKeyReference#initialize
can cause an empty string given as an id to be stored as 0
. This 0
will then be stored as the aggregate_belongs_to
attribute's ID in serialized storage data. This means that trying to fetch the associated DB record will (most likely always) raise an exception because the record won't be found, which ends up becoming confusing to debug because it's not necessarily clear to the consumer of the gem why 0
is being stored as the ID.
aggregate_belongs_to :user, "User"
my_object.user_id = ""
my_object.save!
my_object.user_id == 0
id_or_value
is not an ActiveRecord::Base
object, we should raise an ArgumentError
if id_or_value
is nil
or an empty stringA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.