Skip to content
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

fix: Allow unsigned_integer to accept any value #15

Closed
wants to merge 1 commit into from

Conversation

KonnorRogers
Copy link

@KonnorRogers KonnorRogers commented Jan 15, 2022

Hi there! Im using @leastbad 's AllFutures gem and was doing some faceted search using AllFutures. I encountered a case where I wanted the max amount for something to be 100_000_000_000 and the minimum amount to be the negative amount.

Since ActiveEntity doesnt really account for :bigint would it be okay to have the max_value of an integer be ::Float::INFINITY like in the Rails bigint type?

https://github.com/rails/rails/blob/83a4fa414bc9e5008825f47857fdd80e85c82033/activemodel/lib/active_model/type/big_integer.rb#L10

Error:

Screen Shot 2022-01-15 at 6 02 16 PM

I can confirm monkey patching ActiveEntity locally fixes the error.

I encountered a case where I wanted the max amount for something to be 100_000_000_000.

Since ActiveEntity doesnt really account for `:bigint` would it be okay to have the `max_value` of an integer be `::Float::INFINITY` like in the Rails bigint type.

https://github.com/rails/rails/blob/83a4fa414bc9e5008825f47857fdd80e85c82033/activemodel/lib/active_model/type/big_integer.rb#L10

Error:
@KonnorRogers
Copy link
Author

Closing. On further investigation, it appears :bigint gets registered as :big_integer.

register(:big_integer, Type::BigInteger, override: false)

Perhaps the name in the registration should also add a :bigint to align with Rails ActiveRecord?

https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column

The type parameter is normally one of the migrations native types, which is one of the following : 
:primary_key, :string, :text, :integer, :bigint, :float, :decimal, :numeric, :datetime, :time, :date, :binary, :blob, :boolean

@jasl
Copy link
Owner

jasl commented Jan 16, 2022

Closing. On further investigation, it appears :bigint gets registered as :big_integer.

register(:big_integer, Type::BigInteger, override: false)

Perhaps the name in the registration should also add a :bigint to align with Rails ActiveRecord?

https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column

The type parameter is normally one of the migrations native types, which is one of the following : 
:primary_key, :string, :text, :integer, :bigint, :float, :decimal, :numeric, :datetime, :time, :date, :binary, :blob, :boolean

big_integer follows https://github.com/rails/rails/blob/83a4fa414bc9e5008825f47857fdd80e85c82033/activemodel/lib/active_model/type.rb#L42-L52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants