-
Notifications
You must be signed in to change notification settings - Fork 388
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v1.2.2 does not support rails 3.2 explain feature #159
Comments
Thanks, I didn't know about this yet. Patches appreciated from anyone for adding this feature. |
Hope someone adds this soon! For now i've just monkey patched over it in an initializer, so I can keep working: module ActiveRecord::ConnectionAdapters
class JdbcAdapter < AbstractAdapter
def explain(*args)
# Do nothing :'(
end
end
end |
How about this: module ActiveRecord::ConnectionAdapters
class JdbcAdapter < AbstractAdapter
def explain(query, *binds)
ActiveRecord::Base.connection.execute("EXPLAIN #{query}", 'EXPLAIN', binds)
end
end
end |
@donv that might work as an interim solution for some RDBMSes but unfortunately not for me as i'm on SQL Server :P |
@boxofrad thanks - that let me progress, now things run and my couple of tests pass :) |
anyone got this working guys ? |
I've had it on my "to look into list" for a while to see if I could contribute something, but I just haven't made the time to go through it long enough to understand what's going on (with the hope that it could call back into Rails). It seems to me ar-jdbc-adapter ought to be able to reuse the SQL generated from the AR adapters for each of the DBs, but pass it through the jdbc interface instead. |
lifted this code from the mysql2 gem and modified it to work in the JDBC gem. I've done testing under JRuby 1.6.7.2 with MySQL 5.1 and 5.5 with no issues. Github issue URL: jruby#159
Created pull request (#206) to patch this. I've tested under JRuby 1.6.7.2 with MySQL 5.1 and 5.5 with no issues. I took the code that implements explain support in the mysql2 gem and slightly modified it to work here. I'm not happy with the block copying of the PrettyPrint class, but I couldn't figure out a way to leverage the code without doing that. |
If this approach is acceptable to the maintainers I will be glad to implement explain support for SQLite and PostgreSQL as well. |
I would also be interested in a solution to this for SQL Server, I just got hit by the issue :) |
undefined method `explain' for #ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x521e980f Is there a fix for postgres as well?? |
@vysakh0: Just encountered the same problem myself. |
So apparently @cturner's patch works just fine when copypasta'd right into the PostgreSQL JDBC driver as well... Any objections to extracting his fix into a mixin and sharing it between the MySQL and PostgreSQL drivers? |
A pull request which does so would certainly be welcome.
|
Noted. Thanks! On Friday, January 4, 2013 at 3:41 PM, Anthony Juckel wrote:
|
Good catch sir. I wasn't aware that Postgres had the same syntax and output. Are you going to convert this into a mixin or would you like me to work on it? On Jan 4, 2013, at 15:41, Evan David Light notifications@github.com wrote:
|
I started. Struggling with the LOAD_PATH when requiring the mixin. On Friday, January 4, 2013, Chris Turner wrote:
Evan Light |
Feel free to just throw the mixin into a shared file (like the jdbc adapter |
Deal. On Friday, January 4, 2013, Anthony Juckel wrote:
Evan Light |
on master explain for mysql/postgres and sqlite3 |
Just hit this trying to a Model.all using the derby ar jdbc adapter. Is there a more generic fix? |
@superchris unfortunately not as some DBs such as Derby or DB2 do not support simple "user-friendly" EXPLAIN ... |
Sure, but it seems like there should be some way to stub this out with a no-op for databases that don't support this feature (or don't support it in an easily usable way) |
Disabling in in the app configuration isn't an option for you? On Saturday, January 19, 2013 at 4:17 PM, Chris Nelson wrote:
|
hit the issue again on jruby1.7.2, rails 3.2.11, activerecord-jdbc-adapter 1.2.8 on MSSQL (sqlserver) |
@amazon123 I don't know if it got fixed for SQL Server, so can't help with that problem, but I wanted to let you know there have been 2 more security releases to Rails since 3.2.11, in case you weren't aware. See: Fixed in Rails 3.2.12: JSON Gem, fixed the same time as the above two: Fixed in 3.2.13: |
When trying to use the new rails 3.2 explain feature (http://weblog.rubyonrails.org/2011/12/6/what-s-new-in-edge-rails-explain) I get the following error:
The text was updated successfully, but these errors were encountered: