[Rails]
Re: Executing SQL in rails, and the types of the data return
Wiebe Cazemier
halfgaar at gmail.com
Tue Mar 7 13:08:52 GMT 2006
Wiebe Cazemier wrote:
> First, about the types. In a certain model, to get and return the value
> of a boolean function, I have to do:
>
> result = InvestmentProductProvider.find_by_sql("SELECT
> rating.investment_product_provider_has_complete_rating(#{id})").at(0)
> return result.investment_product_provider_has_complete_rating == "t"
>
> Whereas in a unittest, I can/must do:
>
> result = InvestmentProductProviderScore.find_by_sql("SELECT
> rating.provider_score_is_current(#{first_sub_of_first_root_score.id})").at(0)
> assert result.provider_score_is_current
>
> I really don't see the difference between those calls, yet in the latter
> the field in the result is a boolean, like I would expect, but in the
> former, it is a string which contains either "t" or "f". Both
> databasefunctions (postgres) return the type boolean. So what's the
> deal?
About those types again; what exactly happens here? Why is the result in
the first call a string, and in the latter a boolean? (I tested if the
latter is really a boolean, it is. It does not just pass the assert
because any string with charachters in it is true).
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list