Forum: JRuby Question on Jruby 1.2 and Rails 2.3.2

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.
C10ea39c3fbe535ea1bf1d4eb4617900?d=identicon&s=25 Jay McGaffigan (Guest)
on 2009-04-25 21:26
(Received via mailing list)
I believe I saw arun mention this once but I am using jruby 1.2 adn
2.3.2 with mysql (and latest AR jdbcmysql adapter).  When I do a rake
db:create:all.  I only get the test and production dbs to be created
... the development one doesn't.  Has anyone done any investigation
into this ?  (I'm game to start investigating but wanted to find out
if anything's been done)

Jay

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-25 22:52
(Received via mailing list)
Jay McGaffigan wrote:
> I believe I saw arun mention this once but I am using jruby 1.2 adn
> 2.3.2 with mysql (and latest AR jdbcmysql adapter).  When I do a rake
> db:create:all.  I only get the test and production dbs to be created
> ... the development one doesn't.  Has anyone done any investigation
> into this ?  (I'm game to start investigating but wanted to find out
> if anything's been done)

Weird, I had not heard about that. Do you have a link to Arun's mention?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C10ea39c3fbe535ea1bf1d4eb4617900?d=identicon&s=25 Jay McGaffigan (Guest)
on 2009-04-26 04:18
(Received via mailing list)
http://jira.codehaus.org/browse/JRUBY-3502

He even filed a bug.

As I said I'm happy to help investigate :)

Jay

On Sat, Apr 25, 2009 at 4:51 PM, Charles Oliver Nutter
<charles.nutter@sun.com> wrote:
>
> - Charlie
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-26 06:55
(Received via mailing list)
Hey, knock yourself out :) It's probably not a hard one to track down.

Jay McGaffigan wrote:
>> Jay McGaffigan wrote:
>> ---------------------------------------------------------------------
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C10ea39c3fbe535ea1bf1d4eb4617900?d=identicon&s=25 Jay McGaffigan (Guest)
on 2009-04-28 01:42
(Received via mailing list)
Well I'm making progress.  But it's weird.

When running rake db:create:all it appears that the jdbc adapter stuff
isn't being loaded until after the create:all stuff has started to be
processed.

So in the jdbc.rake file we alias the AR create_database method.  But
this aliasing isn't happening until we are halfway through the
create_database call in the origianl database.rake on the
ActiveRecord::establish_connection call.    Which is weird.

What this means is that in a db:create:all call the first entry in the
config hash (which contains the contents of the database.yml file)
always fails (in our case it just happens to be the name of the
development hash settings).

I'm just not sure yet why this stuff isn't loaded sooner.  I'll play
with more things tonight to see if I can find out why it's not being
loaded sooner.

Jay


On Sun, Apr 26, 2009 at 12:54 AM, Charles Oliver Nutter
<charles.nutter@sun.com> wrote:
>> Jay
>>>> into this ?  (I'm game to start investigating but wanted to find out
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-28 04:27
(Received via mailing list)
Jay McGaffigan wrote:
> What this means is that in a db:create:all call the first entry in the
> config hash (which contains the contents of the database.yml file)
> always fails (in our case it just happens to be the name of the
> development hash settings).
>
> I'm just not sure yet why this stuff isn't loaded sooner.  I'll play
> with more things tonight to see if I can find out why it's not being
> loaded sooner.

Loaded sooner, or you could investigate if it's a Hash default proc or
something and in that proc we're supposed to be reinserting everything.
Shot in the dark...but it sounds like you're on the right track.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C10ea39c3fbe535ea1bf1d4eb4617900?d=identicon&s=25 Jay McGaffigan (Guest)
on 2009-04-29 02:39
(Received via mailing list)
So after much digging it appears that the JDBC adapter stuff just
isn't loading until too late in a db:create call.

The Kenai wiki points to putting the following code into your
environment.rb call
if RUBY_PLATFORM =~ /java/
  require 'rubygems'
  gem 'activerecord-jdbc-adapter'
  require 'jdbc_adapter'
end


However that doesn't work as db:create:all in 2.3.2 doesn't load
environment.rb

My solution?

For now I put it in the database.yml file in a ruby tag:

<%
if RUBY_PLATFORM =~ /java/
  require 'rubygems'
  gem 'activerecord-jdbc-adapter'
  require 'jdbc_adapter'
end
%>

This force loads the JDBC adapter causing the proper aliasing to happen.

This problem exists for:
rake db:create:all
and rake db:create

From tracing through the code it does look like the problem exists for
any jdbc supported database.

It would be nicer to have it implicitly load sooner.

I am off to test and make sure this "workaround" doesn't negatively
affect other rake tasks
Jay

On Mon, Apr 27, 2009 at 10:26 PM, Charles Oliver Nutter
<charles.nutter@sun.com> wrote:
>
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-29 02:54
(Received via mailing list)
Jay McGaffigan wrote:
> However that doesn't work as db:create:all in 2.3.2 doesn't load environment.rb

Ah-ha. How about boot.rb? Or something boot.rb loads? Maybe plugin init
or something?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C10ea39c3fbe535ea1bf1d4eb4617900?d=identicon&s=25 Jay McGaffigan (Guest)
on 2009-04-29 03:40
(Received via mailing list)
boot.rb seems to work too.
I've always shied away from boot.rb but it makes sense that it would
be good to put it there.

Think this belongs on the wiki?

Jay

On Tue, Apr 28, 2009 at 8:53 PM, Charles Oliver Nutter
<charles.nutter@sun.com> wrote:
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-29 03:55
(Received via mailing list)
I feel like we're doing it wrong...there must be a correct way according
to Rails folks to get our logic bootstrapped for purposes of db
migration. Obviously environment.rb isn't it and boot.rb doesn't seem to
be either.

Jay McGaffigan wrote:
>> Jay McGaffigan wrote:
>>   http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C10ea39c3fbe535ea1bf1d4eb4617900?d=identicon&s=25 Jay McGaffigan (Guest)
on 2009-04-29 04:52
(Received via mailing list)
From looking at the code tho Rails call to establish_connection causes
rails/AR to go looking for connection adapters.

On a rake db:create that call doesn't happen until halfway through the
create_database call... it's at this point that the JDBC AR adapter
stuff does it's magic of aliasing the create_database call.

It would seem to me a BETTER solution would be for the rails team to
accept a patch to make create_database (in the database.rake file) be
able to discover the connection adapters sooner.

I mean at this point doesn't the JDBC stuff deserve "first class"
citizenship in there?

:)

Jay


On Tue, Apr 28, 2009 at 9:48 PM, Charles Oliver Nutter
<charles.nutter@sun.com> wrote:
>> Think this belongs on the wiki?
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-04-29 05:07
(Received via mailing list)
We can probably make that case; they've included other fixes of ours, so
if there's a patch to be submitted I bet they'd accept it.

Jay McGaffigan wrote:
>
>> I feel like we're doing it wrong...there must be a correct way according to
>>> Jay
>>>> - Charlie
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.