All,
ActiveRecord 1.14.3, sqlserver adapter, odbc mode
I have a table in SQL Server with a smalldatetime column - let’s call it
little_date. little_date is not allowed to have NULLs per the database
schema.
I am creating a new ActiveRecord object using obj.new (no database save)
and calling obj.little_date. So I’m doing:
obj.new
obj.little_date
What I observe is that if there is no constraint on the little_date
column, then the value of obj.little_date is nil (as you would expect).
However, if there is a default constraint on little_date, created by
something like:
“ALTER TABLE XXX WITH NOCHECK ADD CONSTRAINT DF_blah DEFAULT (getdate())
FOR little_date”
and I then do:
obj.new
obj.little_date
then little_date has a value of “Sat Jan 01 00:00:00 Central Standard
Time 2000”
What gives? Is ActiveRecord attempting to create a default for this
record since “it saw” a default constraint on the table? If so, it’s
unnecessary - the database will provide the value upon insert.
Any insight into this?
Thanks,
Wes