New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails test are failing on fixture loading #672
Comments
I couldn't reproduce the error locally even with your test project (thanks for that, btw). Can you tell us which versions you have for SQL Server, Also, what's the compatibility level of your database? |
The master branch in NOT failing in your case? Interesting. FreeTDS: 1.00.109 |
@wpolicarpo Btw, the adapter is working, just the tests are failing. In Rails 5.1 the SET IDENTITY_INSERT is set to ON before a fixture insert is executed. Rails 5.1
Rails 5.2
|
I cloned your demo project and ran the tests against a 2016 (130) database and all worked fine. Can you tell us the types for those You can use rails itself if you want: |
Ok, the just managed to try the sample project on a 2016 Server: MSSQL Server 2016 (130) 13.0.5201 The message is now: Error: You are in the master branch and you executed, "rails db:migrate RAILS_ENV=test" and "rails test"? This is my output for MyModel.columes_hash:
|
@juice why do you have both Does that work if you remove |
@wpolicarpo Is there an option to disable the backquotes syntax? "TinyTds::Error: Incorrect syntax near '`'", isn't this the problem? We use multiple db connections, i tried to get as close as possible to the original project, thats why there is another db connection. I'm looking forward to Rails 6.0 multiple Database connection feature. What has changed between rails 5.1 and rails 5.2 in the sqlserver adapter so that tests are now failing? |
@juice first of all, I don't think Rails supports (or will support) the presence of multiple adapters within the same application even with Rails 6 multiple db connection feature, but I might be wrong. Your tests are failing because Rails changed the way fixtures are loaded with the addition of If the SQL Server adapter was the main connection, this problem would not be happening, but I bet you would have more issues other than these. Given that, I would suggest:
|
@wpolicarpo I have a backtrace here, i hope this helps and thanks for the links to the source. It would be great to fix the broken Fixture code in this Adapter. Everything works together as expected and with Rails 6.0 it will finally backed into the Rails Core. So setting up multiple DB will be a bit easier. The Adapter is playing nicely with other adapters, but as you mentioned the Problem is in the "insert_fixtures_set" method. After calling "insert_fixtures_set" from the activerecord-sqlserver-adapter, it is falling back to the active_record method "build_fixture_sql". And at this point the data from the SQLServer is mishandled. Understandably, "TypeError: can't quote ActiveRecord::ConnectionAdapters::SQLServer::Type::Data" will be raised. BTW, our original Setup is not, sqlite3, it is MySQL in some projects and PostgreSQL in other projects.
|
@juice I don't think the issue is in the adapter as I explained before. Your setup is very peculiar and I don't know if Rails would support it out of the box (even Rails 6). I made a few tests (manually monkey patching I'm happy to help with a PR to Rails, but I need to be sure this is intentionally supported by them. Can you open an issue there linking back this thread and we can discuss with them what needs to be done? |
FWIW, I am a little surprised Rails does not find the right constant. It could that 5.2 has a regression. Maybe check rails/rails to be sure but I would expect it to find your right model constant. A few thoughts:
HTH |
@metaskills Thanks for your help. Sadly, both tips didn't change the behavior. |
@wpolicarpo @metaskills Right now the MSSQL Adapter is in a broken state, loading fixtures in tests with multi adapters is not working. As highlighted by the Rails Maintainers, one of the biggest points on the Roadmap is multi database connection and easier multi database adapter support. Is there a way to make sure that the original behavior is working again by adding a test? |
@wpolicarpo I just did an upgrade to Rails 6.0 and the tests are now working as intended. Thanks to everyone who helped with the Rails 6.0 PRs. |
Hello, we tried to migrate the current master into our project, but our tests are failing.
I created a tiny test project with one table and one field.
execute: rails test
https://github.com/juice/mssql-test
It looks like the fixtures cannot be inserted into the table.
I added all options from our project, like:
ActiveRecord::ConnectionAdapters::SQLServerAdapter.use_output_inserted = false
But it doesn't matter, simple tests are failing anyway. It works with Rails 5.1 and previous versions of the adapter.
Here the same tests in a working branch with Rails 5.1:
https://github.com/juice/mssql-test/tree/working
The text was updated successfully, but these errors were encountered: