Issue Details (XML | Word | Printable)

Key: ACTIVERECORD_JDBC-88
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Unassigned
Reporter: Igor Minar
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
activerecord-jdbc

tinyint to boolean conversion fails with mysql jndi pool

Created: 21/Jan/10 04:46 AM   Updated: 23/Feb/10 08:33 PM   Resolved: 23/Feb/10 08:33 PM
Component/s: MySQL
Affects Version/s: 0.9.2
Fix Version/s: 0.9.2

Time Tracking:
Not Specified

Tags:


 Description  « Hide

Recently I upgrade from activerecord 0.9 to 0.9.2 and from rails 2.2.2 to rails 2.3.5 and noticed a regression in the app.

I have a model with a boolean field:

t.boolean  "foo",    :limit => nil,  :default => true, :null => false

in the db it looks like:

`foo` tinyint(1) NOT NULL default '1',

before, when retrieving model with this field, I would get true or false back as the value, but now I get "0" or "1", which breaks many things in my app.

The odd thing is that this happens only when I hook up my app to with the db via a connection pool exposed via jndi. If I connect to the db directly, everything works.

My config:

database.yml:

production:
   adapter: jdbc
   jndi: jdbc/mydb

connection pool config in domain.xml of glassfish:

<jdbc-connection-pool validation-table-name="users" 
    datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" 
    max-pool-size="128" res-type="javax.sql.ConnectionPoolDataSource" name="mydb" ping="true">
  <property name="user" value="myuser" />
  <property name="url" value="jdbc:mysql://mydb:3307/myapp_production?
     autoReconnect=true&amp;relaxAutoCommit=true&amp;useUnicode=true&amp;characterEncoding=utf8" />
  <property name="password" value="xxxxxx" />
</jdbc-connection-pool>


Nick Sieger added a comment - 21/Jan/10 01:45 PM

A data point: does the same behavior occur without a JNDI connection (e.g., put mysql credentials in database.yml)?


Igor Minar added a comment - 21/Jan/10 07:03 PM

No it does not, that's what I meant by "If I connect to the db directly, everything works.".

At first I used the rails console and a new rails environment to connect to the db directly without the pool and I didn't see the issue, then I changed the production environment not to use jndi, but make a direct connection to the db and the app started working properly.


Nick Sieger added a comment - 21/Jan/10 07:07 PM

Whoops, I missed that bit during the first reading, sorry.

Can you try setting adapter to "mysql" instead and see if it helps?


Igor Minar added a comment - 21/Jan/10 09:33 PM

Yeah, that does fix the issue. For some reason in the older AR-JDBC version "jdbc" worked fine. I'll update my config.

It would help if a jndi config example was part of the examples on the wiki.

Thanks!