Skip to content
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

table name with double underscore #590

Closed
lukeholder opened this issue Dec 3, 2012 · 4 comments
Closed

table name with double underscore #590

lukeholder opened this issue Dec 3, 2012 · 4 comments

Comments

@lukeholder
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

issue solved with

#327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant