Though password with only digits is not secure, Oracle database does support numeric passwords. Suppose we have Oracle database account named "test" with a legal password "123". Configure development mode as following:
-+-+-+-+-+-+- database.yml +-+-+-+-+-+-
development:
adapter: oracle
database: localhost/XE
username: test
password: 123
This will lead an error as following when we run "rake db:migrate"
-+-+-+-+-+-+- error message +-+-+-+-+-+-
rake aborted!
wrong argument type Fixnum (expected String)
This error happens because ActiveRecord doesn't convert password "123" from numeric to string when reading account information from database.yml. The Ruby-Oci8 driver checks the account parameters' type before connecting to the server. You can find the corresponding codes at Ruby-Oci8 driver's file env.c. Following is the code snippet.
-+-+-+-+-+-+- ruby-oci8-1.0.0.3-rc3/ext/oci8/env.c +-+-+-+-+-+-
static VALUE oci8_logon(VALUE self, VALUE username, VALUE password, VALUE dbname)
......
Get_String(username, u);
Get_String(password, p);
Get_String(dbname, d);
......
The function "Get_String" checks the data type of username, password and dbname. If those parameters' type isn't string, a type error will be raised.
The attached patch with a very tiny modification fixes the problem and make the numeric password workable with Oracle adapter.