rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
606 stars 189 forks source link

argument out of range for datetime fields on linux (similar to issue #55) #58

Closed gardwired closed 12 years ago

gardwired commented 13 years ago

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?

gardwired commented 12 years ago

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: 2010-05-20 16:42 Priority: 3 Submitted By: Nick Sieger (nicksieger) Assigned To: Eric Hodel (drbrain) Category: None State: Closed Summary: Gem::PackageTask gem_dir incorrect

Detailed description

The local variable "gem_dir" in Gem::PackageTask as added in r2471 incorrectly includes the platform (via gem_spec.full_name) when the parent is only expecting name-version. For gems that have platform names, this results in a bad rake prerequisite, since the actual directory is named without the '-java'.

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.

gardwired commented 12 years ago

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 def package_name gem_spec.full_name end end

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.

gardwired commented 12 years ago

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.

gardwired commented 12 years ago

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:

1) can we do native gem without the platform -x86_64-linux or install platform gem with just 0.5.1.rc1 as the version? would like to be able to put versions in my gemfile and be able to install multiple versions etc for testing.

2) does this static gem still read /etc/freetds/freetds.conf?

3) do i need to bother with seetting freetds options like text size? i am hoping that this would just work with any size text field.

4) i assume that this is sending an unencrypted, utf-8 encoded request to my sqlserver.

thanks for all the help on this. and i apologize for any brain vacumn on my end....gg

metaskills commented 12 years ago

can we do native gem without the platform -x86_64-linux

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.

does this static gem still read /etc/freetds/freetds.conf?

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.

do i need to bother with seetting freetds options like text size

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.

i assume that this is sending an unencrypted, utf-8 encoded request to my sqlserver.

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!

gardwired commented 12 years ago

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.

luislavena commented 12 years ago

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.

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.

gardwired commented 12 years ago

i tried gems 1.3.7, 1.4,0, 1,4,2, `,5,0 all were unable to build the platform gem.

On Wed, Dec 7, 2011 at 1:29 PM, Luis Lavena < reply@reply.github.com

wrote:

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.

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.


Reply to this email directly or view it on GitHub: https://github.com/rails-sqlserver/tiny_tds/issues/58#issuecomment-3051250

greg gard, psyd http://gardwired.com

gardwired commented 12 years ago

sorry 1.5.0 writing this on my phone.

On Wed, Dec 7, 2011 at 1:37 PM, Greg Gard greg@gardwired.com wrote:

i tried gems 1.3.7, 1.4,0, 1,4,2, `,5,0 all were unable to build the platform gem.

On Wed, Dec 7, 2011 at 1:29 PM, Luis Lavena < reply@reply.github.com

wrote:

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.

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.


Reply to this email directly or view it on GitHub: https://github.com/rails-sqlserver/tiny_tds/issues/58#issuecomment-3051250

greg gard, psyd http://gardwired.com

greg gard, psyd http://gardwired.com

luislavena commented 12 years ago

i tried gems 1.3.7, 1.4,0, 1,4,2, `,5,0 all were unable to build the platform gem.

You didn't try 1.7.2, build the gem and revert your system back to 1.3.7

gardwired commented 12 years ago

no i didn't. it didn't occur to me to do that. is the gem_spec.full_name issue resolved in 1.7.2? or starting with 1.7.x series. if so, then maybe add this little trick to the compat note you opened the issue on. here is a link to upgrading/downgrading gems you could include:

http://rubygems.rubyforge.org/rubygems-update/UPGRADING_rdoc.html

On Wed, Dec 7, 2011 at 1:40 PM, Luis Lavena < reply@reply.github.com

wrote:

i tried gems 1.3.7, 1.4,0, 1,4,2, `,5,0 all were unable to build the platform gem.

You didn't try 1.7.2, build the gem and revert your system back to 1.3.7


Reply to this email directly or view it on GitHub: https://github.com/rails-sqlserver/tiny_tds/issues/58#issuecomment-3051414

greg gard, psyd http://gardwired.com

luislavena commented 12 years ago

no i didn't. it didn't occur to me to do that. is the gem_spec.full_name issue resolved in 1.7.2? or starting with 1.7.x series.

Yes, starting RubyGems 1.7.2, rake native gem works properly.

gardwired commented 12 years ago

it's nice to have some clarity on that thank you. if all goes well, i will be putting this static gem into production soon. we have around 200k hits a day so will let you know if i run into other oddities. on a different ticket :)

On Wed, Dec 7, 2011 at 2:07 PM, Luis Lavena < reply@reply.github.com

wrote:

no i didn't. it didn't occur to me to do that. is the gem_spec.full_name issue resolved in 1.7.2? or starting with 1.7.x series.

Yes, starting RubyGems 1.7.2, rake native gem works properly.


Reply to this email directly or view it on GitHub: https://github.com/rails-sqlserver/tiny_tds/issues/58#issuecomment-3051765

greg gard, psyd http://gardwired.com