Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we define large integers? [duplicate]

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 ?

like image 307
geeky_monster Avatar asked Jun 15 '11 02:06

geeky_monster


People also ask

How do you find duplicate values in an array?

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. }

Why set does not allow 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.

How do you find the duplicate number on a given integer array in Java?

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.


1 Answers

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.)

like image 141
David Avatar answered Sep 18 '22 05:09

David