From 54c361477c721c67937867ae14c44f58970d9b6a Mon Sep 17 00:00:00 2001 From: Yeray Rodriguez Marco Date: Wed, 14 May 2025 16:16:30 +0200 Subject: [PATCH 1/3] Fixing enum filtering by escaping value --- odata/enumtype.py | 5 +++++ odata/reflect-templates/enum_entity.mako | 2 -- odata/reflector.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/odata/enumtype.py b/odata/enumtype.py index 8c032fa..59f8613 100644 --- a/odata/enumtype.py +++ b/odata/enumtype.py @@ -21,6 +21,11 @@ def __init__(self, name, enum_class=EnumType): super(EnumTypeProperty, self).__init__(name) self.enum_class = enum_class + def escape_value(self, value): + if self.enum_class.__module__: + return f"Microsoft.Dynamics.DataEntities.{self.enum_class.__name__}'{value.name}'" + return f"{self.enum_class.__name__}'{value.name}'" + def serialize(self, value): return value.name diff --git a/odata/reflect-templates/enum_entity.mako b/odata/reflect-templates/enum_entity.mako index 23cb22b..bcc2f7c 100644 --- a/odata/reflect-templates/enum_entity.mako +++ b/odata/reflect-templates/enum_entity.mako @@ -1,5 +1,3 @@ - - <%page args="name, entity"/>\ <% short_name = name.split(".")[-1] %>\ ${short_name} = Enum("${short_name}", {\ diff --git a/odata/reflector.py b/odata/reflector.py index e2e5f23..138c8d4 100644 --- a/odata/reflector.py +++ b/odata/reflector.py @@ -94,7 +94,7 @@ "FloatProperty": "float", "BooleanProperty": "bool", "UUIDProperty": "uuid.UUID", - "EnumTypeProperty": "str" + "EnumTypeProperty": "Enum" } From 21bc2cf240b39ebed18a44abafeaef06dae9a0d2 Mon Sep 17 00:00:00 2001 From: Yeray Rodriguez Marco Date: Wed, 14 May 2025 16:16:58 +0200 Subject: [PATCH 2/3] Preventing exception for update and insert operations when server_flags attribute is None. --- odata/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odata/context.py b/odata/context.py index f98bb52..4e9c02c 100644 --- a/odata/context.py +++ b/odata/context.py @@ -9,7 +9,7 @@ class Context: - def __init__(self, session=None, auth=None, extra_headers: dict = None, server_flags: ODataServerFlags = None): + def __init__(self, session=None, auth=None, extra_headers: dict = None, server_flags: ODataServerFlags = ODataServerFlags()): self.log = logging.getLogger('odata.context') self.connection = ODataConnection(session=session, auth=auth, extra_headers=extra_headers) self.server_flags = server_flags From 73fc714f7e96a3548a5a63577d53a6771a04c3c1 Mon Sep 17 00:00:00 2001 From: Yeray Rodriguez Marco Date: Wed, 14 May 2025 16:18:21 +0200 Subject: [PATCH 3/3] Adding missing docstring --- odata/service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odata/service.py b/odata/service.py index dc2aa68..dc7e03a 100644 --- a/odata/service.py +++ b/odata/service.py @@ -91,6 +91,7 @@ class ODataService(object): :param auth: Custom Requests auth object to use for credentials :param console: Rich console instance to use for messages. If set to None a new console will be created. Console will inherit quiet flag from quiet_progress. :param quiet_progress: Don't show any progress information while reflecting metadata and while other long duration tasks are running. Default is to show progress + :param server_flags: Server specific flags for an OData server :raises ODataConnectionError: Fetching metadata failed. Server returned an HTTP error code """