ormlambda 3.35.3__tar.gz → 4.0.0__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.
Files changed (196) hide show
  1. {ormlambda-3.35.3 → ormlambda-4.0.0}/PKG-INFO +29 -31
  2. {ormlambda-3.35.3 → ormlambda-4.0.0}/README.md +28 -30
  3. {ormlambda-3.35.3 → ormlambda-4.0.0}/pyproject.toml +1 -1
  4. ormlambda-4.0.0/src/ormlambda/__init__.py +87 -0
  5. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/caster/caster.py +6 -1
  6. ormlambda-4.0.0/src/ormlambda/common/abstract_classes/__init__.py +1 -0
  7. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/enums/__init__.py +1 -0
  8. ormlambda-4.0.0/src/ormlambda/common/enums/order_type.py +9 -0
  9. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/errors/__init__.py +13 -3
  10. ormlambda-4.0.0/src/ormlambda/common/global_checker.py +106 -0
  11. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/interfaces/IQueryCommand.py +2 -2
  12. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/interfaces/__init__.py +0 -2
  13. ormlambda-3.35.3/src/ormlambda/dialects/interface/dialect.py → ormlambda-4.0.0/src/ormlambda/dialects/__init__.py +34 -1
  14. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/default/base.py +1 -1
  15. ormlambda-4.0.0/src/ormlambda/dialects/mysql/__init__.py +41 -0
  16. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/mysql/base.py +226 -40
  17. ormlambda-4.0.0/src/ormlambda/dialects/mysql/clauses/ST_AsText.py +26 -0
  18. ormlambda-4.0.0/src/ormlambda/dialects/mysql/clauses/ST_Contains.py +30 -0
  19. ormlambda-4.0.0/src/ormlambda/dialects/mysql/clauses/__init__.py +1 -0
  20. ormlambda-4.0.0/src/ormlambda/dialects/mysql/repository/__init__.py +1 -0
  21. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql/repository}/repository.py +0 -5
  22. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/mysql/types.py +6 -0
  23. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/engine/base.py +26 -4
  24. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/errors.py +9 -0
  25. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/model/base_model.py +3 -10
  26. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/repository/base_repository.py +1 -1
  27. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/repository/interfaces/IRepositoryBase.py +0 -7
  28. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/repository/response.py +12 -7
  29. ormlambda-4.0.0/src/ormlambda/sql/__init__.py +12 -0
  30. ormlambda-4.0.0/src/ormlambda/sql/clause_info/__init__.py +2 -0
  31. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clause_info/clause_info.py +94 -76
  32. ormlambda-4.0.0/src/ormlambda/sql/clause_info/interface/IAggregate.py +20 -0
  33. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clause_info/interface/IClauseInfo.py +6 -11
  34. ormlambda-4.0.0/src/ormlambda/sql/clauses/alias.py +14 -0
  35. ormlambda-4.0.0/src/ormlambda/sql/clauses/count.py +42 -0
  36. ormlambda-4.0.0/src/ormlambda/sql/clauses/group_by.py +24 -0
  37. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/having.py +2 -6
  38. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/insert.py +3 -3
  39. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/interfaces/__init__.py +0 -1
  40. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/join/join_context.py +5 -12
  41. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/joins.py +34 -52
  42. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/limit.py +1 -2
  43. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/offset.py +1 -2
  44. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/order.py +17 -21
  45. ormlambda-4.0.0/src/ormlambda/sql/clauses/select.py +79 -0
  46. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/update.py +13 -10
  47. ormlambda-4.0.0/src/ormlambda/sql/clauses/where.py +46 -0
  48. ormlambda-4.0.0/src/ormlambda/sql/column/__init__.py +2 -0
  49. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/column/column.py +19 -12
  50. ormlambda-4.0.0/src/ormlambda/sql/column/column_proxy.py +117 -0
  51. ormlambda-4.0.0/src/ormlambda/sql/column_table_proxy.py +23 -0
  52. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/comparer.py +31 -65
  53. ormlambda-4.0.0/src/ormlambda/sql/compiler.py +617 -0
  54. ormlambda-4.0.0/src/ormlambda/sql/context/__init__.py +304 -0
  55. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/ddl.py +19 -5
  56. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/elements.py +3 -0
  57. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/foreign_key.py +42 -64
  58. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/functions/__init__.py +0 -1
  59. ormlambda-4.0.0/src/ormlambda/sql/functions/concat.py +45 -0
  60. ormlambda-4.0.0/src/ormlambda/sql/functions/max.py +24 -0
  61. ormlambda-4.0.0/src/ormlambda/sql/functions/min.py +24 -0
  62. ormlambda-4.0.0/src/ormlambda/sql/functions/sum.py +25 -0
  63. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/sqltypes.py +2 -0
  64. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/table/__init__.py +1 -0
  65. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/table/table.py +31 -45
  66. ormlambda-4.0.0/src/ormlambda/sql/table/table_proxy.py +88 -0
  67. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/type_api.py +4 -1
  68. ormlambda-4.0.0/src/ormlambda/sql/types.py +30 -0
  69. ormlambda-4.0.0/src/ormlambda/statements/__init__.py +1 -0
  70. ormlambda-4.0.0/src/ormlambda/statements/base_statement.py +90 -0
  71. ormlambda-4.0.0/src/ormlambda/statements/interfaces/IStatements.py +299 -0
  72. ormlambda-4.0.0/src/ormlambda/statements/interfaces/__init__.py +1 -0
  73. ormlambda-4.0.0/src/ormlambda/statements/query_builder.py +331 -0
  74. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/statements/statements.py +120 -110
  75. ormlambda-4.0.0/src/ormlambda/statements/types.py +37 -0
  76. ormlambda-4.0.0/src/ormlambda/util/__init__.py +9 -0
  77. ormlambda-3.35.3/src/ormlambda/util/__init__.py → ormlambda-4.0.0/src/ormlambda/util/langhelpers.py +30 -30
  78. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/util/module_tree/dynamic_module.py +1 -1
  79. ormlambda-4.0.0/src/ormlambda/util/preloaded.py +80 -0
  80. ormlambda-4.0.0/src/ormlambda/util/typing.py +15 -0
  81. ormlambda-3.35.3/src/ormlambda/__init__.py +0 -59
  82. ormlambda-3.35.3/src/ormlambda/common/abstract_classes/__init__.py +0 -3
  83. ormlambda-3.35.3/src/ormlambda/common/abstract_classes/clause_info_converter.py +0 -65
  84. ormlambda-3.35.3/src/ormlambda/common/abstract_classes/decomposition_query.py +0 -141
  85. ormlambda-3.35.3/src/ormlambda/common/abstract_classes/query_base.py +0 -15
  86. ormlambda-3.35.3/src/ormlambda/common/global_checker.py +0 -28
  87. ormlambda-3.35.3/src/ormlambda/common/interfaces/ICustomAlias.py +0 -7
  88. ormlambda-3.35.3/src/ormlambda/common/interfaces/IDecompositionQuery.py +0 -33
  89. ormlambda-3.35.3/src/ormlambda/databases/__init__.py +0 -4
  90. ormlambda-3.35.3/src/ormlambda/databases/my_sql/__init__.py +0 -3
  91. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/ST_AsText.py +0 -37
  92. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/ST_Contains.py +0 -36
  93. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/__init__.py +0 -14
  94. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/count.py +0 -33
  95. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/delete.py +0 -9
  96. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/drop_table.py +0 -26
  97. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/group_by.py +0 -17
  98. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/having.py +0 -12
  99. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/insert.py +0 -9
  100. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/joins.py +0 -14
  101. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/limit.py +0 -6
  102. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/offset.py +0 -6
  103. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/order.py +0 -8
  104. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/update.py +0 -8
  105. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/upsert.py +0 -9
  106. ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/where.py +0 -7
  107. ormlambda-3.35.3/src/ormlambda/dialects/__init__.py +0 -39
  108. ormlambda-3.35.3/src/ormlambda/dialects/interface/__init__.py +0 -1
  109. ormlambda-3.35.3/src/ormlambda/dialects/mysql/__init__.py +0 -84
  110. ormlambda-3.35.3/src/ormlambda/sql/__init__.py +0 -3
  111. ormlambda-3.35.3/src/ormlambda/sql/clause_info/__init__.py +0 -4
  112. ormlambda-3.35.3/src/ormlambda/sql/clause_info/aggregate_function_base.py +0 -96
  113. ormlambda-3.35.3/src/ormlambda/sql/clause_info/clause_info_context.py +0 -87
  114. ormlambda-3.35.3/src/ormlambda/sql/clause_info/interface/IAggregate.py +0 -10
  115. ormlambda-3.35.3/src/ormlambda/sql/clauses/alias.py +0 -45
  116. ormlambda-3.35.3/src/ormlambda/sql/clauses/count.py +0 -57
  117. ormlambda-3.35.3/src/ormlambda/sql/clauses/group_by.py +0 -30
  118. ormlambda-3.35.3/src/ormlambda/sql/clauses/interfaces/ISelect.py +0 -17
  119. ormlambda-3.35.3/src/ormlambda/sql/clauses/new_join.py +0 -119
  120. ormlambda-3.35.3/src/ormlambda/sql/clauses/select.py +0 -51
  121. ormlambda-3.35.3/src/ormlambda/sql/clauses/where.py +0 -65
  122. ormlambda-3.35.3/src/ormlambda/sql/column/__init__.py +0 -1
  123. ormlambda-3.35.3/src/ormlambda/sql/compiler.py +0 -427
  124. ormlambda-3.35.3/src/ormlambda/sql/functions/concat.py +0 -48
  125. ormlambda-3.35.3/src/ormlambda/sql/functions/max.py +0 -48
  126. ormlambda-3.35.3/src/ormlambda/sql/functions/min.py +0 -39
  127. ormlambda-3.35.3/src/ormlambda/sql/functions/sum.py +0 -41
  128. ormlambda-3.35.3/src/ormlambda/sql/types.py +0 -27
  129. ormlambda-3.35.3/src/ormlambda/statements/__init__.py +0 -3
  130. ormlambda-3.35.3/src/ormlambda/statements/base_statement.py +0 -123
  131. ormlambda-3.35.3/src/ormlambda/statements/interfaces/IStatements.py +0 -345
  132. ormlambda-3.35.3/src/ormlambda/statements/interfaces/__init__.py +0 -1
  133. ormlambda-3.35.3/src/ormlambda/statements/query_builder.py +0 -163
  134. ormlambda-3.35.3/src/ormlambda/statements/types.py +0 -57
  135. ormlambda-3.35.3/src/ormlambda/util/load_module.py +0 -21
  136. ormlambda-3.35.3/src/ormlambda/util/plugin_loader.py +0 -32
  137. ormlambda-3.35.3/src/ormlambda/util/typing.py +0 -6
  138. {ormlambda-3.35.3 → ormlambda-4.0.0}/AUTHORS +0 -0
  139. {ormlambda-3.35.3 → ormlambda-4.0.0}/LICENSE +0 -0
  140. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/caster/__init__.py +0 -0
  141. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/caster/base_caster.py +0 -0
  142. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/caster/interfaces/ICaster.py +0 -0
  143. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/caster/interfaces/__init__.py +0 -0
  144. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/__init__.py +0 -0
  145. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/abstract_classes/non_query_base.py +0 -0
  146. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/enums/condition_types.py +0 -0
  147. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/enums/join_type.py +0 -0
  148. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/interfaces/IJoinSelector.py +0 -0
  149. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/common/interfaces/INonQueryCommand.py +0 -0
  150. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/default/__init__.py +0 -0
  151. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/__init__.py +0 -0
  152. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/caster.py +0 -0
  153. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/__init__.py +0 -0
  154. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/boolean.py +0 -0
  155. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/bytes.py +0 -0
  156. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/date.py +0 -0
  157. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/datetime.py +0 -0
  158. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/decimal.py +0 -0
  159. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/float.py +0 -0
  160. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/int.py +0 -0
  161. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/iterable.py +0 -0
  162. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/json.py +0 -0
  163. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/none.py +0 -0
  164. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/point.py +0 -0
  165. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql}/caster/types/string.py +0 -0
  166. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/mysql/mysqlconnector.py +0 -0
  167. {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.0/src/ormlambda/dialects/mysql/repository}/pool_types.py +0 -0
  168. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/sqlite/__init__.py +0 -0
  169. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/sqlite/base.py +0 -0
  170. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/dialects/sqlite/pysqlite.py +0 -0
  171. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/engine/__init__.py +0 -0
  172. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/engine/create.py +0 -0
  173. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/engine/url.py +0 -0
  174. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/engine/utils.py +0 -0
  175. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/env.py +0 -0
  176. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/model/__init__.py +0 -0
  177. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/repository/__init__.py +0 -0
  178. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/repository/interfaces/IDatabaseConnection.py +0 -0
  179. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/repository/interfaces/__init__.py +0 -0
  180. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clause_info/interface/__init__.py +0 -0
  181. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/__init__.py +0 -0
  182. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/delete.py +0 -0
  183. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/interfaces/IDelete.py +0 -0
  184. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/interfaces/IInsert.py +0 -0
  185. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/interfaces/IUpdate.py +0 -0
  186. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/interfaces/IUpsert.py +0 -0
  187. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/join/__init__.py +0 -0
  188. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/clauses/upsert.py +0 -0
  189. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/interfaces/__init__.py +0 -0
  190. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/table/fields.py +0 -0
  191. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/table/table_constructor.py +0 -0
  192. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/sql/visitors.py +0 -0
  193. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/types/__init__.py +0 -0
  194. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/types/metadata.py +0 -0
  195. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/util/module_tree/__init__.py +0 -0
  196. {ormlambda-3.35.3 → ormlambda-4.0.0}/src/ormlambda/util/module_tree/dfs_traversal.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ormlambda
3
- Version: 3.35.3
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
  )
@@ -283,19 +283,19 @@ with this approach, we will obtain a dictionary where the key will be the concat
283
283
 
284
284
  ## max
285
285
  ```python
286
- res = AddressModel.max(Address.address_id, execute=True)
286
+ res = AddressModel.max(lambda x: x.address_id)
287
287
  ```
288
288
  ## min
289
289
  ```python
290
- res = AddressModel.min(Address.address_id, execute=True)
290
+ res = AddressModel.min(lambda x: x.address_id)
291
291
  ```
292
292
  ## sum
293
293
  ```python
294
- res = AddressModel.sum(Address.address_id, execute=True)
294
+ res = AddressModel.sum(lambda x: x.address_id)
295
295
  ```
296
296
  ## count
297
297
  ```python
298
- res = AddressModel.count(Address.address_id, execute=True)
298
+ res = AddressModel.count(lambda x: x.address_id)
299
299
  ```
300
300
 
301
301
  ## 1. Concat
@@ -309,14 +309,14 @@ response = ORM(Address, db).where(Address.City.Country.country.regex(r"^Spain"))
309
309
  (
310
310
  Address.address,
311
311
  Address.City.city,
312
- self.tmodel.concat(
312
+ Concat(lambda x:
313
313
  (
314
314
  "Address: ",
315
- Address.address,
315
+ x.address,
316
316
  " - city: ",
317
- Address.City.city,
317
+ x.City.city,
318
318
  " - country: ",
319
- Address.City.Country.country,
319
+ x.City.Country.country,
320
320
  )
321
321
  ),
322
322
  ),
@@ -351,15 +351,13 @@ class Response(BaseModel):
351
351
  engine= create_engine(DATABASE_URL)
352
352
  model = ORM(Address,engine)
353
353
 
354
- count_name = Column(column_name="count")
355
-
356
354
  res = (
357
355
  self.model
358
- .groupby(Address.district)
359
- .select(
356
+ .groupby(lambda x: x.district)
357
+ .select(lambda x:
360
358
  (
361
- Address.district,
362
- self.model.count(Address.address),
359
+ x.district,
360
+ Count(x.address),
363
361
  ),
364
362
  flavour=Response,
365
363
  )
@@ -374,12 +372,12 @@ The `having` method is used to filter results based on aggregate functions. It i
374
372
  ```python
375
373
  res = (
376
374
  model
377
- .groupby(Address.district)
378
- .having(count_name > 4)
379
- .select(
375
+ .groupby(lambda x: x.district)
376
+ .having(lambda x: x.count > 4)
377
+ .select(lambda x:
380
378
  (
381
- Address.district,
382
- model.count(Address.address),
379
+ x.district,
380
+ Count(x.address),
383
381
  ),
384
382
  flavour=Response,
385
383
  )
@@ -409,9 +407,9 @@ select = (
409
407
  ORM(Address, db)
410
408
  .order(lambda x: x.City.Country.country, "DESC")
411
409
  .limit(10)
412
- .where(Address.City.Country.country == "Spain")
413
- .first(
414
- lambda x: (
410
+ .where(lambda x: x.City.Country.country == "Spain")
411
+ .first(lambda x:
412
+ (
415
413
  x.address,
416
414
  x.City.city,
417
415
  x.City.Country.country,
@@ -436,9 +434,9 @@ As shown in the previous examples, setting the `execute` attribute to `True` all
436
434
  ```python
437
435
  result = AddressModel.select_one(
438
436
  lambda x: (
439
- AddressModel.min(x.address_id),
440
- AddressModel.max(x.address_id),
441
- AddressModel.count(x.address_id),
437
+ Min(x.address_id),
438
+ Max(x.address_id),
439
+ Count(x.address_id),
442
440
  ),flavour=dict
443
441
  )
444
442
  ```
@@ -455,11 +453,11 @@ Getting something like
455
453
  You also can use custom alias for each method
456
454
 
457
455
  ```python
458
- AddressModel.select_one(
459
- lambda x: (
460
- AddressModel.min(x.address_id),
461
- AddressModel.max(x.address_id, alias="custom-max"),
462
- AddressModel.count(x.address_id),
456
+ AddressModel.select_one(lambda x:
457
+ (
458
+ Min(x.address_id),
459
+ Max(x.address_id, alias="custom-max"),
460
+ Count(x.address_id),
463
461
  ),
464
462
  flavour=dict,
465
463
  )
@@ -3,7 +3,7 @@ line-length = 320
3
3
 
4
4
  [tool.poetry]
5
5
  name = "ormlambda"
6
- version = "3.35.3"
6
+ version = "4.0.0"
7
7
  description = "ORM designed to interact with the database (currently with MySQL) using lambda functions and nested functions"
8
8
  authors = ["p-hzamora <p.hzamora@icloud.com>"]
9
9
  readme = "README.md"
@@ -0,0 +1,87 @@
1
+ # COMMENT: Necesary to load all variables inside ormalambda.env
2
+ import ormlambda.env # noqa: F401
3
+
4
+ # region enums
5
+ from .common.enums import JoinType as JoinType
6
+ from .common.enums import ConditionType as ConditionType
7
+ from .common.enums import OrderType as OrderType
8
+
9
+
10
+ # endregion
11
+
12
+ # region sql
13
+ from .sql import Column as Column
14
+ from .sql import ColumnProxy as ColumnProxy
15
+ from .sql import Table as Table
16
+ from .sql import ForeignKey as ForeignKey
17
+ from .sql import TableProxy as TableProxy
18
+
19
+
20
+ # endregion
21
+
22
+ from .repository import BaseRepository as BaseRepository
23
+
24
+ from .model.base_model import BaseModel as BaseModel
25
+ from .model.base_model import ORM as ORM
26
+ # COMMENT: to avoid relative import we need to import BaseModel after import Table,Column, ForeignKey, IRepositoryBase and Disassembler
27
+
28
+ from .engine import create_engine as create_engine
29
+ from .engine import URL as URL
30
+ from .engine import make_url as make_url
31
+
32
+ from .sql.sqltypes import JSON as JSON
33
+ from .sql.sqltypes import UUID as UUID
34
+ from .sql.sqltypes import NullType as NullType
35
+ from .sql.sqltypes import INTEGER as INTEGER
36
+ from .sql.sqltypes import INT as INT
37
+ from .sql.sqltypes import SMALLINTEGER as SMALLINTEGER
38
+ from .sql.sqltypes import BIGINTEGER as BIGINTEGER
39
+ from .sql.sqltypes import NUMERIC as NUMERIC
40
+ from .sql.sqltypes import FLOAT as FLOAT
41
+ from .sql.sqltypes import REAL as REAL
42
+ from .sql.sqltypes import DOUBLE as DOUBLE
43
+ from .sql.sqltypes import DECIMAL as DECIMAL
44
+ from .sql.sqltypes import STRING as STRING
45
+ from .sql.sqltypes import TEXT as TEXT
46
+ from .sql.sqltypes import UNICODE as UNICODE
47
+ from .sql.sqltypes import UNICODETEXT as UNICODETEXT
48
+ from .sql.sqltypes import CHAR as CHAR
49
+ from .sql.sqltypes import NCHAR as NCHAR
50
+ from .sql.sqltypes import BLOB as BLOB
51
+ from .sql.sqltypes import VARCHAR as VARCHAR
52
+ from .sql.sqltypes import NVARCHAR as NVARCHAR
53
+ from .sql.sqltypes import DATE as DATE
54
+ from .sql.sqltypes import TIME as TIME
55
+ from .sql.sqltypes import DATETIME as DATETIME
56
+ from .sql.sqltypes import TIMESTAMP as TIMESTAMP
57
+ from .sql.sqltypes import BOOLEAN as BOOLEAN
58
+ from .sql.sqltypes import LARGEBINARY as LARGEBINARY
59
+ from .sql.sqltypes import VARBINARY as VARBINARY
60
+ from .sql.sqltypes import ENUM as ENUM
61
+ from .sql.sqltypes import POINT as POINT
62
+
63
+
64
+ from .sql.clauses import Alias as Alias
65
+ from .sql.clauses import Count as Count
66
+ from .sql.clauses import Delete as Delete
67
+ from .sql.clauses import GroupBy as GroupBy
68
+ from .sql.clauses import Insert as Insert
69
+ from .sql.clauses import JoinSelector as JoinSelector
70
+ from .sql.clauses import Limit as Limit
71
+ from .sql.clauses import Offset as Offset
72
+ from .sql.clauses import Order as Order
73
+ from .sql.clauses import Select as Select
74
+ from .sql.clauses import Where as Where
75
+ from .sql.clauses import Having as Having
76
+ from .sql.clauses import Update as Update
77
+ from .sql.clauses import Upsert as Upsert
78
+
79
+ from .sql.functions import Max as Max
80
+ from .sql.functions import Min as Min
81
+ from .sql.functions import Concat as Concat
82
+ from .sql.functions import Sum as Sum
83
+
84
+
85
+ from . import util as _util
86
+
87
+ _util.import_prefix("ormlambda")
@@ -62,4 +62,9 @@ class Caster(ICaster):
62
62
  column_type = type(value)
63
63
  else:
64
64
  column_type = type_value
65
- return cls.CASTER_SELECTOR()[column_type](value, column_type)
65
+
66
+ caster_class = cls.CASTER_SELECTOR().get(column_type, None)
67
+ if not caster_class:
68
+ raise ValueError(f"'{column_type}' type has not a Caster class created.")
69
+
70
+ return caster_class(value, column_type)
@@ -0,0 +1 @@
1
+ from .non_query_base import NonQueryBase as NonQueryBase
@@ -1,2 +1,3 @@
1
1
  from .join_type import JoinType # noqa: F401
2
2
  from .condition_types import ConditionType # noqa: F401
3
+ from .order_type import OrderType # noqa: F401
@@ -0,0 +1,9 @@
1
+ import enum
2
+
3
+
4
+ class OrderType(str, enum.Enum):
5
+ def __str__(self):
6
+ return super().__str__()
7
+
8
+ ASC = "ASC"
9
+ DESC = "DESC"
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
  import inspect
3
3
  import typing as tp
4
4
 
5
+ from ormlambda import util
5
6
 
6
7
  if tp.TYPE_CHECKING:
7
8
  from ormlambda.sql.clause_info import ClauseInfo
@@ -35,16 +36,25 @@ class AggregateFunctionError[T](Exception):
35
36
  agg_methods = self.__get_all_aggregate_method(self.clause)
36
37
  return f"You cannot use aggregation method like '{agg_methods}' to return model objects. Try specifying 'flavour' attribute as 'dict'."
37
38
 
39
+ @util.preload_module("ormlambda.sql.clause_info")
38
40
  def __get_all_aggregate_method(self, clauses: list[ClauseInfo]) -> str:
39
41
  """
40
- Get the class name of those classes that inherit from 'AggregateFunctionBase' class in order to create a better error message.
42
+ Get the class name of those classes that inherit from 'IAggregate' class in order to create a better error message.
41
43
  """
42
- from ormlambda.sql.clause_info import AggregateFunctionBase
43
44
 
45
+ IAggregate = util.preloaded.sql_clause_info.IAggregate
44
46
  res: set[str] = set()
45
47
  if not isinstance(clauses, tp.Iterable):
46
48
  return clauses.__class__.__name__
47
49
  for clause in clauses:
48
- if isinstance(clause, AggregateFunctionBase):
50
+ if isinstance(clause, IAggregate):
49
51
  res.add(clause.__class__.__name__)
50
52
  return ", ".join(res)
53
+
54
+
55
+ class NotCallableError(ValueError):
56
+ def __init__(self, *args):
57
+ super().__init__(*args)
58
+
59
+ def __str__(self)->str:
60
+ return f"You must provide a function or callable to proceed with the query creation. Passed '{self.args[0].__class__.__name__}' "
@@ -0,0 +1,106 @@
1
+ from __future__ import annotations
2
+ import re
3
+ from typing import Any, TYPE_CHECKING, Iterable, Callable
4
+
5
+ from ormlambda.common.errors import UnmatchedLambdaParameterError
6
+ from ormlambda.common.errors import NotCallableError
7
+ from ormlambda import util
8
+
9
+ if TYPE_CHECKING:
10
+ from ormlambda.sql.types import SelectCol # FIXME [ ]: enhance the name
11
+ from ormlambda import TableProxy
12
+ from ormlambda.sql.column import ColumnProxy
13
+
14
+
15
+ # type LambdaResponse[T] = TableProxy[T] | ColumnProxy[T] | Comparer
16
+ class GlobalChecker[T: TableProxy]:
17
+ FIRST_QUOTE = "`"
18
+ END_QUOTE = "`"
19
+
20
+ @staticmethod
21
+ def is_lambda_function(obj: Any) -> bool:
22
+ return callable(obj) and not isinstance(obj, type)
23
+
24
+ @util.preload_module("ormlambda.sql")
25
+ @classmethod
26
+ def resolved_callback_object(cls, table: T, lambda_func: Callable[[T], Any]) -> tuple[SelectCol, ...]:
27
+ TableProxy = util.preloaded.sql_table.TableProxy
28
+
29
+ try:
30
+ table_proxy = TableProxy(table)
31
+
32
+ if not callable(lambda_func):
33
+ raise NotCallableError(lambda_func)
34
+
35
+ if isinstance(lambda_func, Iterable):
36
+ # We hit that condition when trying to pass column or function dynamically into select clause.
37
+
38
+ # max_fn = Max(lambda x: x.Col1)
39
+ # min_fn = Min(lambda x: x.Col1)
40
+ # sum_fn = Sum(lambda x: x.Col1)
41
+ # result = self.model.select(
42
+ # (
43
+ # max_fn,
44
+ # min_fn,
45
+ # sum_fn,
46
+ # ),
47
+ # flavour=dict,
48
+ # )
49
+
50
+ response = []
51
+
52
+ for item in lambda_func:
53
+ response.append(item)
54
+ return response
55
+
56
+ response = lambda_func(table_proxy)
57
+ result = []
58
+
59
+ if isinstance(response, str) or not isinstance(response, Iterable):
60
+ response = [response]
61
+
62
+ for item in response:
63
+ column = cls.parser_object(item, table)
64
+
65
+ result.extend(column)
66
+
67
+ return result
68
+
69
+ except TypeError as err:
70
+ cond1 = r"takes \d+ positional argument but \d+ were given"
71
+ cond2 = r"missing \d+ required positional arguments:"
72
+ if re.search(r"(" + f"{cond1}|{cond2}" + r")", err.args[0]):
73
+ raise UnmatchedLambdaParameterError(len(table), lambda_func)
74
+ raise err
75
+
76
+ @util.preload_module(
77
+ "ormlambda.sql.column",
78
+ "ormlambda.sql.table",
79
+ "ormlambda.sql.comparer",
80
+ "ormlambda.sql.column_table_proxy",
81
+ )
82
+ @staticmethod
83
+ def parser_object(item: Any, table: T) -> tuple[ColumnProxy, ...]:
84
+ ColumnProxy = util.preloaded.sql_column.ColumnProxy
85
+ Column = util.preloaded.sql_column.Column
86
+
87
+ TableProxy = util.preloaded.sql_table.TableProxy
88
+ Comparer = util.preloaded.sql_comparer.Comparer
89
+ FKChain = util.preloaded.sql_column_table_proxy.FKChain
90
+
91
+ if isinstance(item, TableProxy):
92
+ return item.get_columns()
93
+
94
+ if isinstance(item, str):
95
+ # If we got a string, probably means that it'll be an alias,
96
+ # so we'll want to avoid add string alias table to alias like `address`.count
97
+ new_col = Column(dtype=str, column_name=item)
98
+ new_col.table = table
99
+ return [ColumnProxy(new_col, path=FKChain(table, None))]
100
+ if isinstance(item, Comparer):
101
+ return [item]
102
+
103
+ if isinstance(item, ColumnProxy):
104
+ return [item]
105
+
106
+ return [item]
@@ -1,5 +1,5 @@
1
1
  from __future__ import annotations
2
- from abc import abstractmethod, ABC
2
+ from abc import ABC
3
3
  from typing import TYPE_CHECKING
4
4
 
5
5
  if TYPE_CHECKING:
@@ -9,7 +9,7 @@ if TYPE_CHECKING:
9
9
  class IQuery(ABC):
10
10
  """Interface to queries that retrieve any element such as select, limit, offset, where, group by, etc..."""
11
11
 
12
- @abstractmethod
12
+ # @abstractmethod
13
13
  def query(self, dialect: Dialect, **kwargs) -> str: ...
14
14
 
15
15
  def __repr__(self) -> str:
@@ -1,5 +1,3 @@
1
- from .ICustomAlias import ICustomAlias as ICustomAlias
2
- from .IDecompositionQuery import IDecompositionQuery as IDecompositionQuery
3
1
  from .IJoinSelector import IJoinSelector as IJoinSelector
4
2
  from .INonQueryCommand import INonQueryCommand as INonQueryCommand
5
3
  from .IQueryCommand import IQuery as IQuery
@@ -1,6 +1,8 @@
1
1
  from __future__ import annotations
2
+ from typing import Callable, Optional, Type, TYPE_CHECKING, ClassVar
2
3
  import abc
3
- from typing import ClassVar, Optional, Type, TYPE_CHECKING
4
+ from ormlambda import util
5
+ import importlib
4
6
 
5
7
 
6
8
  if TYPE_CHECKING:
@@ -76,3 +78,34 @@ class Dialect(abc.ABC):
76
78
 
77
79
  def __repr__(self):
78
80
  return f"{Dialect.__name__}: {type(self).__name__}"
81
+
82
+
83
+ def _auto_fn(name: str) -> Optional[Callable[[], Type[Dialect]]]:
84
+ """default dialect importer.
85
+
86
+ plugs into the :class:`.PluginLoader`
87
+ as a first-hit system.
88
+
89
+ """
90
+ if "." in name:
91
+ dialect, driver = name.split(".")
92
+ else:
93
+ dialect = name
94
+ driver = "base"
95
+
96
+ try:
97
+ module = importlib.import_module(f"ormlambda.dialects.{dialect}")
98
+
99
+ except ImportError:
100
+ return None
101
+
102
+ if hasattr(module, driver):
103
+ module = getattr(module, driver)
104
+ return lambda: module.dialect
105
+ else:
106
+ return None
107
+
108
+
109
+ registry = util.PluginLoader("ormlambda.dialects", auto_fn=_auto_fn)
110
+
111
+ __all__ = ("mysql", "sqlite")
@@ -1,4 +1,4 @@
1
- from ormlambda.dialects.interface import Dialect
1
+ from ormlambda.dialects import Dialect
2
2
  from ormlambda.sql import compiler
3
3
  from typing import Optional, Any
4
4
  from types import ModuleType
@@ -0,0 +1,41 @@
1
+ from . import base as base
2
+ from . import mysqlconnector as mysqlconnector
3
+
4
+ from .base import BIGINT as BIGINT
5
+ from .base import BIT as BIT
6
+ from .base import BLOB as BLOB
7
+ from .base import BOOLEAN as BOOLEAN
8
+ from .base import CHAR as CHAR
9
+ from .base import DATE as DATE
10
+ from .base import DATETIME as DATETIME
11
+ from .base import DECIMAL as DECIMAL
12
+ from .base import DOUBLE as DOUBLE
13
+ from .base import FLOAT as FLOAT
14
+ from .base import INTEGER as INTEGER
15
+ from .base import LONGBLOB as LONGBLOB
16
+ from .base import LONGTEXT as LONGTEXT
17
+ from .base import MEDIUMBLOB as MEDIUMBLOB
18
+ from .base import MEDIUMINT as MEDIUMINT
19
+ from .base import MEDIUMTEXT as MEDIUMTEXT
20
+ from .base import NCHAR as NCHAR
21
+ from .base import NUMERIC as NUMERIC
22
+ from .base import NVARCHAR as NVARCHAR
23
+ from .base import REAL as REAL
24
+ from .base import SMALLINT as SMALLINT
25
+ from .base import TEXT as TEXT
26
+ from .base import TIME as TIME
27
+ from .base import TIMESTAMP as TIMESTAMP
28
+ from .base import TINYBLOB as TINYBLOB
29
+ from .base import TINYINT as TINYINT
30
+ from .base import TINYTEXT as TINYTEXT
31
+ from .base import VARBINARY as VARBINARY
32
+ from .base import VARCHAR as VARCHAR
33
+ from .base import YEAR as YEAR
34
+ from .types import POINT as POINT
35
+
36
+
37
+ from .repository import MySQLRepository as MySQLRepository # noqa: F401
38
+ from .caster import MySQLCaster as MySQLCaster # noqa: F401
39
+
40
+ # default dialect
41
+ base.dialect = dialect = mysqlconnector.dialect