Default BIT columns are not being set
snex opened this issue · 3 comments
Issue
Default BIT columns are not being set
Expected behavior
If a column has a NOT NULL constraint and a default value is specified, then that default value should be used if the value was not set via the Rails model.
Actual behavior
NULL is being sent for the value, causing the database to throw an error and not create the record.
How to reproduce
Create a table with a column of type BIT with NOT NULL and a DEFAULT.
Create a Rails model representing this table.
Try to create a record without specifying the value for the column in question.
Details
- Rails version:
7.1.3.2 - SQL Server adapter version:
7.1.3 - TinyTDS version:
2.1.7 - FreeTDS details:
Compile-time settings (established with the "configure" script)
Version: freetds v1.3.3
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: auto
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
OpenSSL: no
GnuTLS: yes
MARS: yes
Seems to be happening for all column types, not just BIT.
Could you create a test-case using the script in https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/How-to-report-a-bug#minimal-reproducible-script and attach it to this issue?
It looks like this is a permissions problem - the user we are connecting with does not have proper view permissions on the table. It can see most of the table structure but not what the defaults should be, so the adapter is confused into thinking there are none. I think this should be safe to close. Thank you.