Skip to content
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

Support UUID #329

Merged
merged 41 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f2e51b4
basic 5.0 support
mShan0 Sep 13, 2023
c8a5f61
use django main branch
mShan0 Sep 13, 2023
8a1a95e
use alpha 5.0 branch
mShan0 Sep 19, 2023
7f43768
preliminary fix for nulls_distinct
mShan0 Oct 4, 2023
0f4008e
add _unique_supported function
mShan0 Oct 4, 2023
5f4993a
Fix schema db default test
dauinsight Oct 16, 2023
b448063
Skip constraint tests
dauinsight Oct 16, 2023
5c30ab6
Merge pull request #305 from microsoft/fix-schema-tests
dauinsight Oct 18, 2023
ff6a636
Merge pull request #306 from microsoft/skip-constraint-tests
dauinsight Oct 18, 2023
8014815
Merge branch 'dev' into django50
mShan0 Oct 26, 2023
4e280b4
Support db_default field
dauinsight Nov 7, 2023
b3538c2
Remove operations test fixes
dauinsight Nov 7, 2023
880bccd
Preliminary fix
dauinsight Nov 7, 2023
023b8ca
Check version before accessing db_default
dauinsight Nov 8, 2023
6ff7d2a
Merge branch 'support-db-default' into fix-operation-tests
dauinsight Nov 8, 2023
4d76857
Skip add field database default test
dauinsight Nov 8, 2023
acc440f
Update returned values from insert
dauinsight Nov 10, 2023
360004f
Change can_return_rows_from_bulk_insert default to True
dauinsight Nov 17, 2023
06b58fc
Revert format sql changes
dauinsight Nov 17, 2023
8b1e9e0
Prevent formatting empty params query
dauinsight Nov 20, 2023
becbdd0
unskip add_field_database_default
dauinsight Nov 20, 2023
489a107
Merge pull request #314 from microsoft/fix-operation-tests
dauinsight Nov 21, 2023
78f1bc6
fix add_field_both_defaults test
dauinsight Nov 22, 2023
2220304
Update nullable default field behavior
dauinsight Nov 22, 2023
ee87e48
update odbc 17 windows ci
mShan0 Nov 28, 2023
8c05068
Merge pull request #313 from microsoft/support-db-default
dauinsight Nov 29, 2023
6c564b0
reduce tox tests for testing purposes
mShan0 Dec 12, 2023
70565fd
bump tox version to 5.0
mShan0 Dec 12, 2023
ef695a6
Merge branch 'django50' into 50-ci
mShan0 Dec 12, 2023
0e09564
add field_defaults
mShan0 Dec 14, 2023
0851ef7
Fix default constraints test
dauinsight Dec 21, 2023
7d55721
unskip tox tests
dauinsight Dec 21, 2023
47af010
Merge pull request #319 from microsoft/50-ci
mShan0 Dec 22, 2023
5976f06
Merge branch 'dev' into 50-merge-conflicts
mShan0 Dec 22, 2023
6b7e771
Add support for uuid
dauinsight Jan 4, 2024
bbc279b
Merge branch 'django50' into support-uuid
dauinsight Jan 4, 2024
f378675
Update UUIDField mapping
dauinsight Jan 23, 2024
57885ab
Merge branch 'dev' into support-uuid
dauinsight Jan 23, 2024
0edcee2
Enable native UUID flag for pyodbc
dauinsight Feb 2, 2024
5d51acd
Merge branch 'dev' into support-uuid
dauinsight Feb 2, 2024
2a69c07
Merge branch 'dev' into support-uuid
dauinsight Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mssql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
'SmallIntegerField': 'smallint',
'TextField': 'nvarchar(max)',
'TimeField': 'time',
'UUIDField': 'char(32)',
'UUIDField': 'uniqueidentifier',
}
data_types_suffix = {
'AutoField': 'IDENTITY (1, 1)',
Expand Down Expand Up @@ -376,7 +376,6 @@ def get_new_connection(self, conn_params):
break
if not need_to_retry:
raise

# Handling values from DATETIMEOFFSET columns
# source: https://github.com/mkleehammer/pyodbc/wiki/Using-an-Output-Converter-function
conn.add_output_converter(SQL_TIMESTAMP_WITH_TIMEZONE, handle_datetimeoffset)
Expand Down Expand Up @@ -431,6 +430,9 @@ def init_connection_state(self):
if (options.get('return_rows_bulk_insert', False)):
self.features_class.can_return_rows_from_bulk_insert = True

if (options.get('has_native_uuid_field', True)):
Database.native_uuid = True

val = self.get_system_datetime
if isinstance(val, str):
raise ImproperlyConfigured(
Expand Down
3 changes: 2 additions & 1 deletion mssql/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
has_json_object_function = False
has_json_operators = False
has_native_json_field = False
has_native_uuid_field = False
has_native_uuid_field = True
has_real_datatype = True
has_select_for_update = True
has_select_for_update_nowait = True
Expand Down Expand Up @@ -64,6 +64,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_stored_generated_columns = True
supports_virtual_generated_columns = True


@cached_property
def has_zoneinfo_database(self):
with self.connection.cursor() as cursor:
Expand Down
2 changes: 1 addition & 1 deletion mssql/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def convert_floatfield_value(self, value, expression, connection):

def convert_uuidfield_value(self, value, expression, connection):
if value is not None:
value = uuid.UUID(value)
value = uuid.UUID(str(value))
return value

def convert_booleanfield_value(self, value, expression, connection):
Expand Down
Loading