Hi, I''m using postgresql, using the numeric datatype to store facebook uid''s. Rails converts them to BigDecimal. BigDecimal.new(''3.99'').kind_of?(Integer) returns false. That''s used in a few places in the code. Should I not use that datatype to store facebook uid''s?
decimal is meant for Floats. You''ll want to use ''bigint''. In a Rails migration, you can use :integer with :limit => 8 Brandon On Mar 6, 2009, at 12:20 AM, Joe Van Dyk wrote:> Hi, > > I''m using postgresql, using the numeric datatype to store facebook > uid''s. Rails converts them to BigDecimal. > > BigDecimal.new(''3.99'').kind_of?(Integer) returns false. That''s used > in a few places in the code. > > Should I not use that datatype to store facebook uid''s? > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090306/79392e94/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090306/79392e94/attachment.bin>
You may want to increase your integer size to 20 - i.e., :integer, :limit=>20 When I dropped my Facebook app into Bebo, I kept losing one of my users - his ID was 8xxxyyyzzz but the database was always recording it as 2147483647. Took me a while to figure out that number is 2**31 - 1 and that my user ID was rolling over silently. And this was with the default MySQL integer size of 11. The app worked fine before in Facebook because none of the FB ID''s were long enough and didn''t cause a silent overflow. -- Bosco On Fri, Mar 6, 2009 at 6:33 AM, Brandon Keepers <brandon at opensoul.org>wrote:> decimal is meant for Floats. You''ll want to use ''bigint''. In a Rails > migration, you can use :integer with :limit => 8 > Brandon > > > > On Mar 6, 2009, at 12:20 AM, Joe Van Dyk wrote: > > Hi, > > I''m using postgresql, using the numeric datatype to store facebook > uid''s. Rails converts them to BigDecimal. > > BigDecimal.new(''3.99'').kind_of?(Integer) returns false. That''s used > in a few places in the code. > > Should I not use that datatype to store facebook uid''s? > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090306/f9561887/attachment.html>
That makes sense, thanks. On Fri, Mar 6, 2009 at 6:33 AM, Brandon Keepers <brandon at opensoul.org> wrote:> decimal is meant for Floats. ?You''ll want to use ''bigint''. ?In a Rails > migration, you can use :integer with :limit => 8 > Brandon > > > On Mar 6, 2009, at 12:20 AM, Joe Van Dyk wrote: > > Hi, > > I''m using postgresql, using the numeric datatype to store facebook > uid''s. ?Rails converts them to BigDecimal. > > BigDecimal.new(''3.99'').kind_of?(Integer) returns false. ?That''s used > in a few places in the code. > > Should I not use that datatype to store facebook uid''s? > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk > >
8 is actually the max. Active Record maps 8 to "bigint", which is an 8 byte integer, (up to 9223372036854775807 signed). Brandon On Mar 6, 2009, at 1:12 PM, Bosco So wrote:> You may want to increase your integer size to 20 - > i.e., :integer, :limit=>20 > > When I dropped my Facebook app into Bebo, I kept losing one of my > users - his ID was 8xxxyyyzzz but the database was always recording > it as 2147483647. Took me a while to figure out that number is 2**31 > - 1 and that my user ID was rolling over silently. And this was with > the default MySQL integer size of 11. > > The app worked fine before in Facebook because none of the FB ID''s > were long enough and didn''t cause a silent overflow. > > -- Bosco > > > On Fri, Mar 6, 2009 at 6:33 AM, Brandon Keepers > <brandon at opensoul.org> wrote: > decimal is meant for Floats. You''ll want to use ''bigint''. In a > Rails migration, you can use :integer with :limit => 8 > > Brandon > > > > On Mar 6, 2009, at 12:20 AM, Joe Van Dyk wrote: > >> Hi, >> >> I''m using postgresql, using the numeric datatype to store facebook >> uid''s. Rails converts them to BigDecimal. >> >> BigDecimal.new(''3.99'').kind_of?(Integer) returns false. That''s used >> in a few places in the code. >> >> Should I not use that datatype to store facebook uid''s? > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090306/9709d6aa/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090306/9709d6aa/attachment.bin>
The :limit argument in the SQL world is the number of decimal digits (including sign) you want the DB to allocate to your field. 8 bytes require, as you point out, 20 decimal digits to represent fully. -- B On Fri, Mar 6, 2009 at 11:21 AM, Brandon Keepers <brandon at opensoul.org>wrote:> 8 is actually the max. Active Record maps 8 to "bigint", which is an 8 > byte integer, (up to 9223372036854775807 signed). > > Brandon > > On Mar 6, 2009, at 1:12 PM, Bosco So wrote: > > You may want to increase your integer size to 20 - i.e., :integer, > :limit=>20 > > When I dropped my Facebook app into Bebo, I kept losing one of my users - > his ID was 8xxxyyyzzz but the database was always recording it as > 2147483647. Took me a while to figure out that number is 2**31 - 1 and that > my user ID was rolling over silently. And this was with the default MySQL > integer size of 11. > > The app worked fine before in Facebook because none of the FB ID''s were > long enough and didn''t cause a silent overflow. > > -- Bosco > > > On Fri, Mar 6, 2009 at 6:33 AM, Brandon Keepers <brandon at opensoul.org>wrote: > >> decimal is meant for Floats. You''ll want to use ''bigint''. In a Rails >> migration, you can use :integer with :limit => 8 >> Brandon >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090306/53d00840/attachment.html>
Great, thanks all! On Fri, Mar 6, 2009 at 11:33 AM, Bosco So <rubymeetup at boscoso.com> wrote:> The :limit argument in the SQL world is the number of decimal digits > (including sign) you want the DB to allocate to your field. 8 bytes require, > as you point out, 20 decimal digits to represent fully. > > -- B > > > On Fri, Mar 6, 2009 at 11:21 AM, Brandon Keepers <brandon at opensoul.org> > wrote: >> >> 8 is actually the max. ?Active Record maps 8 to "bigint", which is an 8 >> byte integer, (up to?9223372036854775807 signed). >> Brandon >> On Mar 6, 2009, at 1:12 PM, Bosco So wrote: >> >> You may want to increase your integer size to 20 - i.e., :integer, >> :limit=>20 >> >> When I dropped my Facebook app into Bebo, I kept losing one of my users - >> his ID was 8xxxyyyzzz but the database was always recording it as >> 2147483647. Took me a while to figure out that number is 2**31 - 1 and that >> my user ID was rolling over silently. And this was with the default MySQL >> integer size of 11. >> >> The app worked fine before in Facebook because none of the FB ID''s were >> long enough and didn''t cause a silent overflow. >> >> -- Bosco >> >> >> On Fri, Mar 6, 2009 at 6:33 AM, Brandon Keepers <brandon at opensoul.org> >> wrote: >>> >>> decimal is meant for Floats. ?You''ll want to use ''bigint''. ?In a Rails >>> migration, you can use :integer with :limit => 8 >>> Brandon > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk > >