Skip to content
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

Invalid SQL for DB2 with limit + offset + order when order refers to a column not in the result set #606

Closed
benissimo opened this issue Dec 8, 2014 · 6 comments
Assignees
Labels

Comments

@benissimo
Copy link

See my comment on b330635
for details.

In brief, that commit introduced a limitation on ordering. Prior to that commit, you could join on another table and sort by the joined table's column(s) even if they weren't included in your result set. With that commit, doing so results in invalid SQL.

@benissimo
Copy link
Author

p.s. I encountered this issue using jruby 1.7.6, activerecord 3.2.21, and activerecord-jdbc-adapter 1.3.13, running the queries against db2 10.5

@kares
Copy link
Member

kares commented Dec 8, 2014

Thanks Ben, having a reproducable test-case or piece of self-explaining AR code that does not work is best.

@kares kares added the db2 label Dec 8, 2014
@benissimo
Copy link
Author

@kares I've created a gist with a spec for the bug here:
https://gist.github.com/benissimo/aabf0bc99a178b1cf47d

Please let me know if you have any questions. Thanks!

@kares
Copy link
Member

kares commented Dec 8, 2014

@benissimo excellent ... thanks (might take me a while to look into it but having that spec will help a lot) !

@kares kares self-assigned this Jan 27, 2015
kares added a commit to kares/activerecord-jdbc-adapter that referenced this issue Jan 27, 2015
…plete (see jruby#606)

added a (previously) failing test-case provided by @benissimo to make sure it's implemented better if/as this gets re-introduced again ...

reverts jruby@b330635 (introduced in 1.3.0)
@kares
Copy link
Member

kares commented Jan 28, 2015

b330635 got reverted to NOT mangle with OVER ( ORDER BY ... ) 0ec8f12 as there was no test-case for the feature, use the test-case provided so that if it's re-introduced it's done in a more consistent way, thx!

@kares kares closed this as completed Jan 28, 2015
kares added a commit that referenced this issue Jan 28, 2015
* 1-3-stable: (31 commits)
  re-build jar (for1.3.14)
  preparing for 1.3.14
  best to still have ruby 1.8 (syntax) compatibility ... as we're building the jar on 1.6.8
  Fixed an undefined exception error in type_to_sql for MySQL
  [travis-ci] rake test_jdbc still can not connect ;(
  print a note when running on AR 4.2 ... as it's not fully supported!
  [derby] support for empty insert statements (e.g. `DbModel.create!`) on AR 4.x
  [db2] revert limit/offset OVER( ORDER BY ) matching as it was not complete (see #606)
  simplify DB2 adapter/visitor internals that handle limit/offset with ordering
  [db2] handle empty INSERT statement (default) VALUES in a way that works on AR 4.x
  tune DB2's tests to align with AR 4.x
  [db2] `select` return value should be the same as core AR (Array on 3.2) (fixes #607)
  improve missing 'postgres' role message
  [mysql] backport bulk change & schema-creation to be compatible with AR 4.x versions
  avoid potential NPE failures when extracting SQL array values using JDBC
  handle possible null values while extracting from XML columns (NPE fix for #615)
  DateTime columns are returned always as nil values. The "rescue nil" in the module ActiveRecord::ConnectionAdapters::Jdbc::TypeCast is hiding the error.
  [travis-ci] no -Xcext.enabled=false and no need to disable invoke-dynamic on 1.7.8
  make sure we spin `ruby` that works with JRuby 9K
  [oracle] do not override primary= within column methods on AR 4.2
  ...
@benissimo
Copy link
Author

@kares Thanks for following up on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants