I tried in irb to require 'sequel' and then type the workaround code that you 
gave and it complained about Sequel::MSSQL being an unknown constant.

I also tried 'rake gem' in my tiny_tds repo that I cloned. It built the gem but 
didn't install it (at least gem list didn't list it even after running rake 
gem). 'gem install tiny_tds' in that directory errors out because DBDATEREC is 
missing several expected members (dateyear, datemonth, etc.).

I'll fork a new repo tomorrow and see if I can build - maybe I pulled it when 
the build was broken or something.

I have no idea how to add a SQL Logger, unfortunately, so can't make much 
progress on that without some googling or finding other information.

I'll work on this more tomorrow or the next day.

Thanks for the help!

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Jeremy Evans
Sent: Tuesday, March 08, 2011 5:24 PM
To: sequel-talk
Subject: Re: Seg fault when accessing SQL Server

On Mar 8, 1:22 pm, Andy Tinkham <[email protected]> wrote:
> Thanks for this, Jeremy! I tried building and installing the tinytds gem, but 
> I don't have much experience with locally built gems and something went awry. 
> I'll revisit that in a few days and watch for the 0.4 version and switch to 
> that.
>
> In the meantime, I've built and installed the ruby-odbc gem along with iODBC 
> and the OpenLink SQL Server drivers which seems to have helped as I no longer 
> get a Seg Fault when I access our databases. I can successfully connect and 
> query the db through ruby-odbc.
>
> However, when I try to use sequel, I'm getting an "Incorrect syntax near '1'" 
> error.  Here's the call stack:
> Sequel::DatabaseError: ODBC::Error: S1000 (102) [OpenLink][ODBC][Express 
> Edition]Incorrect syntax near '1'.
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:51:in
>  `run'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:51:in
>  `block (2 levels) in execute'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/database/logging.rb:28:in
>  `log_yield'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:51:in
>  `block in execute'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/connection_pool/threaded.rb:84:in
>  `hold'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/database/connecting.rb:226:in
>  `synchronize'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:49:in
>  `execute'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:541:in
>  `execute'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/adapters/odbc.rb:91:in
>  `fetch_rows'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:123:in
>  `each'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:449:in
>  `single_record'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:457:in
>  `single_value'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:202:in
>  `get'
>         from 
> /Users/andyt/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.21.0/lib/sequel/dataset/actions.rb:96:in
>  `count'
>         from (irb):4
>         from /Users/andyt/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
>
> The code that I've executed when I get that is DB = Sequel.odbc('{my 
> DSN name}', :user => '{my user}', :password = '{my password}', :dbtype 
> => 'mssql') ds = DB[:glb_people] ds.count
>
> Is this also a case where I should just switch to tiny tds, or is there 
> something else going on here?

It would help to have an SQL logger to see the actual SQL being generated, but 
my guess is the 1 being mentioned is the value of TOP.
I'm not sure how the OpenLink ODBC driver is programmed, but if it is also 
attempting to parse the SQL and doesn't recognize the format Sequel is using 
(TOP (1) for newer versions of SQL Server), I could see it giving you that 
error.  You could try this as a workaround:

  module Sequel::MSSQL::DatasetMethods
    def select_limit_sql(sql) sql << " TOP #{literal(@opts[:limit])}"
if @opts[:limit] end
  end

If that doesn't work, please add an SQL logger and send the output.

BTW, building a tiny_tds gem is as simple as cloning the repository with git 
and running rake gem, so I'd advise giving that a shot.

Thanks,
Jeremy

--
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to