rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
972 stars 558 forks source link

Fix Rails application name and SQL Server check #1111

Closed aovertus closed 11 months ago

aovertus commented 11 months ago

Hi,

I've been trying to use the main version of the adapter on our project and can't make it running yet. Here are 2 issues I've found so far.

  1. Small bug

rails_application_name is called on the instance level instead of class

  1. Issue with sqlserver? declaration
3.2.0 :001 > User.where(id: 1).exists?
/Users/alexandreovertus/.rvm/gems/ruby-3.2.0/bundler/gems/activerecord-sqlserver-adapter-d1a3b1dd1977/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb:14:in `construct_relation_for_exists’: undefined method `sqlserver?' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x0000000117eaf020 @transaction_manager=#<ActiveRecord::ConnectionAdapters::TransactionManager:0x00000001162e0100 @stack=[], @connection=#

sqlserver? is unknown from the other adapter. As I understand the goal of defining a method to easily detect which adapter is currently used rather than relying on the name, its not known by the abstracted layer. Ideally the abstract layer would define a method dynamically based on the name of the adapter, in the meantime we can explicitly add a method on the abstract module to make it shared.

Let me know if it makes sense as if its easier to share those notes or make a useable PR to contribute.

Thanks for your support and help with this library 🎉

aidanharan commented 11 months ago

@aovertus Thanks for the PR! Great to fix the issues you found as soon as possible.