I am using Elixir to connect to MSSQL database. The database has a table with a computed column in it. However, when I update other columns in the object and commit the changes, python tells me I can't insert to the computed column.
I am using autoload so in my model:
class Slot(Entity):
using_options(tablename='tbScheduleSlots', autoload=True)
using_table_options(schema='sch')
I create a Slot and give it some values then commit:
ss = Slot(StartDateTime='2012-01-01 13:00:00:000', Program_ID=1234, etc)
session.commit()
Important note!! I do not give the ss object any value for EndDateTime because that is a computed field. So effectively, I'm not passing anything back to the database for that field.
Error:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', '[42000] [FreeTDS][SQL Server]The column "EndDateTime" cannot be modified because it is either a computed column or is the result of a UNION operator. (271) (SQLPrepare)') 'INSERT INTO sch.[tbScheduleSlots] ([Program_ID], [SlotType_ID], [StartDateTime], [EndDateTime], [Duration], [Description], [Notes], [State], [MasterSlot_ID]) OUTPUT inserted.[ID_ScheduleSlot] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' (5130, 1, '2012-01-01 13:00:00:000', None, None, None, None, 2, None)