-
Notifications
You must be signed in to change notification settings - Fork 564
Description
Issue
This is more of a question than a reproducible issue.
My team is considering using the multiple database support built into Rails to connect our Rails app to two databases simultaneously: a PostreSQL database and a SQL Server database. Does this gem supports such a scenario?
For example, Rails 6.1 supports a database.yml like this:
production:
primary:
adapter: postgresql;
# postgres config goes here
secondary:
adapter: sqlserver
# sql server config goes hereThen one can use establish_connection to connect to one or the other database on demand. Alternatively, one can declare models using connects_to to "bind" models to a certain database.
However, I see that this gem applies monkey patches to several ActiveRecord internal classes. Which has me worried. See here:
Some of these patches seem to imply that compatibility with other databases is being removed (notably PostgreSQL in this example) in favor of supporting SQL Server. This is not explicitly stated in the code or documentation, so I can't be sure of that.
Is it problematic to use the SQL Server adapter and the PostgreSQL adapter in the same Rails application? It seems like conflicts are a real possibility, because the monkey patches are scoped to affect ActiveRecord as a whole.
Expected behavior
I'd like like to be able to use the SQL Server adapter and PostgreSQL adapter in the same Rails app without them conflicting with each other. Is it possible that the monkey patches in this gem could somehow be scoped so they only apply based on the database connection?
In other words, in pseudo code:
if connection.adapter is sqlserver then patched_version else original_version
Details
- Rails version:
6.1.4 - SQL Server adapter version:
6.1.0.0 - TinyTDS version:
2.1.5 - FreeTDS details:
$ tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v1.2.21
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
OpenSSL: yes
GnuTLS: no
MARS: yes