activerecord-hackery / ransack

Object-based searching.
https://activerecord-hackery.github.io/ransack/
MIT License
5.67k stars 807 forks source link

Sorting field across SQLServer TinyTds & MySQL #958

Closed lahirisan closed 4 years ago

lahirisan commented 6 years ago

hi everybody: Im trying to use ransack sorting feature with 2 different db connections, using many to many relation between my models I have 3 models with this relation among them:

class SqlServerIncidente < ApplicationRecord establish_connection :sql_server self.table_name_prefix = "Alto.dbo." self.table_name = 'Incidente' has_many :sql_server_incidente_linkages, foreign_key: "sql_server_incidente_id" has_many :linkages, :through => :sql_server_incidente_linkages end

class Linkage < ApplicationRecord has_many :sql_server_incidente_linkages, dependent: :destroy has_many :sql_server_incidentes, :through => :sql_server_incidente_linkages end

class SqlServerIncidenteLinkage < ApplicationRecord belongs_to :linkage belongs_to :sql_server_incidente end

In rails console i can do this successfully: SqlServerIncidente.first.sql_server_incidente_linkages.first.linkage.name

but when a try to ransack sorting throw the field name associated to Linkage model using the previous defined relation i get this error:

(TinyTds::Error: Invalid object name'sql_server_incidente_linkages'.

it is like rails do not recognize the relation among MS SQLServer and Mysql when sorting

Any Idea? anybody???

Sorry by my english. Im spanish speaker Thanks

scarroll32 commented 4 years ago

Thanks @lahirisan

SQLServer is not supported by Ransack.