# Find\_by\_sql returns Strings! How to I type cast?

**URL:** <https://www.ruby-forum.com/t/find-by-sql-returns-strings-how-to-i-type-cast/164878>\
**Category:** Rails\
**Created:** [April 7, 2009, 12:35am UTC](https://www.ruby-forum.com/t/find-by-sql-returns-strings-how-to-i-type-cast/164878 "2009-04-07T00:35:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [April 7, 2009, 12:35am UTC](https://www.ruby-forum.com/t/find-by-sql-returns-strings-how-to-i-type-cast/164878/1 "2009-04-07T00:35:43Z")

</div>

When i run find\_by\_sql the extra fields not in the Model are returned  
as Strings.

What is the correct way to convert all the extra fields to their correct  
type? Is there a way to somehow define these extra fields in the Model  
class to ensure they will always be returned correctly? Or is their a  
better method.

I will be using find\_by\_sql a lot so a clean solution would be good.  
(I am using Mysql)s

Thanks in advance  
Chri
