AR: quoting integer in string : how to fix ?

Tony wrote:


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
find_all_by_val method as in :


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 :


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 ?


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

Posted via

Hi Tony,

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