New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assign next_sequence_id automatically before put/save #28
Assign next_sequence_id automatically before put/save #28
Conversation
expect(alice.persisted?).to be true | ||
expect(alice.id).to eq model.current_sequence_id | ||
expect(alice.name).to eq "Alice" | ||
expect(alice.class.name).to match /User::ShardFor/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
@@ -0,0 +1,47 @@ | |||
describe ActiveRecord::Sharding::Facade do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockLength: Block has too many lines. [37/25]
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
@@ -0,0 +1,22 @@ | |||
require "active_support/concern" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
Thank you propose. This module use My module policy is not hacked Rails. so, Exported gem. It gem user is must consider this when implement hooks for models. |
I understand and thank you for your good idea! |
When using activerecord-sharding, it is necessary to add following code snippet to our active record model classes.
before_put
is from ActiveRecord::Sharding::Model,next_sequence_id
is from ActiveRecord::Sharding::Sequencer.Now, when I use activerecord-sharding, I always include both extensions into my models.
So, I propose to define a unified module, ActiveRecord::Sharding::Facade.