-
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
Issue when using joins with distinct #590
Comments
Thanks Sam, I unfortunately do not have the time to look into MS-SQL but I'm happy to help out when someone does ... please consider looking into it on your own. We're low on (SQLServer) maintainers, there are several issues open. |
Thanks @kares for the reply. I'd like to look into this myself, however i don't really know where to start. Could you give me some hints maybe? I need a starting point in the code, as i'm very unfamiliar with it as of now. |
sure, here you go:
|
@kares I investigated on this and i think the cause of the problem is on this line:
The problem is that the order by sql looks like this
and the line of code i referenced is supposed to change it to this
However, the REGEX used does not contain
to this
solves the problem. I'm not sure if this is a sufficient solution as i'm having a few troubles running the test suite (several tests are failing due to problems that are unrelated to this change). Do you want me to create a pull request anyways? |
@samu sure, if there are no new failures introduced and you can cover your case with a test I'll merge it. |
@kares do i understand this correctly that the tests for mssql are only being run locally and not in CI? |
@samu yes, you do not worry about travis-ci failures unless you touch some shared (non-specific) parts ... |
We have a basic user to roles mapping with a roles_users table in between.
User.joins(:roles_users).distinct.where(id: 1).first
would cause the error
ActiveRecord::JDBCError: The multi-part identifier "users.id" could not be bound
while
User.joins(:roles_users).where(id: 1).first
works fine.
We are using an MSSQL Database, therefore we use the
activerecord-jdbcmssql-adapter
(newest version). Here are the two sql statements that are being generated:cruby:
jruby:
We have tried it with different jruby versions:
jruby-1.7.9
andjruby-1.7.13
onRails 4.1.1
andRails 4.1.6
.you can support MS-SQL fixes at BountySource
The text was updated successfully, but these errors were encountered: