AR_TO_JDBC_TYPES and custom driver


#1

Hi,

I have added my own custom JDBC driver to provide access to
legacy data. This works fine, but since the available SQL data
types in that database deviates from standards I had to “hack”
jdbc_adapter.rb and modify the constant AR_TO_JDBC_TYPES.

(For example there is no “varchar”, but only “char” data type)

From my (sometimes limited) understanding it would be better
if this information was not handled in a constant which cannot
be overridden in my application. Am I missing something here?
Is there some other (better) way to do this?

The other related thing is the jdbc_adapter_spec.rb file where
I need to add a “require” for my driver. Is there another way to
“inject” it without having to modify a system file?
Regards,
Stefan N.


#2

On Mon, Dec 8, 2008 at 10:28 AM, Stefan N. removed_email_address@domain.invalid
wrote:

if this information was not handled in a constant which cannot
be overridden in my application. Am I missing something here?
Is there some other (better) way to do this?

I agree, it’s not the ideal way to maintain these types, but it’s got
us this far.

The other related thing is the jdbc_adapter_spec.rb file where
I need to add a “require” for my driver. Is there another way to
“inject” it without having to modify a system file?

It’s just Ruby, so there’s nothing preventing you from keeping your
local driver modifications outside of activerecord-jdbc and loading
them at the same time activerecord-jdbc loads. In the case off adapter
specs, you probably need to load it before, in the case of the types,
you can write code to modifiy the hash in the constant afterwards.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

Is there some other (better) way to do this?> > I agree, it’s not the ideal way to maintain these types, but it’s got> us this far.

Very far indeed… thank you so much for effort and dedication!
(And very quick response on this matter)

The other related thing is the jdbc_adapter_spec.rb file where> > I need to add a “require” for my driver. Is there another way to> > “inject” it without having to modify a system file?> > It’s just Ruby, so there’s nothing preventing you from keeping your> local driver modifications outside of activerecord-jdbc and loading> them at the same time activerecord-jdbc loads. In the case off adapter> specs, you probably need to load it before, in the case of the types,> you can write code to modifiy the hash in the constant afterwards.

Ok. I now modify the “constant” in an initializer and require my driver
(located in “lib”) pretty early in environment.rb and everything works
without any extra hacks.

One more: Thanks!

Regards,
Stefan