Issue #176 - fix ms sql 2000 - wrong primary key where nonstandard table name is used #177

Merged
merged 5 commits into from Jul 28, 2012

Projects

None yet

3 participants

@gregors
Contributor
gregors commented Feb 29, 2012

Issue #176 - fix ms sql 2000 - wrong primary key where nonstandard table name is used.

I added a failing test then added passing code. I've only tested against rails3.2.1. For some reason I can't seem to install older versions of rails properly at the moment but I did add code which should work under ActiveRecord 2.3.0 if someone would test to be sure.

@jrubyci
jrubyci commented Feb 29, 2012

Did you try running "rake appraisal:install" to install gems and "rake appraisal:railsX" to run?

On Feb 29, 2012, at 0:52, gregory ostermayrreply@reply.github.com wrote:

Issue #176 - fix ms sql 2000 - wrong primary key where nonstandard table name is used.

I added a failing test then added passing code. I've only tested against rails3.2.1. For some reason I can't seem to install older versions of rails properly at the moment but I did add code which should work under ActiveRecord 2.3.0 if someone would test to be sure.

You can merge this Pull Request by running:

git pull https://github.com/gregors/activerecord-jdbc-adapter limit_with_alt_primary_key

Or you can view, comment on it, or merge it online at:

#177

-- Commit Summary --

  • attempt to add failing test
  • add failing test
  • add get primary key helper
  • add logic to pull back primary key using table name via ActiveRecord
  • add rails 2 compatibility

-- File Changes --

M lib/arjdbc/mssql/limit_helpers.rb (24)
M test/mssql_limit_offset_test.rb (30)

-- Patch Links --

https://github.com/jruby/activerecord-jdbc-adapter/pull/177.patch
https://github.com/jruby/activerecord-jdbc-adapter/pull/177.diff


Reply to this email directly or view it on GitHub:
#177

@gregors
Contributor
gregors commented Mar 1, 2012

I have and get the following output - any suggestions using jruby 1.6.7 both with --1.8 and --1.9

$ rake appraisal:install

bundle install --gemfile=C:/Documents and Settings/gregory.ostermayr/My Documents/activerecord-jdbc-adapter/gemfiles/rails23.gemfile
C:/Documents not found

@nicksieger
Member

Bummer -- the old "filename with spaces" strikes again. Might need to patch the appraisal gem...

@gregors
Contributor
gregors commented Mar 1, 2012

Duh - I totally didn't understand what I was seeing. I'll move it to a path without spaces and try it tonight. Thanks!

@gregors
Contributor
gregors commented Mar 2, 2012

I moved the repo to a place without spaces in the path and did rake appraisal:install which installed all the gems, however, when I tried to run the actual test it still pukes. I'm assuming it's some kind of windows weirdness I even uninstalled jruby 1.6.7 and tried 1.6.6 both 1.8 and 1.9 no dice. If I try it from on a mac it works fine - but I don't have access to the windows database I'm using. So.....

I ran each of the tests individually by manually changing the projects main Gemfile and specifying precisely which activerecord I was using and this worked as I could see which activerecord was being run in the tests.

I reverted the repo back before I touched anything to get a baseline these are the results:
2.3.14 = lots of errors
3.0.11 = 1 failed test (sys.views test - which I don't think can pass on sql server 2000)
3.1.3 = same as 2.3.14
3.2.1 = same as 3.0.11

Now this is somewhat strange the test with 'lots of errors' all had to do with "ROW_NUMBER is not a recognized function name" which makes sense since yes that didn't exist in SQL Server 2000 - but why does that work in 3.0.11? How does it know? I might look into that later.

Anyway, I apply my changes add my test:
2.3.14 = lots of errors
3.0.11 = ( 1 failed sys.view test)
3.1.3 = same as 2.3.14
3.2.1 = same as 3.0.11

So my fix for this issue hasn't caused any issues which were not already present and adds the ability to use legacy nonstandard primary key ids. The only thing I don't like about my solution is the possible issues if you have an obscene amount of models. A better solution would probably better to pass such information down to the helper from a higher level. I may revisit that in the future but presently for my needs it works.

Is there anything else I need to provide for these changes to be acceptable?

@gregors
Contributor
gregors commented Mar 25, 2012

Any feedback on this would be appreciated.

@nicksieger nicksieger merged commit 889f8ed into jruby:master Jul 28, 2012
@nicksieger
Member

I went ahead and merged it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment