-
Notifications
You must be signed in to change notification settings - Fork 563
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
ActiveRecord::StatementInvalid (TinyTds::Error: Type DT_BooleanFalse is not a defined system type.) #1005
Comments
Actually after further investigation, I found out something interesting, this only happens for default value constraints for non-standard column types. So this is still an issue, but we've worked around it by having the client drop the constraints, but leaving my original issue here in case anyone comes across it via search or otherwise. |
Hey, The issue is that in this optimization commit we have changed the source of truth for the columns information, i.e. we now use different tables, and if we use custom types in our tables, the "type" being fetched is different than previously. For example, assuming following custom type: In old version, we were fetching the "system type" as a type (for example, Then, in the code around default values, we have this line: activerecord-sqlserver-adapter/lib/active_record/connection_adapters/sqlserver/schema_statements.rb Line 430 in 28c38ea
In our example, it tries to execute following SQL:
Because now, the type is
Because, as far as I understand -- we cannot cast the value into a custom type, only into system type. In previous version it tries to cast into My guess would be that the easiest solution would be to change the code so that it fetch system type instead of custom type again, but I don't know whether it's possible to do that and keep the optimizations in place. Or maybe fetch both the custom type and system type, and then use system type for casting. I honestly don't know what's best, my knowledge in SQL Server is really basic. When it comes for workaround, I have recovered myself the unoptimized version of column definitions (monkeypatched Also for the record: ActiveRecord version: 6.1.7.3 But in my understanding, the problem should also be the same in 7.x version. |
Also, the issue is closed and I don't have ability to reopen it :) |
Issue
I'm trying to query a DB which has some custom types, I've not seen before, one column has the type
TD_BooleanFalse
, when querying the db, the following error is raised:I've tried registering a type with an initializer like so:
And then setting the attribute type in the model with:
Although this does not work.
Details
Rails version:
6.1.4.4
SQL Server adapter version:
v6.1.2.1
TinyTDS version: v1.3.7
FreeTDS details:
The text was updated successfully, but these errors were encountered: