Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

table name with double underscore #590

Closed
lukeholder opened this Issue · 4 comments

1 participant

@lukeholder

The following connects successfully to the database:

require "rubygems"
require "sequel"

DB = Sequel.connect(
    :adapter => "tinytds",
    :username => 'sa',
    :password => 'Doric101',
    :host => '192.168.4.235',
    :database => 'ADCData_Doric'
    )

Running manual SQL queries works but the code here:

prm_master__employee = DB.from(:prm_master__employee)

prm_master__employee.each do |r|
    puts r.employee
end

results in the error:

/Users/lukeholder/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.41.0/lib/sequel/adapters/tinytds.rb:221:in `fields': TinyTds::Error: Invalid object name 'PRM_MASTER.EMPLOYEE'. (Sequel::DatabaseError)
    from /Users/lukeholder/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.41.0/lib/sequel/adapters/tinytds.rb:221:in `block in fetch_rows'
    from /Users/lukeholder/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.41.0/lib/sequel/adapters/tinytds.rb:68:in `block in execute'

Obviously the tinytds adadper is looking for a table PRM_MASTER.EMPLOYEE but the table does not have a dot.

Any assistance would be appreciated.

@lukeholder

ok, looking at documentation further, the double underscore is actually a notation created as a part of the Qualifying identifiers of sequel. Any way around this, as the table cannot be renamed to not contain double underscores?

I tried this which should be a valid symbol but it doesn't work either:

DB.from(:"prm_master__employee")
@lukeholder

I suppose what I am asking is a way to use double underscores in a table name without it thinking im looking to make it a qualified query.

@lukeholder

Additional question:

why does

class Employees < Sequel::Model(:prm_master__employee)

end

puts Employees.table_name

print out

prm_master__employee

but Employee.all fails with

 Invalid object name 'PRM_MASTER.EMPLOYEE'
@lukeholder

issue solved with

#327

@lukeholder lukeholder closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.