ormlambda 3.35.2__py3-none-any.whl → 4.0.0__py3-none-any.whl

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.
Files changed (130) hide show
  1. ormlambda/__init__.py +79 -51
  2. ormlambda/caster/caster.py +6 -1
  3. ormlambda/common/abstract_classes/__init__.py +0 -2
  4. ormlambda/common/enums/__init__.py +1 -0
  5. ormlambda/common/enums/order_type.py +9 -0
  6. ormlambda/common/errors/__init__.py +13 -3
  7. ormlambda/common/global_checker.py +86 -8
  8. ormlambda/common/interfaces/IQueryCommand.py +2 -2
  9. ormlambda/common/interfaces/__init__.py +0 -2
  10. ormlambda/dialects/__init__.py +75 -3
  11. ormlambda/dialects/default/base.py +1 -1
  12. ormlambda/dialects/mysql/__init__.py +35 -78
  13. ormlambda/dialects/mysql/base.py +226 -40
  14. ormlambda/dialects/mysql/clauses/ST_AsText.py +26 -0
  15. ormlambda/dialects/mysql/clauses/ST_Contains.py +30 -0
  16. ormlambda/dialects/mysql/clauses/__init__.py +1 -0
  17. ormlambda/dialects/mysql/repository/__init__.py +1 -0
  18. ormlambda/{databases/my_sql → dialects/mysql/repository}/repository.py +0 -5
  19. ormlambda/dialects/mysql/types.py +6 -0
  20. ormlambda/engine/base.py +26 -4
  21. ormlambda/errors.py +9 -0
  22. ormlambda/model/base_model.py +3 -10
  23. ormlambda/repository/base_repository.py +1 -1
  24. ormlambda/repository/interfaces/IRepositoryBase.py +0 -7
  25. ormlambda/repository/response.py +12 -7
  26. ormlambda/sql/__init__.py +12 -3
  27. ormlambda/sql/clause_info/__init__.py +0 -2
  28. ormlambda/sql/clause_info/clause_info.py +94 -76
  29. ormlambda/sql/clause_info/interface/IAggregate.py +14 -4
  30. ormlambda/sql/clause_info/interface/IClauseInfo.py +6 -11
  31. ormlambda/sql/clauses/alias.py +6 -37
  32. ormlambda/sql/clauses/count.py +21 -36
  33. ormlambda/sql/clauses/group_by.py +13 -19
  34. ormlambda/sql/clauses/having.py +2 -6
  35. ormlambda/sql/clauses/insert.py +3 -3
  36. ormlambda/sql/clauses/interfaces/__init__.py +0 -1
  37. ormlambda/sql/clauses/join/join_context.py +5 -12
  38. ormlambda/sql/clauses/joins.py +34 -52
  39. ormlambda/sql/clauses/limit.py +1 -2
  40. ormlambda/sql/clauses/offset.py +1 -2
  41. ormlambda/sql/clauses/order.py +17 -21
  42. ormlambda/sql/clauses/select.py +56 -28
  43. ormlambda/sql/clauses/update.py +13 -10
  44. ormlambda/sql/clauses/where.py +20 -39
  45. ormlambda/sql/column/__init__.py +1 -0
  46. ormlambda/sql/column/column.py +19 -12
  47. ormlambda/sql/column/column_proxy.py +117 -0
  48. ormlambda/sql/column_table_proxy.py +23 -0
  49. ormlambda/sql/comparer.py +31 -65
  50. ormlambda/sql/compiler.py +248 -58
  51. ormlambda/sql/context/__init__.py +304 -0
  52. ormlambda/sql/ddl.py +19 -5
  53. ormlambda/sql/elements.py +3 -0
  54. ormlambda/sql/foreign_key.py +42 -64
  55. ormlambda/sql/functions/__init__.py +0 -1
  56. ormlambda/sql/functions/concat.py +35 -38
  57. ormlambda/sql/functions/max.py +12 -36
  58. ormlambda/sql/functions/min.py +13 -28
  59. ormlambda/sql/functions/sum.py +17 -33
  60. ormlambda/sql/sqltypes.py +2 -0
  61. ormlambda/sql/table/__init__.py +1 -0
  62. ormlambda/sql/table/table.py +32 -49
  63. ormlambda/sql/table/table_proxy.py +88 -0
  64. ormlambda/sql/type_api.py +4 -1
  65. ormlambda/sql/types.py +15 -12
  66. ormlambda/statements/__init__.py +0 -2
  67. ormlambda/statements/base_statement.py +51 -84
  68. ormlambda/statements/interfaces/IStatements.py +77 -123
  69. ormlambda/statements/interfaces/__init__.py +1 -1
  70. ormlambda/statements/query_builder.py +296 -128
  71. ormlambda/statements/statements.py +120 -110
  72. ormlambda/statements/types.py +5 -25
  73. ormlambda/util/__init__.py +7 -86
  74. ormlambda/util/langhelpers.py +102 -0
  75. ormlambda/util/module_tree/dynamic_module.py +1 -1
  76. ormlambda/util/preloaded.py +80 -0
  77. ormlambda/util/typing.py +12 -3
  78. {ormlambda-3.35.2.dist-info → ormlambda-4.0.0.dist-info}/METADATA +29 -31
  79. ormlambda-4.0.0.dist-info/RECORD +139 -0
  80. ormlambda/common/abstract_classes/clause_info_converter.py +0 -65
  81. ormlambda/common/abstract_classes/decomposition_query.py +0 -141
  82. ormlambda/common/abstract_classes/query_base.py +0 -15
  83. ormlambda/common/interfaces/ICustomAlias.py +0 -7
  84. ormlambda/common/interfaces/IDecompositionQuery.py +0 -33
  85. ormlambda/databases/__init__.py +0 -4
  86. ormlambda/databases/my_sql/__init__.py +0 -3
  87. ormlambda/databases/my_sql/clauses/ST_AsText.py +0 -37
  88. ormlambda/databases/my_sql/clauses/ST_Contains.py +0 -36
  89. ormlambda/databases/my_sql/clauses/__init__.py +0 -14
  90. ormlambda/databases/my_sql/clauses/count.py +0 -33
  91. ormlambda/databases/my_sql/clauses/delete.py +0 -9
  92. ormlambda/databases/my_sql/clauses/drop_table.py +0 -26
  93. ormlambda/databases/my_sql/clauses/group_by.py +0 -17
  94. ormlambda/databases/my_sql/clauses/having.py +0 -12
  95. ormlambda/databases/my_sql/clauses/insert.py +0 -9
  96. ormlambda/databases/my_sql/clauses/joins.py +0 -14
  97. ormlambda/databases/my_sql/clauses/limit.py +0 -6
  98. ormlambda/databases/my_sql/clauses/offset.py +0 -6
  99. ormlambda/databases/my_sql/clauses/order.py +0 -8
  100. ormlambda/databases/my_sql/clauses/update.py +0 -8
  101. ormlambda/databases/my_sql/clauses/upsert.py +0 -9
  102. ormlambda/databases/my_sql/clauses/where.py +0 -7
  103. ormlambda/dialects/interface/__init__.py +0 -1
  104. ormlambda/dialects/interface/dialect.py +0 -78
  105. ormlambda/sql/clause_info/aggregate_function_base.py +0 -96
  106. ormlambda/sql/clause_info/clause_info_context.py +0 -87
  107. ormlambda/sql/clauses/interfaces/ISelect.py +0 -17
  108. ormlambda/sql/clauses/new_join.py +0 -119
  109. ormlambda/util/load_module.py +0 -21
  110. ormlambda/util/plugin_loader.py +0 -32
  111. ormlambda-3.35.2.dist-info/RECORD +0 -159
  112. /ormlambda/{databases/my_sql → dialects/mysql}/caster/__init__.py +0 -0
  113. /ormlambda/{databases/my_sql → dialects/mysql}/caster/caster.py +0 -0
  114. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/__init__.py +0 -0
  115. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/boolean.py +0 -0
  116. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/bytes.py +0 -0
  117. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/date.py +0 -0
  118. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/datetime.py +0 -0
  119. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/decimal.py +0 -0
  120. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/float.py +0 -0
  121. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/int.py +0 -0
  122. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/iterable.py +0 -0
  123. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/json.py +0 -0
  124. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/none.py +0 -0
  125. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/point.py +0 -0
  126. /ormlambda/{databases/my_sql → dialects/mysql}/caster/types/string.py +0 -0
  127. /ormlambda/{databases/my_sql → dialects/mysql/repository}/pool_types.py +0 -0
  128. {ormlambda-3.35.2.dist-info → ormlambda-4.0.0.dist-info}/AUTHORS +0 -0
  129. {ormlambda-3.35.2.dist-info → ormlambda-4.0.0.dist-info}/LICENSE +0 -0
  130. {ormlambda-3.35.2.dist-info → ormlambda-4.0.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,80 @@
1
+ from typing import Callable, TYPE_CHECKING
2
+ import importlib
3
+
4
+ type FuncType[T] = Callable[..., T]
5
+
6
+
7
+ if TYPE_CHECKING:
8
+ from ormlambda.sql import table as _sql_table
9
+ from ormlambda.sql import column as _sql_column
10
+ from ormlambda.sql import comparer as _sql_comparer
11
+ from ormlambda.sql import column_table_proxy as _sql_column_table_proxy
12
+ from ormlambda.sql import foreign_key as _sql_foreign_key
13
+ from ormlambda.sql import clause_info as _sql_clause_info
14
+ from ormlambda.sql import sqltypes as _sql_sqltypes
15
+ from ormlambda.sql import clauses as _sql_clauses
16
+ from ormlambda.sql import type_api as _sql_type_api
17
+
18
+ sql_column = _sql_column
19
+ sql_table = _sql_table
20
+ sql_comparer = _sql_comparer
21
+ sql_column_table_proxy = _sql_column_table_proxy
22
+ sql_foreign_key = _sql_foreign_key
23
+ sql_clause_info = _sql_clause_info
24
+ sql_types = _sql_sqltypes
25
+ sql_clauses = _sql_clauses
26
+
27
+ sql_type_api = _sql_type_api
28
+
29
+ class ModuleRegistry:
30
+ """Registry of modules to load in a package init file.
31
+
32
+ To avoid potential thread safety issues for imports that are deferred
33
+ in a function, like https://bugs.python.org/issue38884, these modules
34
+ are added to the system module cache by importing them after the packages
35
+ has finished initialization.
36
+
37
+ A global instance is provided under the name :attr:`.preloaded`. Use
38
+ the function :func:`.preload_module` to register modules to load and
39
+ :meth:`.import_prefix` to load all the modules that start with the
40
+ given path.
41
+
42
+ While the modules are loaded in the global module cache, it's advisable
43
+ to access them using :attr:`.preloaded` to ensure that it was actually
44
+ registered. Each registered module is added to the instance ``__dict__``
45
+ in the form `<package>_<module>`, omitting ``sqlalchemy`` from the package
46
+ name. Example: ``sqlalchemy.sql.util`` becomes ``preloaded.sql_util``.
47
+ """
48
+
49
+ def __init__(self, prefix="ormlambda."):
50
+ self.module_registry: set[str] = set()
51
+ self.prefix: str = prefix
52
+
53
+ def preload_module[T, **P](self, *deps: str) -> Callable[P, T]:
54
+ """Adds the specified modules to the list to load.
55
+
56
+ This method can be used both as a normal function and as a decorator.
57
+ No change is performed to the decorated object.
58
+ """
59
+ self.module_registry.update(deps)
60
+ return lambda fn: fn
61
+
62
+ def import_prefix(self, path: str) -> None:
63
+ """Resolve all the modules in the registry that start with the
64
+ specified path.
65
+ """
66
+ for module in self.module_registry:
67
+ if self.prefix:
68
+ key = module.split(self.prefix)[-1].replace(".", "_")
69
+ else:
70
+ key = module
71
+
72
+ if (not path or module.startswith(path)) and key not in self.__dict__:
73
+ _module = importlib.import_module(module)
74
+ self.__dict__[key] = globals()[key] = _module
75
+ return None
76
+
77
+
78
+ _reg = ModuleRegistry()
79
+ preload_module = _reg.preload_module
80
+ import_prefix = _reg.import_prefix
ormlambda/util/typing.py CHANGED
@@ -1,6 +1,15 @@
1
- import typing as tp
2
1
  import typing_extensions as tpe
2
+ from typing import Any, Literal, Type, NewType, get_origin, TypeGuard, TypeAliasType
3
3
 
4
- LITERAL_TYPES = frozenset([tp.Literal, tpe.Literal])
5
4
 
6
- type _AnnotationScanType = tp.Type[tp.Any] | str | tp.NewType
5
+ LITERAL_TYPES = frozenset([Literal, tpe.Literal])
6
+
7
+ type _AnnotationScanType = Type[Any] | str | NewType
8
+
9
+
10
+ def is_literal(type_: Any) -> bool:
11
+ return get_origin(type) in LITERAL_TYPES
12
+
13
+
14
+ def is_pep695(type_: _AnnotationScanType) -> TypeGuard[TypeAliasType]:
15
+ return isinstance(type_, TypeAliasType)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ormlambda
3
- Version: 3.35.2
3
+ Version: 4.0.0
4
4
  Summary: ORM designed to interact with the database (currently with MySQL) using lambda functions and nested functions
5
5
  Author: p-hzamora
6
6
  Author-email: p.hzamora@icloud.com
@@ -296,19 +296,19 @@ with this approach, we will obtain a dictionary where the key will be the concat
296
296
 
297
297
  ## max
298
298
  ```python
299
- res = AddressModel.max(Address.address_id, execute=True)
299
+ res = AddressModel.max(lambda x: x.address_id)
300
300
  ```
301
301
  ## min
302
302
  ```python
303
- res = AddressModel.min(Address.address_id, execute=True)
303
+ res = AddressModel.min(lambda x: x.address_id)
304
304
  ```
305
305
  ## sum
306
306
  ```python
307
- res = AddressModel.sum(Address.address_id, execute=True)
307
+ res = AddressModel.sum(lambda x: x.address_id)
308
308
  ```
309
309
  ## count
310
310
  ```python
311
- res = AddressModel.count(Address.address_id, execute=True)
311
+ res = AddressModel.count(lambda x: x.address_id)
312
312
  ```
313
313
 
314
314
  ## 1. Concat
@@ -322,14 +322,14 @@ response = ORM(Address, db).where(Address.City.Country.country.regex(r"^Spain"))
322
322
  (
323
323
  Address.address,
324
324
  Address.City.city,
325
- self.tmodel.concat(
325
+ Concat(lambda x:
326
326
  (
327
327
  "Address: ",
328
- Address.address,
328
+ x.address,
329
329
  " - city: ",
330
- Address.City.city,
330
+ x.City.city,
331
331
  " - country: ",
332
- Address.City.Country.country,
332
+ x.City.Country.country,
333
333
  )
334
334
  ),
335
335
  ),
@@ -364,15 +364,13 @@ class Response(BaseModel):
364
364
  engine= create_engine(DATABASE_URL)
365
365
  model = ORM(Address,engine)
366
366
 
367
- count_name = Column(column_name="count")
368
-
369
367
  res = (
370
368
  self.model
371
- .groupby(Address.district)
372
- .select(
369
+ .groupby(lambda x: x.district)
370
+ .select(lambda x:
373
371
  (
374
- Address.district,
375
- self.model.count(Address.address),
372
+ x.district,
373
+ Count(x.address),
376
374
  ),
377
375
  flavour=Response,
378
376
  )
@@ -387,12 +385,12 @@ The `having` method is used to filter results based on aggregate functions. It i
387
385
  ```python
388
386
  res = (
389
387
  model
390
- .groupby(Address.district)
391
- .having(count_name > 4)
392
- .select(
388
+ .groupby(lambda x: x.district)
389
+ .having(lambda x: x.count > 4)
390
+ .select(lambda x:
393
391
  (
394
- Address.district,
395
- model.count(Address.address),
392
+ x.district,
393
+ Count(x.address),
396
394
  ),
397
395
  flavour=Response,
398
396
  )
@@ -422,9 +420,9 @@ select = (
422
420
  ORM(Address, db)
423
421
  .order(lambda x: x.City.Country.country, "DESC")
424
422
  .limit(10)
425
- .where(Address.City.Country.country == "Spain")
426
- .first(
427
- lambda x: (
423
+ .where(lambda x: x.City.Country.country == "Spain")
424
+ .first(lambda x:
425
+ (
428
426
  x.address,
429
427
  x.City.city,
430
428
  x.City.Country.country,
@@ -449,9 +447,9 @@ As shown in the previous examples, setting the `execute` attribute to `True` all
449
447
  ```python
450
448
  result = AddressModel.select_one(
451
449
  lambda x: (
452
- AddressModel.min(x.address_id),
453
- AddressModel.max(x.address_id),
454
- AddressModel.count(x.address_id),
450
+ Min(x.address_id),
451
+ Max(x.address_id),
452
+ Count(x.address_id),
455
453
  ),flavour=dict
456
454
  )
457
455
  ```
@@ -468,11 +466,11 @@ Getting something like
468
466
  You also can use custom alias for each method
469
467
 
470
468
  ```python
471
- AddressModel.select_one(
472
- lambda x: (
473
- AddressModel.min(x.address_id),
474
- AddressModel.max(x.address_id, alias="custom-max"),
475
- AddressModel.count(x.address_id),
469
+ AddressModel.select_one(lambda x:
470
+ (
471
+ Min(x.address_id),
472
+ Max(x.address_id, alias="custom-max"),
473
+ Count(x.address_id),
476
474
  ),
477
475
  flavour=dict,
478
476
  )
@@ -0,0 +1,139 @@
1
+ ormlambda/__init__.py,sha256=RmBuEDu4a6i8JcShsG-CWFVFhruc-YKz4_Fo5VYrcPQ,3053
2
+ ormlambda/caster/__init__.py,sha256=lXzW6TJwgtyFTaBhKBETyGIxEje005S3SPg7PXnYEVQ,137
3
+ ormlambda/caster/base_caster.py,sha256=c3vCGoKDyJ39kfUiS7sNKhKdjBRYSK1Ie88lwDIXqgE,1774
4
+ ormlambda/caster/caster.py,sha256=qOKgNkoZQqTruNfSGLU0h7V-mZA19KY0uhRzjS6EGxc,2616
5
+ ormlambda/caster/interfaces/ICaster.py,sha256=MCBBVBho9KH67vCcUk8nclY0a7QoqxgdyVJJR0-QDT0,759
6
+ ormlambda/caster/interfaces/__init__.py,sha256=TRoIxxgxuhUhCJq2ldLS3UEa1THrMXEIyTH5K46vyGw,43
7
+ ormlambda/common/__init__.py,sha256=g4yGxH4WEgvQ7Rix4lpp3FQ-3SeRhptNd5sabgZLQNk,59
8
+ ormlambda/common/abstract_classes/__init__.py,sha256=iXhV9U5e8HIis4IhiF_w5fyAAdJclZDUGRJBkZA_AyM,57
9
+ ormlambda/common/abstract_classes/non_query_base.py,sha256=eLXAprXVjVk2sFF8X8EK0UKoOQpgxBlDRn8prLzjr30,1201
10
+ ormlambda/common/enums/__init__.py,sha256=daxD_1Xmrg3txPpzkvdy_VLEbiGPgnD336hMz4nvd0E,151
11
+ ormlambda/common/enums/condition_types.py,sha256=QZnhhlTwzLcZ9kkmG6a08fQjUUJsJ5XGAH7QCiJRL1A,330
12
+ ormlambda/common/enums/join_type.py,sha256=EosZVnvAc72LlZHuICIgoKWwUJzhvWOIIAohcbDYPQo,354
13
+ ormlambda/common/enums/order_type.py,sha256=MOwMIUWn8H-3_BmMpEHcxUK7KNkVlmxrTBfp6etdF44,138
14
+ ormlambda/common/errors/__init__.py,sha256=27NGxp4I4wqhn-TIT9e97IlGb7Blx9RTCFrY8CgACRM,2316
15
+ ormlambda/common/global_checker.py,sha256=l_kN9mejC9kz5xyTEnrJ6adXDLW47cDofJfS9ATHFTI,3634
16
+ ormlambda/common/interfaces/IJoinSelector.py,sha256=-w-MJmwq65tpDLtigWSLgvAqeOl75DA-EyWIugNkfCs,490
17
+ ormlambda/common/interfaces/INonQueryCommand.py,sha256=7CjLW4sKqkR5zUIGvhRXOtzTs6vypJW1a9EJHlgCw2c,260
18
+ ormlambda/common/interfaces/IQueryCommand.py,sha256=PKkAI1SE6U7kcbqFgQsdTQ3asIx-gIp5RDXYlBfANJk,461
19
+ ormlambda/common/interfaces/__init__.py,sha256=-qIJf5fBX0y0vq_O7YjImWFimbj5pqONzK8udH2CMX4,169
20
+ ormlambda/dialects/__init__.py,sha256=-WM-PqZXgZ_-3KWWLSNrPV12FhvVbo_v8Ul3XCUjs0o,3536
21
+ ormlambda/dialects/default/__init__.py,sha256=N1B0LKEDu7r2-mTF9mBA4ReyhYeDuJDnbQCiH4hJvFQ,33
22
+ ormlambda/dialects/default/base.py,sha256=Xle5kD_wi94NiPnkShi5LJbe5M1k8hq_XhU_PZ-iFbs,1078
23
+ ormlambda/dialects/mysql/__init__.py,sha256=DwoefrtyJUivg7z4QS4K2k0DrUu04ItC5LJcDQEYZWg,1398
24
+ ormlambda/dialects/mysql/base.py,sha256=BDEoWUpGB7ss6ZpzZzu8gMUCM33N_pwYgNbh5tmQ30A,21493
25
+ ormlambda/dialects/mysql/caster/__init__.py,sha256=Df2sdZaAJ1Mi5Ego0sILMk5pF1NbK-nlV0hbpzd0PWE,47
26
+ ormlambda/dialects/mysql/caster/caster.py,sha256=G2CDqkrmsxFrHe_nDOmqqrTA_3O2o6gIIfukqPeHmJs,1021
27
+ ormlambda/dialects/mysql/caster/types/__init__.py,sha256=BmtHuVvKGPIOCjVuqQZgtGBMnx15YnGBaBi4r3Hd-3U,587
28
+ ormlambda/dialects/mysql/caster/types/boolean.py,sha256=EYOxnR7-XU30UYZbBbMH4pyynTw5CPU1G8V5xpCthg4,1100
29
+ ormlambda/dialects/mysql/caster/types/bytes.py,sha256=Mzl5oI2q6hGL9TFrTS-Ae1olQlAVtvNoxTSLUSBb5v8,1026
30
+ ormlambda/dialects/mysql/caster/types/date.py,sha256=8usP1Af7WUzEC8BHOBL16Zjg9j-ipMlb42p0UTFELmg,1176
31
+ ormlambda/dialects/mysql/caster/types/datetime.py,sha256=ISzcsbwijTa2wC9ZD8zy5piRm9BdnT9GxkMNf4FQYug,1189
32
+ ormlambda/dialects/mysql/caster/types/decimal.py,sha256=ycQnSqO-aFkrcsa8JKVPdnfjotNL_BUFeScYRcueOWM,1068
33
+ ormlambda/dialects/mysql/caster/types/float.py,sha256=EbU6J3yoL5_naLowfibkfUC9Bk9WzDaWks7lJ2pNhyA,1026
34
+ ormlambda/dialects/mysql/caster/types/int.py,sha256=a30xbe0LNj2BvbtLNZhUXFvT3WJ115MFsHC19Y3NLTk,1016
35
+ ormlambda/dialects/mysql/caster/types/iterable.py,sha256=S7pEAJ_NaxZqYhJAXwaJBS_zrbSz9J2yiYPpmDHATso,1057
36
+ ormlambda/dialects/mysql/caster/types/json.py,sha256=AR7D6CEgyK3zAEijyNO1AuWtLBgC7KTj-YNEWkyilkg,1042
37
+ ormlambda/dialects/mysql/caster/types/none.py,sha256=Bl4jpVVyoLG7ehoCAYj9lFBZbRWbyDN8QsQeWmIb84I,948
38
+ ormlambda/dialects/mysql/caster/types/point.py,sha256=GHAf51kE0AS7wOlCYM9YW-z2ZbmY8hXwcHs979ZCeaY,1442
39
+ ormlambda/dialects/mysql/caster/types/string.py,sha256=WFjTC5phuJ_-ShuokndFbqGuFgGZZx9GbpozH4rlB2g,1017
40
+ ormlambda/dialects/mysql/clauses/ST_AsText.py,sha256=CC9mAAWtU8Vw79Un1ZjQHljsFqaBIW2GHAsoZfn6RO8,726
41
+ ormlambda/dialects/mysql/clauses/ST_Contains.py,sha256=Oexez4rYLTlmWb1sKj4ZVolUqK8BRvgdj2sX3ROVIOc,737
42
+ ormlambda/dialects/mysql/clauses/__init__.py,sha256=n5MMwLhDypwXIJyZd-ggPt8GbTxozIAUfzu5wObbQn0,46
43
+ ormlambda/dialects/mysql/mysqlconnector.py,sha256=DOjK7U7LOhjuVQJULzAV8xaRGX0OlBU8APUeRiTcbDY,1378
44
+ ormlambda/dialects/mysql/repository/__init__.py,sha256=yX1XIaVD8U2JT0nliQpcDQGPutXyhmeJnpI_4ZUxapM,53
45
+ ormlambda/dialects/mysql/repository/pool_types.py,sha256=6c7LMS1VGR8ko1LB1T8DQzn1l10Mzk8PfIeYEOb9w30,1839
46
+ ormlambda/dialects/mysql/repository/repository.py,sha256=-LwEWRvyq6_DDmWD2sWiH9x12x0RUDmH94ZID1Xyvac,7067
47
+ ormlambda/dialects/mysql/types.py,sha256=oQUQiriHhmubmfBdJvhRhcq5zyFqJshbqSktvmxlGR8,23671
48
+ ormlambda/dialects/sqlite/__init__.py,sha256=2EMmxD7ORtGoD18GJ_9aC_tPutAq9ormMZJmaJ5nkYA,103
49
+ ormlambda/dialects/sqlite/base.py,sha256=24LSB461yQDEnXa-TsQt_srJmBCAR6M6419pa40CL_4,1503
50
+ ormlambda/dialects/sqlite/pysqlite.py,sha256=dZY0NV2IvSTk3DNEDyncstmIABKj3M2xfmhf2dc2zQs,680
51
+ ormlambda/engine/__init__.py,sha256=JpCLfuW1zcJi4ki97ajXh0aQxMSvWBKzDlBZx9ZVF9o,132
52
+ ormlambda/engine/base.py,sha256=f60O6CLzB7rFBtw7XNxaEw0BccruROzRR-vXBUMcYgQ,2621
53
+ ormlambda/engine/create.py,sha256=caDYXX4BP5uODSrdJXRZvWWjbliDgH1TiSvhtHP3RNY,533
54
+ ormlambda/engine/url.py,sha256=ZzdgZU_Cnjhonbbr5OfBvq_ThUPnDj9v-3-7O54ENm0,26137
55
+ ormlambda/engine/utils.py,sha256=fFoiKsiFuLcjcBVYNebVoYnMrEj3aZdoxEVSNfCY-GM,522
56
+ ormlambda/env.py,sha256=rCZKT2rpvRF3hPtkLmtiaVAIxQ0xj8tF7ZKJpFp7BkA,736
57
+ ormlambda/errors.py,sha256=ltLR52g3fnUTjrDC_x_R9-b5LlLjC6bVACnOoc9-OZg,839
58
+ ormlambda/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
+ ormlambda/model/base_model.py,sha256=lhtJWiGXiRWLOxsuPg0PPr53shhreMy69Ps2-7dYU7U,739
60
+ ormlambda/repository/__init__.py,sha256=4KAhKn6vWV7bslewvGMNqbbbUnz1DLnH4yy-M5QNAQA,112
61
+ ormlambda/repository/base_repository.py,sha256=SW7VsbNddIY8-ALIGYcLlj4tFAoPSepeQpFvDNMOWpg,1252
62
+ ormlambda/repository/interfaces/IDatabaseConnection.py,sha256=pxczjx0b53yjjg5hvVDloMgUTFDahVC3HlJLQjo9_1w,283
63
+ ormlambda/repository/interfaces/IRepositoryBase.py,sha256=jTlViARH5SWIcYXstmXhttvNOShJ5mmAbTEmfGLiRuA,3527
64
+ ormlambda/repository/interfaces/__init__.py,sha256=t8Mn0aRZm8uF4MGaqjEANTTADCdOwNF0THZ_qebyzwo,126
65
+ ormlambda/repository/response.py,sha256=z1e0DlToPZqMCxS3Y36P0lTBOWzhMMkla6k8IiCvYQo,4525
66
+ ormlambda/sql/__init__.py,sha256=C5tpRVPZFnk8h1GSUkAM83u0M-IiOWtxrQSzD5DFZYU,211
67
+ ormlambda/sql/clause_info/__init__.py,sha256=tbDXMGPjIc1e4YpBycjmyh8gRFgqZLva6sH-9awsni4,98
68
+ ormlambda/sql/clause_info/clause_info.py,sha256=OnVyjDcisJK7-exFCgk7xqyXFGMTBMxzIXEg8RF56DI,14107
69
+ ormlambda/sql/clause_info/interface/IAggregate.py,sha256=wdaNxhRYrHqwknljvTEus5PDkt9MD0eufBmphFqsH-8,429
70
+ ormlambda/sql/clause_info/interface/IClauseInfo.py,sha256=vPJWSi6ojSIc931Z8BTYFHkFbSYpEiD5oIdtLby3fBc,820
71
+ ormlambda/sql/clause_info/interface/__init__.py,sha256=bTNYVMPuJebEvQpPa5LBQaAesGnfljQ8BKsj1UxN09k,100
72
+ ormlambda/sql/clauses/__init__.py,sha256=9bkgw3jbd2HdB-WGQtpyHLr0K-SbCZcBU7KmHur7k1c,572
73
+ ormlambda/sql/clauses/alias.py,sha256=EywUwSYTWFOptTEnJ3O6UqLw4IJyd7XXumPM4djbegU,340
74
+ ormlambda/sql/clauses/count.py,sha256=MpbnfNRiylDlL93d25s6XEqCMfgME6lZwF9H4A5iRv0,1034
75
+ ormlambda/sql/clauses/delete.py,sha256=tTSCcSD_F-z9rl4HwfJOeb_M_XJlg-LkyU3f6vVQNTc,2289
76
+ ormlambda/sql/clauses/group_by.py,sha256=wCPCBnre_XR93L_8_alnxOh8PqXyxr8hbZom373EiFo,569
77
+ ormlambda/sql/clauses/having.py,sha256=yvWKUxLPVBzbmI0D-dAkbRXkkEPa365TKQuAmov91XI,360
78
+ ormlambda/sql/clauses/insert.py,sha256=QwY_-StS7yzwoFLvvJQAG2mTx7luxyFk6j26Kwv9HCA,3832
79
+ ormlambda/sql/clauses/interfaces/IDelete.py,sha256=06ZEdbKBxsHSwsGMBu0E1om4WJjojZAm-L3b95eQrcc,139
80
+ ormlambda/sql/clauses/interfaces/IInsert.py,sha256=YIfMPlKu7UGgnVpZuhpr0Mtnefe-O85hqk8-GZrVK7w,139
81
+ ormlambda/sql/clauses/interfaces/IUpdate.py,sha256=U-3Wx8lyCglhxf9gCXWO3MVgydG6gfRpzp00_MHC5cU,168
82
+ ormlambda/sql/clauses/interfaces/IUpsert.py,sha256=2m6Bcwa0X80IDLnf0QErqr01uYEydOnRta9_T1nxjK4,139
83
+ ormlambda/sql/clauses/interfaces/__init__.py,sha256=amGsD84C2torwyZMMknv2GBuA2W16DB3HTuhAGIpYds,172
84
+ ormlambda/sql/clauses/join/__init__.py,sha256=7hwAB-nKaMirTT6uNZ1JtYNkkIx5zMSa6jaqr28d8Cg,67
85
+ ormlambda/sql/clauses/join/join_context.py,sha256=I3Z8l0EoDwVb6EnFacm7o2lkAPgzuYxP5mNhih78aSQ,3096
86
+ ormlambda/sql/clauses/joins.py,sha256=Lt0KbKC7aOFPzkerB2TUHsUKOdIsbCkIJCMktEn_XaA,4295
87
+ ormlambda/sql/clauses/limit.py,sha256=h3WuF4QV5_Pns3r7MzfZn_QtINdq6CEiCh30LLaeWKY,315
88
+ ormlambda/sql/clauses/offset.py,sha256=dGUVDUvvaLQJov8vYwImhwKgHjwud5eViRYs-kcvAtA,318
89
+ ormlambda/sql/clauses/order.py,sha256=Zpl_XxVViURrwl4LFw3ldvCh0OeGVjvGIPYurHQ8S9Q,1438
90
+ ormlambda/sql/clauses/select.py,sha256=-tViA_6Z-7WFJaILnUdX8AUmcwEarrO2e2HkGeIzRTg,2193
91
+ ormlambda/sql/clauses/update.py,sha256=LM6Cb9A31O93IvOxL80NLZuKPr9xFt65BpYejbqQKj8,3072
92
+ ormlambda/sql/clauses/upsert.py,sha256=1MlHSzIVXSnCnXx_0HqX_-JT1FAxaIKHImrv-OKjnWU,2250
93
+ ormlambda/sql/clauses/where.py,sha256=QRYuBstzVG0nlI87USE_hJyCqzSkZSwq7aSA0OAItbE,1255
94
+ ormlambda/sql/column/__init__.py,sha256=v5zXftkrFqpZeXVu_jtHKWHdmDYALVQelmxt52Fvs5E,93
95
+ ormlambda/sql/column/column.py,sha256=DLmfInvrdqMESy3C3zA_nY2-SSfk5iXzxtncy_lX-Pw,8352
96
+ ormlambda/sql/column/column_proxy.py,sha256=lyNmMIo-1j-bmwOofWas03H7_LKTzcYxEZyqsbR7WCM,4006
97
+ ormlambda/sql/column_table_proxy.py,sha256=h-cCakQjtHnrnO9NY_6oq0xOMH3fnNAvMeIDfd29ci8,450
98
+ ormlambda/sql/comparer.py,sha256=VUaS81ikBrK_R5rk5GgVqjWg_JzYgXtWmfGip1NFMzk,3967
99
+ ormlambda/sql/compiler.py,sha256=KaKiuAmuCluqWGQ69vYnm9laMBn1gmoIBtUULqNUuHA,22233
100
+ ormlambda/sql/context/__init__.py,sha256=0PkoZ0nk4dxw1275cyAEhlOHHE6jgyg7BrJJ_P1hG4E,10256
101
+ ormlambda/sql/ddl.py,sha256=LqIOLl5bfyyw07U96e6FQMbyQBbv7SjLd0uDc1gJpf8,1916
102
+ ormlambda/sql/elements.py,sha256=ijZiwi_CxSvr4LlgUJwTcyCDy28SZOsquNAQh6XKpd4,1016
103
+ ormlambda/sql/foreign_key.py,sha256=yaL8E7IOTm3OFChoWTsA4cQcMux6SdNiUzoGFaKy0Sk,4242
104
+ ormlambda/sql/functions/__init__.py,sha256=IDXpolE397LcpyYBvQ_r7QOa69cE5sk7FXPykt7XQk4,121
105
+ ormlambda/sql/functions/concat.py,sha256=78PhV9PBzlo7vRTOhZgZUoOR8-1aI_dexc_DFphHOtI,1291
106
+ ormlambda/sql/functions/max.py,sha256=TAoFIwfdA9m_Ml5xknDhDayHpnwAw5yxxGVIlEV6v0o,570
107
+ ormlambda/sql/functions/min.py,sha256=Q4_ZiyKOPdmE8pbBxO-EoCKTrqpc6cQk3yiWVw1pUzc,570
108
+ ormlambda/sql/functions/sum.py,sha256=pEN_Qxs5O9ANZlrYA0nN7qOZG7lUAWMu-jvYQSYGwLM,571
109
+ ormlambda/sql/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
110
+ ormlambda/sql/sqltypes.py,sha256=17ed054oGuDW9xvoA9fUggkcIj6z7XBWGRwkNI95nxo,14503
111
+ ormlambda/sql/table/__init__.py,sha256=ArH07tGHpC6uS4A4p63FdxbWufGQ0aM6TVnWLvTK62M,100
112
+ ormlambda/sql/table/fields.py,sha256=ovNR3bJ473aKW-2NhbKr0iJlVpgW06jurHLob2IyZU8,2116
113
+ ormlambda/sql/table/table.py,sha256=V0l1sCfqER-f4wEqGtLQdRld_MJ6fCU9vyP_KdWYOC4,5980
114
+ ormlambda/sql/table/table_constructor.py,sha256=c3Z-1El0onSClYBmAatoUBYUOT70tITVqtsDJMxZ9QU,1092
115
+ ormlambda/sql/table/table_proxy.py,sha256=pYASl4GOUcJRrdhEDCo1wFRMvPWZS8Fg43qWfBV0qQo,2931
116
+ ormlambda/sql/type_api.py,sha256=nR5NruI6kUHefcyjqmV_uxy3dM3McCWv3THg2NxXJH8,1217
117
+ ormlambda/sql/types.py,sha256=A1HI8HrANruuAPIfl7dbbTYx3l-SvuUbPrhlzK5SZ6w,1019
118
+ ormlambda/sql/visitors.py,sha256=AHXxCEOME8-b_-YhFEzBv-Jd15vSoX5F-jEGrPPNRLE,2052
119
+ ormlambda/statements/__init__.py,sha256=9IzRSVl-ZXD4D4RrrPIifOhyO0iXSpRS5ZwvVJeAW_0,49
120
+ ormlambda/statements/base_statement.py,sha256=tzDRfDJrzHCvgHWxHRhePrLi4GkOq651JBow8y-5NME,3575
121
+ ormlambda/statements/interfaces/IStatements.py,sha256=ZAMvQA-TtGf9ghhcHVaLcKHeJtodPyTzLPsFw8dngO4,9888
122
+ ormlambda/statements/interfaces/__init__.py,sha256=1EAWwBueWJ1lBG7pOAEae_Bqw6ww8s7Dnvq6LTUgUJM,51
123
+ ormlambda/statements/query_builder.py,sha256=MUTBvdlHuX6ZScyEjk4-bc6KtmpCht31NcBM1ATTyzI,10730
124
+ ormlambda/statements/statements.py,sha256=YXY-1nKONugKWWW3dPVjPJzFeTUcWFt0-hJpke7Oiw4,12250
125
+ ormlambda/statements/types.py,sha256=Qh91CB3tzrqsxsPixib7w6KLRr6zY26pHXAna6MaDm8,885
126
+ ormlambda/types/__init__.py,sha256=xVFaIMcfJvbbXs8BAvmBh8FwSiLn2R6yjZs9o-h08XM,323
127
+ ormlambda/types/metadata.py,sha256=93eJItdVDOItf7YRJUVmN_m79WLa3Ge6I414ewYnKeM,624
128
+ ormlambda/util/__init__.py,sha256=qWD74xQtWGxa5HCuRX1VxUnRrJ8Q5WxGo3R4_xpuRM8,349
129
+ ormlambda/util/langhelpers.py,sha256=84JqxrH6fEE3FbQxy-Vc-C1TofIc5yuIkZT8HxS94o8,3284
130
+ ormlambda/util/module_tree/__init__.py,sha256=LNQtqkwO1ul49Th3aHAIiyt0Wt899GmXCc44Uz1eDyY,53
131
+ ormlambda/util/module_tree/dfs_traversal.py,sha256=lSF03G63XtJFLp03ueAmsHMBvhUkjptDbK3IugXm8iU,1425
132
+ ormlambda/util/module_tree/dynamic_module.py,sha256=SQ1FZW2Es5CdACD0VS8v_UZQTuFYbUWs6diAtMbKMoA,8699
133
+ ormlambda/util/preloaded.py,sha256=1D7t25qPjhW44nRez4Sd40gLjrl6BctLhPfPsK6Dx5g,3064
134
+ ormlambda/util/typing.py,sha256=py6FbOLvnuByR8IHgKIIReFM0efX6Bzz-Ick9fx-nuw,423
135
+ ormlambda-4.0.0.dist-info/AUTHORS,sha256=uWpOHaCPTOLbVkk5x9McoLwbgzSeCg7yILeDRyMGWGM,606
136
+ ormlambda-4.0.0.dist-info/LICENSE,sha256=xBprFw8GJLdHMOoUqDk0427EvjIcbEREvXXVFULuuXU,1080
137
+ ormlambda-4.0.0.dist-info/METADATA,sha256=Ts-rXOPpIPNWaXEpxVAIZobEw4CnmRUuV95AIJwm50A,13140
138
+ ormlambda-4.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
139
+ ormlambda-4.0.0.dist-info/RECORD,,
@@ -1,65 +0,0 @@
1
- from __future__ import annotations
2
- import typing as tp
3
- from ormlambda import Table
4
-
5
- from ormlambda.sql.clause_info import ClauseInfo, AggregateFunctionBase
6
- from ormlambda.sql.clause_info.clause_info_context import ClauseContextType
7
- from ormlambda import ForeignKey
8
-
9
- from ormlambda.sql.types import AliasType, TableType, ColumnType
10
-
11
-
12
- class ClauseInfoConverter[T, TProp](tp.Protocol):
13
- @classmethod
14
- def convert(cls, data: T, alias_table: AliasType[ColumnType[TProp]] = "{table}", context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[T]]: ...
15
-
16
-
17
- class ConvertFromAnyType(ClauseInfoConverter[None, None]):
18
- @classmethod
19
- def convert(cls, data: tp.Any, alias_table: AliasType = "{table}", context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[None]]:
20
- return [ClauseInfo[None](table=None, column=data, alias_table=alias_table, alias_clause=kwargs.get("alias", None), context=context, **kwargs)]
21
-
22
-
23
- class ConvertFromForeignKey[LT: Table, RT: Table](ClauseInfoConverter[RT, None]):
24
- @classmethod
25
- def convert(cls, data: ForeignKey[LT, RT], alias_table=None, context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[RT]]:
26
- return ConvertFromTable[RT].convert(data.tright, data.get_alias(kwargs["dialect"]), context, **kwargs)
27
-
28
-
29
- class ConvertFromColumn[TProp](ClauseInfoConverter[None, TProp]):
30
- @classmethod
31
- def convert(cls, data: ColumnType[TProp], alias_table: AliasType[ColumnType[TProp]] = "{table}", context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[None]]:
32
- # COMMENT: if the property belongs to the main class, the columnn name in not prefixed. This only done if the property comes from any join.
33
- attributes = {
34
- "table": data.table,
35
- "column": data,
36
- "alias_table": alias_table,
37
- "alias_clause": "{table}_{column}",
38
- "context": context,
39
- }
40
- attributes.update(**kwargs)
41
- clause_info = ClauseInfo(**attributes)
42
- return [clause_info]
43
-
44
-
45
- class ConvertFromIAggregate(ClauseInfoConverter[None, None]):
46
- @classmethod
47
- def convert(cls, data: AggregateFunctionBase, alias_table=None, context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[None]]:
48
- return [data]
49
-
50
-
51
- class ConvertFromTable[T: Table](ClauseInfoConverter[T, None]):
52
- @classmethod
53
- def convert(cls, data: T, alias_table: AliasType[ColumnType] = "{table}", context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[T]]:
54
- """
55
- if the data is Table, means that we want to retrieve all columns
56
- """
57
- return cls._extract_all_clauses(data, alias_table, context, **kwargs)
58
-
59
- @staticmethod
60
- def _extract_all_clauses(table: TableType[T], alias_table: AliasType[ColumnType], context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[TableType[T]]]:
61
- # all columns
62
- column_clauses = []
63
- for column in table.get_columns():
64
- column_clauses.extend(ConvertFromColumn.convert(column, alias_table=alias_table, context=context, **kwargs))
65
- return column_clauses
@@ -1,141 +0,0 @@
1
- from __future__ import annotations
2
- import typing as tp
3
- from ormlambda import Table, Column
4
-
5
- from ormlambda.common.interfaces import IDecompositionQuery, ICustomAlias
6
- from ormlambda.sql.clause_info import IAggregate
7
- from ormlambda.sql.clause_info import ClauseInfo, AggregateFunctionBase
8
- from ormlambda.sql.clause_info.clause_info_context import ClauseInfoContext, ClauseContextType
9
- from ormlambda import ForeignKey
10
- from ormlambda.common.global_checker import GlobalChecker
11
-
12
- from ormlambda.sql.types import TableType, ColumnType
13
- from .clause_info_converter import (
14
- ClauseInfoConverter,
15
- ConvertFromAnyType,
16
- ConvertFromForeignKey,
17
- ConvertFromColumn,
18
- ConvertFromIAggregate,
19
- ConvertFromTable,
20
- )
21
-
22
- type TableTupleType[T, *Ts] = tuple[T:TableType, *Ts]
23
- type ValueType = tp.Union[
24
- tp.Type[IAggregate],
25
- tp.Type[Table],
26
- tp.Type[str],
27
- tp.Type[ICustomAlias],
28
- ]
29
-
30
- if tp.TYPE_CHECKING:
31
- from ormlambda.dialects import Dialect
32
-
33
-
34
- class DecompositionQueryBase[T: Table, *Ts](IDecompositionQuery[T, *Ts]):
35
- @tp.overload
36
- def __init__(self, tables: tuple[TableType[T]], columns: tuple[ColumnType]) -> None: ...
37
- @tp.overload
38
- def __init__(self, tables: tuple[TableType[T]], columns: tuple[ColumnType], context: ClauseContextType = ...) -> None: ...
39
- @tp.overload
40
- def __init__(self, tables: tuple[TableType[T]], columns: tuple[ColumnType], alias_table: str, context: ClauseContextType = ...) -> None: ...
41
-
42
- def __init__(
43
- self,
44
- tables: tuple[TableType[T]],
45
- columns: tuple[ColumnType],
46
- alias_table: str = "{table}",
47
- *,
48
- context: ClauseContextType = ClauseInfoContext(),
49
- dialect: Dialect,
50
- **kwargs,
51
- ) -> None:
52
- self.kwargs = kwargs
53
- self._tables: tuple[TableType[T]] = tables if isinstance(tables, tp.Iterable) else (tables,)
54
-
55
- self._dialect = dialect
56
- self._columns: tp.Callable[[T], tuple] = columns
57
- self._all_clauses: list[ClauseInfo | AggregateFunctionBase] = []
58
- self._context: ClauseContextType = context if context else ClauseInfoContext()
59
- self._alias_table: str = alias_table
60
- self.__clauses_list_generetor()
61
-
62
- def __getitem__(self, key: str) -> ClauseInfo | AggregateFunctionBase:
63
- for clause in self._all_clauses:
64
- is_agg_function = isinstance(clause, AggregateFunctionBase)
65
- is_clause_info = isinstance(clause, ClauseInfo)
66
- if (is_agg_function and clause._alias_aggregate == key) or (is_clause_info and clause.alias_clause == key):
67
- return clause
68
-
69
- def __clauses_list_generetor(self) -> None:
70
- # Clean self._all_clauses if we update the context
71
- self._all_clauses.clear() if self._all_clauses else None
72
-
73
- resolved_function = GlobalChecker.resolved_callback_object(self._columns, self.tables)
74
-
75
- # Python treats string objects as iterable, so we need to prevent this behavior
76
- if isinstance(resolved_function, str) or not isinstance(resolved_function, tp.Iterable):
77
- resolved_function = (self.table,) if ClauseInfo.is_asterisk(resolved_function) else (resolved_function,)
78
-
79
- for data in resolved_function:
80
- if not isinstance(data, ClauseInfo):
81
- values = self.__convert_into_ClauseInfo(data)
82
- else:
83
- values = [data]
84
- self.__add_clause(values)
85
-
86
- return None
87
-
88
- def __convert_into_ClauseInfo[TProp](self, data: TProp) -> list[ClauseInfo[T]]:
89
- """
90
- A method that behaves based on the variable's type
91
- """
92
-
93
- def validation(data: TProp, type_: ValueType) -> bool:
94
- is_valid_type: bool = isinstance(data, type) and issubclass(data, type_)
95
- return isinstance(data, type_) or is_valid_type
96
-
97
- VALUE_TYPE_MAPPED: dict[tp.Type[ValueType], ClauseInfoConverter[T, TProp]] = {
98
- ForeignKey: ConvertFromForeignKey[T, Table],
99
- Column: ConvertFromColumn[TProp],
100
- IAggregate: ConvertFromIAggregate,
101
- Table: ConvertFromTable[T],
102
- }
103
- classConverter = next((converter for obj, converter in VALUE_TYPE_MAPPED.items() if validation(data, obj)), ConvertFromAnyType)
104
- self.kwargs.setdefault("dialect", self._dialect)
105
- if "dialect" not in self.kwargs:
106
- raise ValueError("You must specified 'dialect' variable")
107
- return classConverter.convert(data, alias_table=self._alias_table, context=self._context, **self.kwargs)
108
-
109
- def __add_clause[TTable: TableType](self, clauses: list[ClauseInfo[TTable]] | ClauseInfo[TTable]) -> None:
110
- if not isinstance(clauses, tp.Iterable):
111
- raise ValueError(f"Iterable expected. '{type(clauses)}' got instead.")
112
-
113
- for clause in clauses:
114
- self._all_clauses.append(clause)
115
- return None
116
-
117
- @property
118
- def table(self) -> T:
119
- return self.tables[0] if isinstance(self.tables, tp.Iterable) else self.tables
120
-
121
- @property
122
- def tables(self) -> T:
123
- return self._tables
124
-
125
- @property
126
- def columns[*Ts](self) -> tp.Callable[[T], tuple[*Ts]]:
127
- return self._columns
128
-
129
- @property
130
- def all_clauses(self) -> list[ClauseInfo[T]]:
131
- return self._all_clauses
132
-
133
- @property
134
- def context(self) -> tp.Optional[ClauseInfoContext]:
135
- return self._context
136
-
137
- @context.setter
138
- def context(self, value: ClauseInfoContext) -> None:
139
- self._context = value
140
- self.__clauses_list_generetor()
141
- return None
@@ -1,15 +0,0 @@
1
- from __future__ import annotations
2
- from abc import abstractmethod
3
- from typing import TYPE_CHECKING
4
-
5
- from ormlambda.common.interfaces import IQuery
6
-
7
- if TYPE_CHECKING:
8
- from ormlambda import Table
9
- from ormlambda.dialects import Dialect
10
-
11
-
12
- class QueryBase[T: Table](IQuery):
13
- @property
14
- @abstractmethod
15
- def query(self, dialect: Dialect, **kwargs) -> str: ...
@@ -1,7 +0,0 @@
1
- # from ormlambda.common.interfaces import IDecompositionQuery
2
-
3
-
4
- class ICustomAlias[T, *Ts]: ...
5
-
6
-
7
- # class ICustomAlias[T, *Ts](IDecompositionQuery[T, *Ts]): ...
@@ -1,33 +0,0 @@
1
- from __future__ import annotations
2
- import abc
3
- import typing as tp
4
-
5
-
6
- if tp.TYPE_CHECKING:
7
- # TODOH: Changed to avoid mysql dependency
8
- from ormlambda.sql.clause_info import ClauseInfo, TableType
9
- from ormlambda.sql.clause_info.clause_info_context import ClauseInfoContext
10
-
11
-
12
- class IDecompositionQuery_one_arg[T: TableType]:
13
- @property
14
- @abc.abstractmethod
15
- def table(self) -> T: ...
16
-
17
- @property
18
- @abc.abstractmethod
19
- def context(self) -> tp.Optional[ClauseInfoContext]: ...
20
-
21
- @context.setter
22
- @abc.abstractmethod
23
- def context(self) -> tp.Optional[ClauseInfoContext]: ...
24
-
25
-
26
- class IDecompositionQuery[T: TableType, *Ts](IDecompositionQuery_one_arg[T]):
27
- @property
28
- @abc.abstractmethod
29
- def tables(self) -> tuple[*Ts]: ...
30
-
31
- @property
32
- @abc.abstractmethod
33
- def all_clauses(self) -> list[ClauseInfo]: ...
@@ -1,4 +0,0 @@
1
- from .my_sql import (
2
- MySQLCaster as MySQLCaster,
3
- MySQLRepository as MySQLRepository,
4
- )
@@ -1,3 +0,0 @@
1
- from mysql.connector import MySQLConnection # noqa: F401
2
- from .repository import MySQLRepository # noqa: F401
3
- from .caster import MySQLCaster # noqa: F401