On Friday, June 1, 2012 11:11:17 AM UTC-7, Joe Van Dyk wrote:
>
> I'm not sure if this is what you mean by a "primitive type", but I have a 
> postgresql domain like:
>
> CREATE DOMAIN tanga_money AS numeric(19,2)                                 
>                          
>   CONSTRAINT not_negative CHECK ((VALUE >= (0)::numeric));
>
> I use it for prices of things.
>
> ActiveRecord 3.x (not sure if changed in 4.x?), both jdbc and regular:
> 1.9.3p0 :002 > Product.first.normal_price
>  => "8.99" 
> Note that it's a string.
>
> Sequel:
> 1.9.3-p0-perf :011 > DB[:products].order(:id.desc).first[:normal_price]
>  => #<BigDecimal:7fae1bbac748,'0.899E1',18(18)>                           
>                                                                      
>                                                                           
>                           
> 1.9.3-p0-perf :012 > p Product.order(:id.desc).first.normal_price
>  => #<BigDecimal:7fe85243c190,'0.899E1',18(18)>
>
> It's a BigDecimal in Sequel, what I'd expect.
>
> If Sequel and AR shared the same code that detected the types here, it 
> would make it a lot easier to write code that accessed the same database.
>
>
I've mentioned multiple times on rails-core that the way that Sequel does 
this is to use the type OIDs when retrieving the value.  This doesn't 
appear to be a parsing issue, as I assume AR knows how to parse numeric 
columns.  It's that AR doesn't recognize that the column should be parsed 
as numeric, probably because it isn't using the type OIDs.  I see that as a 
different issue than your suggestion to share the parsers for datatypes 
like array, hstore, json, and range.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/Udj7Emv_oUcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to