AR: quoting integer in string : how to fix ?

Tony wrote:

Hello.

I have a table like this :

id : primary key (numeric(9,0) identity for me) name : string value : string rank : integer

Now I insert this record : name = "dummy" val = "12345" rank = 34

I can insert, update and delete it.

If I want to search based on value, I would like to use the so-easy-and-cute find_all_by_val method as in :

find_all_by_val("12345")

But this gives me a SQL request invalid : SELECT * FROM dummy_table WHERE val = 12345

Numbers in string are quoted as integer If I change quote method, I could have SELECT * FROM dummy_table WHERE val = "12345"

But now, I have the same problem with rank :

find_all_by_rank("12345")

gives me SELECT * FROM dummy_table WHERE rank = "12345"

Is there a magic implementation of the quote method in the adapter that could deal with integer and string in the right way ?

Tony

PS : I'm using a Sybase ASE server. I can't put number between quotes like in MySQL requests.

-- Posted via http://www.ruby-forum.com/.

Hi Tony,

Try using find(:all, :conditions => "rank = ?", intString)