You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Minitest and fixtures I will get an error ActiveRecord::StatementInvalid: TinyTds::Error: Cannot truncate table 'active_storage_blobs' because it is being referenced by a FOREIGN KEY constraint. when I try to run any tests.
Expected behavior
Tests should run without an error.
Actual behavior
When I have in my test helper parallelize(workers: :number_of_processors) it will give the above error. Changing it to parallelize(workers: 1) makes it work. I think it has something to do with the timing of disabling the referential integrity but I'm not sure.
How to reproduce
Set up a clean Rails app, add something like ActiveStorage, create a couple of models like User and Post. Create a test for the user and run it.
I've created a demo repo here where this error occurs: https://github.com/erlingur/sqlserver_test
You should be able to clone it, point it at an SQL server and run rails test to make it blow up (possibly have to run it twice).
I created the app by literally doing the following:
rails new sqlserver_test
bundle add activerecord-sqlserver-adapter
# Change database.yml
rails db:create
rails g model User name
rails g model Post title user:belongs_to
rails active_storage:install
rails db:migrate
# Create the single User test
rails test
Details
Rails version: 6.1.4.1
SQL Server adapter version: 6.1.2.1
TinyTDS version: 2.1.5
FreeTDS details:
Compile-time settings (established with the "configure" script)
Version: freetds v1.3.3
freetds.conf directory: /opt/homebrew/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
The text was updated successfully, but these errors were encountered:
At the time I gave it a pretty good try at finding the issue and trying to fix it but I was unsuccessful. I'll try it again soon, hopefully I'm a little smarter now three years later :)
Issue
Using Minitest and fixtures I will get an error
ActiveRecord::StatementInvalid: TinyTds::Error: Cannot truncate table 'active_storage_blobs' because it is being referenced by a FOREIGN KEY constraint.
when I try to run any tests.Expected behavior
Tests should run without an error.
Actual behavior
When I have in my test helper
parallelize(workers: :number_of_processors)
it will give the above error. Changing it toparallelize(workers: 1)
makes it work. I think it has something to do with the timing of disabling the referential integrity but I'm not sure.How to reproduce
Set up a clean Rails app, add something like ActiveStorage, create a couple of models like User and Post. Create a test for the user and run it.
I've created a demo repo here where this error occurs: https://github.com/erlingur/sqlserver_test
You should be able to clone it, point it at an SQL server and run
rails test
to make it blow up (possibly have to run it twice).I created the app by literally doing the following:
Details
6.1.4.1
6.1.2.1
2.1.5
The text was updated successfully, but these errors were encountered: