From: Michael Bayer Date: Tue, 6 Feb 2024 00:27:53 +0000 (+0000) Subject: Merge "add additional IMV UUID tests, fix pymssql case" into rel_2_0 X-Git-Tag: rel_2_0_26~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=753f46fc0c03e0a1a405c72f529abc2249b8f583;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Merge "add additional IMV UUID tests, fix pymssql case" into rel_2_0 --- 753f46fc0c03e0a1a405c72f529abc2249b8f583 diff --cc lib/sqlalchemy/sql/sqltypes.py index 2ba63cdbbf,b359fe97bd..764f9a382e --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@@ -3679,8 -3723,34 +3679,33 @@@ class Uuid(Emulated, TypeEngine[_UUID_R return process + def _sentinel_value_resolver(self, dialect): + """For the "insertmanyvalues" feature only, return a callable that + will receive the uuid object or string + as it is normally passed to the DB in the parameter set, after + bind_processor() is called. Convert this value to match + what it would be as coming back from a RETURNING or similar + statement for the given backend. + + Individual dialects and drivers may need their own implementations + based on how their UUID types send data and how the drivers behave + (e.g. pyodbc) + + """ + if not self.native_uuid or not dialect.supports_native_uuid: + # dealing entirely with strings going in and out of + # CHAR(32) + return None + + elif self.as_uuid: + # we sent UUID objects and we are getting UUID objects back + return None + else: + # we sent strings and we are getting UUID objects back + return _python_UUID + class UUID(Uuid[_UUID_RETURN], type_api.NativeForEmulated): - """Represent the SQL UUID type. This is the SQL-native form of the :class:`_types.Uuid` database agnostic