-
Notifications
You must be signed in to change notification settings - Fork 122
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
Support array types in typed_store
compiler
#1924
Conversation
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.
Thanks this looks like a good change. I have a few inline comments.
3b5f87f
to
71c3348
Compare
type = if field.array | ||
# `null: false` applies to the array itself, not the elements, which are always nilable. | ||
# https://github.com/byroot/activerecord-typedstore/blob/2f3fb98/spec/support/models.rb#L46C34-L46C45 | ||
# https://github.com/byroot/activerecord-typedstore/blob/2f3fb98/spec/active_record/typed_store_spec.rb#L854-L857 |
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.
😮
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.
Thanks for quickly fixing that one!
I'm not seeing the tests though, did you miss a commit?
71c3348
to
ffb51e0
Compare
@ipvalverde Nice catch. I lost it somehow, but was able to revive it back from my editor's local history. Can you have a look and review? Cheers |
ffb51e0
to
30c373e
Compare
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.
I ran these changes on core (cherry-picked in isolation, on top of the https://github.com/Shopify/shopify/commit/36d05ee84d0084e452f644d2b07e01eb54795a8a |
Motivation
Closes #1910
Implementation
Decide to refactor the
#type_for
method to take the wholeActiveRecord::TypedStore::Field
object, instead of just itstype_sym
, because I would have needed to also pass infield.array
. This way it can just access what it needs.This has the nice benefit of moving the
if field.null
responsibility out of thedecorate
method.Tests
I added tests for both
array: true, null: true
andarray: true, null: false
. I didn't assert the type of all the methods (since they're mostly the same), just the getter/setter (just like how other tests check them).