rails-sqlserver / tiny_tds

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

ActiveRecord::StatementInvalid (TinyTds::Error: Invalid column prefix '': No table name specified) Rails 6 #477

Closed RailsCod3rFuture closed 4 years ago

RailsCod3rFuture commented 4 years ago

I'm attempting to use rails 6 new read-only database functionality with tiny_tds. The issue i am having is that it thinks no table name exist for the model I am trying to connect with for a remote SQLEXPRESS Server.

My setup is below remote_file.rb / remote_files table

class RemoteFile < ApplicationRecord
  self.abstract_class = true
  connects_to database: {reading: :remote_files}
end

database.yml

production:
    primary:
         adapter: postgresl
       ....
    ...
   remote_files:
       adapter: sqlserver
       database: RemoteData
       dataserver: 12........:5171\SQLEXPRESS
       username: rails-guy
       password: ergegegegegege

I'm able to connect to the server without issue, outside of rails. But, why does this error pop up when I use the code below?

Activerecord::Base.connected_to(database: {reading: :remote_files}) do 
 RemoteFile.first
end
RailsCod3rFuture commented 4 years ago

I haven't even asked, but does this gem actually work with Rails 6 new multiple database feature? I simply need to read the data from the mssql express server.