Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Joseph Haig
    Hi. We are possibly going to be moving some Rails apps to Azure and, as such, could start using an MS SQL server as the database. I have literally just starting playing around with this (thanks for this gem, by the way) and am trying it with a mcr.microsoft.com/mssql/server:2017-latest-ubuntu docker image. Our migrations are failing because at some points we are defining columns as 'bool' which, I see now, is not standard SQL. Is there a way to get the sqlserver adapter to automatically substitute for (presumably) a tiny int or a char?

    NoMethodError: undefined method `alias_method_chain' for #<Class:ActiveRecord::Base>
    Did you mean? alias_method

    i always get this error when i make db with sql server in rails

    Andrew Blignaut
    Hi All, I just recently a pull request to the repo but I see that the build is failing for most open pull requests. What's up? Is anyone actively getting the tests back up and running and reviewing pull requests? Thanks
    anyone got this thing running with rails 6 and ruby 2.7?
    anyone even reading this ? xD
    Andrew Blignaut
    @nemesit - No, we are running rails 5.2 at the moment.
    @AndrewBlignaut_twitter yeah we are too, shame really. do the 5.2 tests for this adapter all pass for you?
    I fixed all the ONLY_SQLSERVER=1 errors for rails 6 dunno bout the activerecord stuff
    Hey guys, I know this doesn't work with rails 6 - but do you know when it will be? Not exactly, i just wanna know is it like 2 months or 12 months amount of time
    @dlipinski it will be ready as soon as some has time to run all tests and fix the failing ones. Yoe are welcome to help in this matter ;-)
    Aidan Haran
    All the Rails 6 tests are now passing on Travis CI. Trying to fix the last of the tests failing on Windows (AppVeyor). After that is done then I think there will be a release candidate for Rails 6.
    Wanderson Policarpo
    I released the first RC for Rails 6 v6.0.0.rc1 now. I appreciate if you have a chance to test it and give any feedback or report issues here: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
    anyone know why I am getting

    rails db:migrate:down VERSION=20200528104729 RAILS_ENV=development
    == 20200528104729 SomeMigration: reverting =====================================
    rails aborted!
    StandardError: An error has occurred, all later migrations canceled:

    undefined method `revert' for #<ActiveRecord::ConnectionAdapters::SQLServerAdapter:0x00007f7f271c3150>

    (5.2 not rails 6)
    and another thing is that it seems like disable_referential_integrity does not get called when testing
    I'm not sure but I think thats kinda necessary
    Aidan Haran
    @nemesit For the "rails db:migrate:down" issue can you create a reproducible script to demonstrate the issue? https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/How-to-report-a-bug
    @nemesit The tests are currently passing for Rails 5.2 and 6 so I'm not sure why "disable_referential_integrity" is necessary.
    maybe only occurs with multiple adapters
    that it only disables constraints on the main one and not all?
    I guess that could be the problem
    likely in rails itself
    Aidan Haran
    I don't think the current versions of the SQL Server adapter will work if you are using multiple database adapters in the same application. For example, the SQL Server adapter monkey-patches Arel. However, Arel is used by other adapters such as PostgreSQL/MySQL/etc and these monkey-patches will probably break those adapters.
    works fine here, except for the constraint in fixtures
    all tests succeed except when I add foreign keys to the db, because rails only disables the constraints for the main adapter (I guess)
    Michał Zając

    Hi, I'm getting Adaptive Server connection failed (localhost:1433) when trying to bin/rails db:migrate in my application. tsql -H localhost -p 1433 -U sa -P ais7Jighaich (I'm not using this in production) works just fine.

    My config/database.yml

    default: &default
      adapter: <%= ENV.fetch("DATABASE_ADAPTER", "postgresql") %>
      mode: dblib
      host: <%= ENV.fetch("DATABASE_HOST", "localhost") %>
      port: <%= ENV.fetch("DATABASE_PORT", 5432) %>
      pool: 5
      timeout: 5000
      user: <%= ENV.fetch("DATABASE_USER", "nbp") %>
      password: <%= ENV.fetch("SA_PASSWORD") { ENV.fetch("DATABASE_PASSWORD", "nbp") } %>
      <<: *default
      database: <%= ENV.fetch("DATABASE_NAME", "nbp") %>
      <<: *default
      database: <%= ENV.fetch("DATABASE_NAME", "nbp_development") %>
      <<: *default
      database: <%= ENV.fetch("DATABASE_NAME", "nbp_test") %>
      host: <%= ENV.fetch("DATABASE_HOST", "postgres") %>

    And yes, I have exported the variables

    quintasan@applover:~/source/applover/nbp_backend$ env | grep DATABASE

    What am I doing wrong?

    Michał Zając
    TinyTds can connect as well:
    [1] pry(main)> client = TinyTds::Client.new username: 'sa', password: 'ais7Jighaich', host: 'localhost', port: 1433
    [2] pry(main)> result = client.execute("SELECT GETDATE()")
    #<TinyTds::Result:0x000055952ff44100 @query_options={:as=>:hash, :symbolize_keys=>false, :cache_rows=>true, :timezone=>:local, :empty_sets=>true}>
    [3] pry(main)> result.each do |row|
    [3] pry(main)*   row.inspect  
    [3] pry(main)* end  
        [0] {
            "" => 2020-10-06 13:11:34 +0200
    Walther Diechmann
    hi - we're debugging a troubled SQL statement pulling 900K+ rows from a 2008 MSSQLServer using tiny_tds 2.1.3 gem in a Rails project - and lately we're experiencing TinyTds::Error: DBPROCESS is dead or not enabled errors - I know this is like nothing to comment on but perhaps one of you guys have seen this one before and got ideas on how to best debug the issue?
    Guyren Howe

    Hi. My organization (CoverMyMeds) is keen to fix issues with 6.0 and ensure 6.1 is great.

    I can't run tests atm (I created rails-sqlserver/activerecord-sqlserver-adapter#913 about it), but will help out as I'm able until that's fixed. I was planning to do code reviews, but feel free to speak up if I can help in some other way.

    Guyren Howe
    I see no reason not to fix the need for use_output_inserted: use introspection on the database to detect the relevant conditions (trigger on the table, and trigger on the table in the presence of UUID) to determine what means to use to return the newly inserted id. Am I missing something with this idea?
    Senol Feldmann
    Hi! I have a question about tiny_tds. Does anyone know if the the various exe files which are shipped in the fat binary gem version (mingw-x64 / CRuby on Windows) of tiny_tds are really needed for tiny_tds to operate?
    For me, iconv.exe in C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems\tiny_tds-2.1.5-x64-mingw32\ports\x86_64-w64-mingw32\libiconv\1.15\bin is especially important, as it is licensed under GPL and I want to use activerecord-sqlserver-adapter (and thus tiny_tds as it is a dependency) use commercially.
    Hey guys
    does anybody know what to do with this error "TinyTds::Error (USE statement is not supported to switch between databases. Use a new connection to connect to a different database.)"
    when I have azure: true in database.yml
    Jose Jimenez

    Happy Monday! We recently updated our version of the sqlserver adapter in our app from 6.0.x to 6.1.x
    in doing so, we realized passing a type for an index no longer works so this test would fail:

    it "add index with type" do assert_sql(/CREATE CLUSTERED INDEX.*/) do connection.add_index "testings", "id", type: :clustered connection.remove_index "testings", "id" end end
    I believe this is because this version introduced an override for visit_CreateIndexDefinition which doesn't account for the order that sql server expects to see the index type in the create call

    1 reply
    JP Silvashy
    What is the best way to provide an undefined type, I'm connecting to a vendors DB and hey have some types I've not seen, like one called TD_BooleanFalse, which raises an error like:
    ActiveRecord::StatementInvalid (TinyTds::Error: Type DT_BooleanFalse is not a defined system type.)
    I've tried adding an initializer and registering the types like this:
    ActiveRecord::Type.register(:DT_BooleanFalse, ActiveRecord::Type::SQLServer::Boolean)
    No luck however. Any insight would be super appreciated
    I've searched everywhere in the docs and issues and couldn't find any good examples of how to handle this situation
    JP Silvashy
    Nevermind, I think the issue is with something else, this only happens when there is a constraint on a non standard type, oh well.
    TinyTds::Error: The target table 'items' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
    Hi All, Can any one help me in resolving the error which I am getting
    That table 'items' as trigger which we need
    IS there any setting/configuration to insert/update into the table without any trigger error, skip/bypass trigger

    Need one help
    Which version of tiny_tds and activerecord-sqlserver-adapter is compatible with MS SQl server 2019 Enterprise edition with multi_subnet failover?

    Presently we are using tiny_tds 2.1.2 and active-sqlserver-adapter 5.2.1 is compatible and working with MS SQL server 2017 Enterprise edition with multi_subnet failover

    Hello, I am sure this question have been asked here before: does anyone have any experience installing the adapter on windows+mingw ?
    OK maybe I need to reformulate my problem, and start easy: how can I get the tiny_tds binaries prebuilt for windows? I see no release page and I am new-ish to ruby
    anyone connected Rails app running in Azure Docker container without providing username/password in database.yml? meaning using Azure Service Principal or Managed Identity to Azure SQL Server? apparently it should be possible to use the access_token provided by the IMDS endpoint, but I am unable to find any guidance on how to accomplish this...
    Brady Steed
    Hi! I am trying to debug a weird error we get sometimes. The log only says, /usr/local/bundle/ruby/2.7.0/gems/activerecord-sqlserver-adapter-5.0.8/lib/active_record/connection_adapters/sqlserver/database_statements.rb:278: warning: TinyTds: dbsqlsend() returned FAIL. Looks like probably a connection issue. Is there a way to get better insight into the problem? Maybe a log dump or a way to increase the log level?