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
argument out of range for datetime fields on linux (similar to issue #55) #58
Comments
update. i uninstalled my gem compiled against freetds 0.91 (my new /usr/local) and installed the gem again using my debian freetds package 0.82-4 and it seems to work now. i removed my existing freetds.conf and even tried setting dates prior to 1970 all seems fine now. i guess i am confused about whether with sqlserver 2000 i should be trying to use freetds 0.91 (it seems like that is what the docs urge you to do). what am i missing by using 0.82? i looked through freetds changelog for 0.91, but it is raw commits so a bit hard to follow. really just looking for any major gotchas or other bugaboos i should be aware of. thanks again for all your hard work on this. |
ps since i have an older legacy stack, any advice about config for utf8 and tds ver would be appreciated. |
Maybe it is just me, but there seems to be a ton of wild information and some of it contracting that makes your support request really confusing to follow along. Let me start off with some basics. First, your issue is most likely related to a simple issue with how TinyTDS parses date/time structures. The previous ticket #55 related to windows because the C code we have written ties to be compatibility to older version of Ruby and in some cases specific platforms like Windows in what the native Ruby C types will hold for DateTime/Time classes in ruby core. This is compound too when you consider 32/64 bit version. It is why this test looks so crazy. https://github.com/rails-sqlserver/tiny_tds/blob/master/test/schema_test.rb#L41 Now, your issue is not likely directly related to this one. There are some cases where you will see "out of range" errors. Because of a configuration problem. FreeTDS has this crazy notion of http://www.freetds.org/userguide/config.htm TL;DR is that these have nothing to do with So... looking thru your comments I am not getting what you have done, you say you have used both 0.91 and 0.82-4 in the same sentence. Both should work fine, tho 0.91 is recommended. It allows us to use :host/:port correctly and I have bug fixes in 0.91 that allows us to work with azure too. About your last questions, I use TinyTDS with a legacy stack too. Should be just fine. As the docs say, I test in ton everything from 2000 to Azure. If you have your datatypes on SQL Server set to some national/unicode type (like nvarchar) and you have FreeTDS compiled with libiconv and you do not trump our default UTF8 encoding, then you should get good results. Did you read the notes I made about tis version in ""FreeTDS Compatibility & Configuration" in the README? |
You could also have a problem in your distribution of FreeTDS, I have no idea what 0.82-4 is. To give yourself a little more to go on, you can always run the tests. Our README covers how simple it is get the test running using a local only version of FreeTDS and libiconv. Basically a rake command and all is done for you. So read the "Development & Testing" section. That will download the released FreeTDS 0.91, compile and run the tests. We even allow you to test the official patched level of 0.82 too using the TINYTDS_FREETDS_082 env var. https://github.com/rails-sqlserver/tiny_tds/blob/master/tasks/ports.rake#L9 |
hmmm. i thought i was being clear. if not, then i apologize. i am reporting what appears to be either a bug or a configuration issue on my end. to clarify how i got the error:
will take a look at running test and your other suggestions. |
Tho it should not make a difference, can you remove |
i read through all of the relevant pages from freetds.org, activerecord-sqlserver-adapter github pages, and the various pages on your github. i paid partcular attention to your page which is why i started by compiling 0.91 because it seems to indicate that that is the current preferred version and we will be upgrading to rails3 at some point (but not that soon). i tried this install twice. once with freetds 0.91 -- no joy. and now with 0.82 which does seem to work. i would like to use the more recent 0.91 code. some questions:
[global] is this the only place i can set tds version with tiny_tds? i get it that if using the new 0.91 i should set tds ver to 7.1 but with the older version 0.82 is is 8.0. i will play around with the 0.91 with freetds.conf. so, i have tried tiny_tds with two different versions and had issues with 0.91. |
A |
ok will give it another whirl and post back later...gg |
hey, haven't forgotten about this. got hung up at work. i should be able to try later tonight....gg |
ok. i recompiled freetds 0.91 two different times and reinstalled the gem with the --with-freetds-dir option pointint to my /usr/local/freetds/0.91 install. i removed the --enable-msdblib first. same result. the second time i also remove the ---with-tdsver also same. here is the stack trace: ActiveRecord::StatementInvalid: ArgumentError: argument out of range: SELECT * FROM [practitioner] WHERE ([practitioner].[userkey] = 538)
|
ps how do i pass tdsver in database.yml for rails. |
correction, now 0.82 not working either. same error now as with 0.91. out of range error against sqlserver 2000. |
works fine if i get rid of the datetime fields in the query. obviously, not a solution. |
|
ok downloaded the repo and installed letting it pull in the remote freetds and iconv. i get "incorrect syntax near geometry" all over the place for the tests when i run:
|
94 tests, 37 assertions, 0 failures, 78 errors, 1 skips |
all the errors are the about incorrect syntax near geometry. |
made sure that freetds.conf was moved out when ran rake test. there shouldnt be any other switches for your test right? i confess that we do have odbc, a packaged freetds, and my /usr/local/lib version of freetds on the system. this is on a development/utility server that does lots of things so i am reluctant to remove all that. can we solve the geometry issue first so that we can see the test results? |
am knocking off for the day. back later this afternoon. |
If you are on 2000, you forgot to specify the |
TINYTDS_UNIT_HOST=cp9vm TINYTDS_SCHEMA=sqlserver_2000 rake test Running tests:...F..F.F.......E..FFF.F.........E.....F...S..........F........F..F....................F Finished tests in 9.125166s, 9.6437 tests/s, 30.3556 assertions/s.
88 tests, 277 assertions, 12 failures, 2 errors, 1 skips |
Now we are getting somewhere, I just checked master, and all the tests pass under my SQL Server 2000 database in a quick check on ruby 1.8.7, 1.9.2, and 1.9.3. So why yours is not is the big question. Can you show me what you have in your conf file for cp9vm? |
conf file? i am not using freetds.conf. cp9vm is a windows2000 server vmware instance running sqlserver 2000. so cp9vm is just the host. |
Well, if you (1) have made sure that you are not setting any potential conflicting ivars SYBASE , TDSVER, FREETDS, etc http://www.freetds.org/userguide/envvar.htm or (2) you made sure that you compiled an official FreeTDS with the rake task and did not set TINYTDS_SKIP_PORTS... Then do you have any ideas why your SQL Server is failing? All the failures to me look like they could be screwed up due to something crazy like from the above. Make sure you removed all that from the equation and see if you can look around to things like your DB version, some crazy DB configs, something? I'm at a loss. |
will rerun all of it and post back later. as for sqlserver it is just the basic stuff with no oddball collations or other ms wierdness. |
actually, we have a new datacenter stack that we are going to rollout relatively soon. i think i will try pulling all the odbc and other freetds stuff off of one of those servers. get it down to barebones and then run the gem testing from there. the sqlserver vm is the same. will let you know. might not be tonight tho. |
Thanks, you really should not be having problems like this :( but it will be good to find out and close the loop. |
Can you show me the output of this? Should show show the entire build and test process.
|
ok will do. in the meantime i successfully ran tests against my sqlserver2000 vm on a different machine. i uninstalled all odbc and tds related packages, rebooted, and then cloned the repo and ran tests. all tests ran ok with one skipped (test_007 about dropped connections -- looks like that is intentional to skip). to be clear this s what i did to get the clean install/tests after uninstalling stuff and creating tinytdstest db: git clone ... going to try testing the gem with datetime fields now. |
You are trying to shoe horn in rules for installing a gem that just do not simply apply if your are building your own native gem. A few helpful pointers.
|
i did EXACTLY what the directions for installing the native gem as they are specified on the readme. rake compile i just did this again and got the same errors. no free tds lib found. note that when i run rake native gem it exits with the following error: rm -f pkg/tiny_tds-0.5.1.rc1/test/test_helper.rb (See full trace by running task with --trace) does that have anything to do with this? |
Seems not, you're omitting the information you provided now.
See Issue #53 which contains a resolution for the problem (tl;dr -- update RubyGems and build again) |
Yes! It is pointless to continue till we find out that problem. I suggest using the |
right. so did git -x -d -f and reran all this again. same inability to build the platform gem. looking into #53. |
so i do have gem -v = 1.3.7. will upgrade and try again. might be good to have a note in the readme on this. |
Indeed, opening an issue about that. |
sorry hit the wrong button to close. another question. will this static gem still read /etc/freetds/freetds.conf i am hoping not. in my freetds.conf i have options: tds version = 8.0 i have other sites that are still using freetds 8.4 with odbc so i can't remove the freetds.conf file without breaking those. they will get converted to this new driver in short order but it'd be nice to test this driver a bit before forcing it on all of my dev sites. |
ok upgraded to gem 1.5.0 using gem upgrade --system 1.5.0 did clean git clone and bundle install. now i get this: rake compile |
gem -v verfies as 1.5.0 |
downgraded to gems 1.4.2 and now get same rake error. don't know how to build tiny_tds platform gem. i run rails 2.3.11 on some sites and redmine so i can't just upgrade to the current gem. is there a legacy gem version that you recommend? |
tried again with gem 1.4.0 with rake native gem --trace: rake native gem --trace |
ps here is the git clean and rake compile that i did immediately before the above native gem call. git clean -x -d -f |
this appears to be the issue. the gem is getting created without the -x86_64-linux suffix and rake native gem looks for the gem + platform.gem path which doesn't exist. exploring some workarounds including trying to figure out which gem version this gets fixed. #28226] Gem::PackageTask gem_dir incorrect Date: Detailed description The local variable "gem_dir" in Gem::PackageTask as added in r2471 incorrectly includes the platform (via Don't know how to build task 'pkg/activerecord-jdbc-adapter-0.9.7-java' I think the intention is to just depend on the #package_dir_path name instead. Patch attached. |
ok, found a workaround on the old rubyforge ticket for this (apparently this ticket didn't get transferred to github when they moved rubygems tickets this past june to github): http://rubyforge.org/tracker/index.php?func=detail&aid=28226&group_id=126&atid=577 there is a post for this workaround by david kellum: class Gem::PackageTask i added this to the tiny_tds rake file just above the Gem::Package.new call. i now get a platform gem generated. gem -x86_64-linux.gem installed perfectly. finally! ok going to test. |
umm. problems with trying this with bundler Gemfile. illformed requirement. Gem::Version::VERISION_PATTERN doesn't appear to like the dash delimited -x86_64-linux suffix. so we have a gem that doesn't have a valid version for Gemfile/bundler. |
ok. i removed the specific version requirement in my gemfile and now just have gem "tiny_tds" and i am now ... wait for it ... able to get queries that have dates out of my sql server. amazing. i confirmed that the FooModel.connection :mode => :dblib and not :odbc. so i am pretty certain this is running through the right adapter. so some things to finally wrap this up:
thanks for all the help on this. and i apologize for any brain vacumn on my end....gg |
I doubt it. It sounds like your using something in your ruby/rails stack that is causing that. It is not an issue of TinyTDS or rake-compiler/miniportile. We have a guy on our team that has a native gem of TinyTDS and it works great with our bundler, old rails 2.3 stack etc. Find out what is in your stack causing the issue and fix or upgrade.
FreeTDS will look in some standard places, google their site for which. It even allows you to specific a FREETDS env var to point it to one. We recommend removing conf files unless you have a specific need for one and if that is the case, make sure it is setup right.
Like I said, you could if you want if you maintain the conf file. My advice is to use the sqlserver adapter for things like that. Checkout the README on it, we have ways that you can use #configure_connection hooks for things like this. That feature is in the 2-3-stable and 3-0-stable and master branches. These are just general support questions that you can find by always checking the latest READMEs or subscribing to the google list or watching the CHANGELOG of each project.
Yes, I explained this in the TinyTDS read me and a few other places. Building FreeTDS with OpenSSL is an exercise left to you if that is needed. But it does work and I have tested it since that is the only way Azure let's you connect. CLOSING THIS ISSUE! |
ok. i am sorry that this is frustrating for you. it is frustrating for me as well. fwiw, i do think that you have a problem on debian linux with the Gem::PackageTask not building the gem with the -x86_64-linux extension. i had to hack your rake file to get that to work. sure, it might just be me, but it might not. looking through the tickets it appears that you have other linux related issues. thanks for all your work on this. i appreciate your time and effort and i understand fully what a pain in the butt dealing with sqlserver can be. so thanks for taking this on. |
That is build by Gem::PackageTask when including binaries, you should not be modifying the normal gem package. Anyhow, the main issue associated to the native gem not being generated is due the version of RubyGems. |
i tried gems 1.3.7, 1.4,0, 1,4,2, `,5,0 all were unable to build the On Wed, Dec 7, 2011 at 1:29 PM, Luis Lavena <
greg gard, psyd |
sorry 1.5.0 writing this on my phone. On Wed, Dec 7, 2011 at 1:37 PM, Greg Gard greg@gardwired.com wrote:
greg gard, psyd |
You didn't try 1.7.2, build the gem and revert your system back to 1.3.7 |
no i didn't. it didn't occur to me to do that. is the gem_spec.full_name http://rubygems.rubyforge.org/rubygems-update/UPGRADING_rdoc.html On Wed, Dec 7, 2011 at 1:40 PM, Luis Lavena <
greg gard, psyd |
Yes, starting RubyGems 1.7.2, |
it's nice to have some clarity on that thank you. if all goes well, i will On Wed, Dec 7, 2011 at 2:07 PM, Luis Lavena <
greg gard, psyd |
hi, i am running into this same issue as #55, but on debian linux ruby 1.8.7p320, tiny_tds 0.5.0 and freetds 0.91 qyering against windows 2000/sqlserver 2000 virtual machine (vmware). ie ruby is all on linux. i was getting these "statement invalid...argument out of range" errors on any query that has a datetime field (so almost all of my queries fail because of updated_at/created_at). this is a real show stopper. am really wanting to dump odbc. other details are that i compiled freetds without odbc, default tds 7.1 and enabling ms libs. the install all seemed to go fine (debian lenny doesnt have freetds 0.91 as yet).
i was getting the errors in rails 2.3.14 console so i then tried using TinyTds.client directly. same issue (argument out of range) when i try to iterate through result. fine if i dont select datetime fields.
please advise. am willing to help debug if needed. again, this doesn't appear to me to be a windows issue as these queries run fine on mssql query analyzer. it is only when you try to actually read the field in tds (convert string to Time?) that i pukes. i am not (and would prefer not to) use /etc/freetds/freetds.conf unless i have to to get this to work.
any ideas?
The text was updated successfully, but these errors were encountered: