ddsql 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ddsql
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: SQL Query Library
5
5
  Keywords: python,ddsql
6
6
  Author: davyddd
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Classifier: Programming Language :: Python :: 3.14
14
14
  Classifier: Typing :: Typed
15
- Requires-Dist: ddutils>=0.2.0,<0.3.0
15
+ Requires-Dist: ddutils>=0.3.0,<0.4.0
16
16
  Requires-Dist: jinja2>=3.0.0,<4.0.0
17
17
  Requires-Python: >=3.11, <3.15
18
18
  Project-URL: Repository, https://github.com/davyddd/ddsql
@@ -71,6 +71,11 @@ or create your own by inheriting from `BaseSerializer`.
71
71
  | `date` | `'2025-01-01'` | `'2025-01-01'::date` | `toDate('2025-01-01')` |
72
72
  | `list`/`tuple`/`set` | `(item1, item2, ...)` | `(item1, item2, ...)` | `(item1, item2, ...)` |
73
73
 
74
+ An `Enum` member is serialized by its value: `Kind.ADMIN` of a `class Kind(str, Enum)` renders as `'admin'`,
75
+ a plain `Enum` holding a `datetime` as that `datetime`. A subclass is matched as its base type
76
+ (a `ProfileId(UUID)` as a `UUID`, a `pendulum.DateTime` as a `datetime`). `bytes` and `bytearray` are not
77
+ serialized: like any other type missing from the table they go to `serialize_other_object`.
78
+
74
79
  String values are escaped according to the dialect rules, so quotes, backslashes
75
80
  and control characters cannot break the query:
76
81
 
@@ -51,6 +51,11 @@ or create your own by inheriting from `BaseSerializer`.
51
51
  | `date` | `'2025-01-01'` | `'2025-01-01'::date` | `toDate('2025-01-01')` |
52
52
  | `list`/`tuple`/`set` | `(item1, item2, ...)` | `(item1, item2, ...)` | `(item1, item2, ...)` |
53
53
 
54
+ An `Enum` member is serialized by its value: `Kind.ADMIN` of a `class Kind(str, Enum)` renders as `'admin'`,
55
+ a plain `Enum` holding a `datetime` as that `datetime`. A subclass is matched as its base type
56
+ (a `ProfileId(UUID)` as a `UUID`, a `pendulum.DateTime` as a `datetime`). `bytes` and `bytearray` are not
57
+ serialized: like any other type missing from the table they go to `serialize_other_object`.
58
+
54
59
  String values are escaped according to the dialect rules, so quotes, backslashes
55
60
  and control characters cannot break the query:
56
61
 
@@ -4,6 +4,9 @@ from decimal import Decimal
4
4
  from typing import Any
5
5
  from uuid import UUID
6
6
 
7
+ from ddutils.annotation_helpers import NON_COMPLEX_SEQUENCE_TYPES
8
+ from ddutils.value_helpers import unwrap_enum
9
+
7
10
 
8
11
  class BaseSerializer:
9
12
  @property
@@ -11,6 +14,9 @@ class BaseSerializer:
11
14
  return {'serialize_value': self.serialize_value}
12
15
 
13
16
  def serialize_value(self, value: Any) -> str:
17
+ # an `Enum` member is serialized by its value: `f'{Kind.A}'` of a `class Kind(int, Enum)` is 'Kind.A', not '1'
18
+ value = unwrap_enum(value)
19
+
14
20
  if value is None:
15
21
  return self.serialize_none(value)
16
22
  elif isinstance(value, bool):
@@ -27,7 +33,8 @@ class BaseSerializer:
27
33
  # the check for date must come after datetime,
28
34
  # because a datetime instance can also be identified as a date
29
35
  return self.serialize_date(value)
30
- elif isinstance(value, Collection) and not isinstance(value, Mapping):
36
+ elif isinstance(value, Collection) and not isinstance(value, (Mapping, *NON_COMPLEX_SEQUENCE_TYPES)):
37
+ # `bytes` is a collection of ints, but has no SQL representation here
31
38
  return self.serialize_collection(value)
32
39
  else:
33
40
  return self.serialize_other_object(value)
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "ddsql"
3
3
  description = "SQL Query Library"
4
- version = "0.3.0"
4
+ version = "0.3.1"
5
5
  license = "MIT"
6
6
  license-files = ["LICENSE"]
7
7
  readme = "README.md"
@@ -19,7 +19,7 @@ classifiers = [
19
19
  "Typing :: Typed",
20
20
  ]
21
21
  dependencies = [
22
- "ddutils>=0.2.0,<0.3.0",
22
+ "ddutils>=0.3.0,<0.4.0",
23
23
  "jinja2>=3.0.0,<4.0.0",
24
24
  ]
25
25
 
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "ddsql"
3
3
  description = "SQL Query Library"
4
- version = "0.3.0"
4
+ version = "0.3.1"
5
5
  authors = [{ name = "davyddd" }]
6
6
  license = "MIT"
7
7
  license-files = ["LICENSE"]
@@ -18,7 +18,7 @@ classifiers = [
18
18
  "Typing :: Typed",
19
19
  ]
20
20
  dependencies = [
21
- "ddutils>=0.2.0,<0.3.0",
21
+ "ddutils>=0.3.0,<0.4.0",
22
22
  "jinja2>=3.0.0,<4.0.0",
23
23
  ]
24
24
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes