I have a Django 1.8.3 application that I'm connecting to SQL Server Enterprise 2012 as one of the databases. I am using django-pyodbc-azure==1.8.3.0
and my connection looks like this:
'sql_server': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'mydb',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': '173.1.1.1',
'PORT': 1433,
'OPTIONS': {
'host_is_server': True,
}
},
I have a column in a table in the database that was created as such:
ALTER TABLE mytable ADD geo AS GEOGRAPHY::Point (
latitude
,longitude
,4326
) persisted;
CREATE spatial INDEX SI_mytable__geo ON mytable (geo)
When trying to update any column in this table via the Django admin, I receive this error:
('42000', "[42000] [FreeTDS][SQL Server]UPDATE failed because the following SET options have incorrect settings: 'ANSI_NULLS, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. (1934) (SQLExecDirectW)")
My database currently has SET options like this:
SELECT
is_ansi_nulls_on,
is_ansi_padding_on,
is_ansi_warnings_on,
is_arithabort_on,
is_concat_null_yields_null_on,
is_numeric_roundabort_on,
is_quoted_identifier_on
FROM sys.databases
is_ansi_nulls_on is_ansi_padding_on is_ansi_warnings_on is_arithabort_on is_concat_null_yields_null_on is_numeric_roundabort_on is_quoted_identifier_on
0 0 0 0 0 0 0
I only receive this error in production and not when running in development on my laptop. I understand that I need to correctly update the SET options, per the error and this answer: https://stackoverflow.com/a/9235638/1753891
How can I tell django-pyodbc-azure to send the correct SET options prior to updating this table?
Or do I need to update the options on the database itself and, if so, are they any potential pitfalls to watch out for if I change these SET options?