Forum: JRuby AR_TO_JDBC_TYPES and custom driver

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bfbdff0f4a3e02b323ae888e62c04e89?d=identicon&s=25 Stefan Norlin (Guest)
on 2008-12-08 17:28
(Received via mailing list)
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 Norlin
526d60de6472502bb570a9df2842b33b?d=identicon&s=25 Nick Sieger (Guest)
on 2008-12-08 20:09
(Received via mailing list)
On Mon, Dec 8, 2008 at 10:28 AM, Stefan Norlin <stenor99@hotmail.com>
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
Bfbdff0f4a3e02b323ae888e62c04e89?d=identicon&s=25 Stefan Norlin (Guest)
on 2008-12-09 11:28
(Received via mailing list)
> > 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
This topic is locked and can not be replied to.