Possible Duplicate:
Integer out of range on Postgres DB
When my code tries to insert big numbers such as 100001857905525
into a database on heroku, I get the error:
ActiveRecord::StatementInvalid (PGError: ERROR: integer out of range )
The column has been defined as an integer. I use a sqlite3 database. My code is deployed to heroku.
It works fine when I run on localhost. But I get the above error only when I run the code on heroku. Perhaps I can solve the issue by defining the column as a long integer or a double. How do I do this in Ruby/Rails ?
function checkIfArrayIsUnique(myArray) { for (var i = 0; i < myArray. length; i++) { for (var j = 0; j < myArray. length; j++) { if (i != j) { if (myArray[i] == myArray[j]) { return true; // means there are duplicate values } } } } return false; // means there are no duplicate values. }
The meaning of "sets do not allow duplicate values" is that when you add a duplicate to a set, the duplicate is ignored, and the set remains unchanged. This does not lead to compile or runtime errors: duplicates are silently ignored.
One of the most common ways to find duplicates is by using the brute force method, which compares each element of the array to every other element. This solution has the time complexity of O(n^2) and only exists for academic purposes.
in your migration, you could try this:
t.integer :uid, :limit => 8
which will produce a 64-bit integer column.
(Just integer
with no limit
specified will allow, according to the PostgreSQL docs, up to 10 digits.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With