ormlambda 3.35.3__tar.gz → 4.0.4__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.
- {ormlambda-3.35.3 → ormlambda-4.0.4}/PKG-INFO +56 -79
- {ormlambda-3.35.3 → ormlambda-4.0.4}/README.md +55 -78
- {ormlambda-3.35.3 → ormlambda-4.0.4}/pyproject.toml +1 -1
- ormlambda-4.0.4/src/ormlambda/__init__.py +87 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/caster/caster.py +6 -1
- ormlambda-4.0.4/src/ormlambda/common/abstract_classes/__init__.py +1 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/enums/__init__.py +1 -0
- ormlambda-4.0.4/src/ormlambda/common/enums/order_type.py +9 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/errors/__init__.py +13 -3
- ormlambda-4.0.4/src/ormlambda/common/global_checker.py +106 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/interfaces/IQueryCommand.py +2 -2
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/interfaces/__init__.py +0 -2
- ormlambda-3.35.3/src/ormlambda/dialects/interface/dialect.py → ormlambda-4.0.4/src/ormlambda/dialects/__init__.py +34 -1
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/default/base.py +1 -1
- ormlambda-4.0.4/src/ormlambda/dialects/mysql/__init__.py +41 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/mysql/base.py +226 -40
- ormlambda-4.0.4/src/ormlambda/dialects/mysql/clauses/ST_AsText.py +26 -0
- ormlambda-4.0.4/src/ormlambda/dialects/mysql/clauses/ST_Contains.py +30 -0
- ormlambda-4.0.4/src/ormlambda/dialects/mysql/clauses/__init__.py +1 -0
- ormlambda-4.0.4/src/ormlambda/dialects/mysql/repository/__init__.py +1 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql/repository}/repository.py +0 -5
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/mysql/types.py +6 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/engine/base.py +26 -4
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/errors.py +9 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/model/base_model.py +3 -10
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/repository/base_repository.py +1 -1
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/repository/interfaces/IRepositoryBase.py +0 -7
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/repository/response.py +21 -8
- ormlambda-4.0.4/src/ormlambda/sql/__init__.py +12 -0
- ormlambda-4.0.4/src/ormlambda/sql/clause_info/__init__.py +2 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clause_info/clause_info.py +94 -76
- ormlambda-4.0.4/src/ormlambda/sql/clause_info/interface/IAggregate.py +20 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clause_info/interface/IClauseInfo.py +6 -11
- ormlambda-4.0.4/src/ormlambda/sql/clauses/alias.py +14 -0
- ormlambda-4.0.4/src/ormlambda/sql/clauses/count.py +42 -0
- ormlambda-4.0.4/src/ormlambda/sql/clauses/group_by.py +24 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/having.py +2 -6
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/insert.py +3 -3
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/interfaces/__init__.py +0 -1
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/join/join_context.py +5 -12
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/joins.py +34 -52
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/limit.py +1 -2
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/offset.py +1 -2
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/order.py +17 -21
- ormlambda-4.0.4/src/ormlambda/sql/clauses/select.py +79 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/update.py +13 -10
- ormlambda-4.0.4/src/ormlambda/sql/clauses/where.py +46 -0
- ormlambda-4.0.4/src/ormlambda/sql/column/__init__.py +2 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/column/column.py +19 -12
- ormlambda-4.0.4/src/ormlambda/sql/column/column_proxy.py +117 -0
- ormlambda-4.0.4/src/ormlambda/sql/column_table_proxy.py +23 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/comparer.py +31 -65
- ormlambda-4.0.4/src/ormlambda/sql/compiler.py +617 -0
- ormlambda-4.0.4/src/ormlambda/sql/context/__init__.py +304 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/ddl.py +19 -5
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/elements.py +3 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/foreign_key.py +42 -64
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/functions/__init__.py +0 -1
- ormlambda-4.0.4/src/ormlambda/sql/functions/concat.py +45 -0
- ormlambda-4.0.4/src/ormlambda/sql/functions/max.py +24 -0
- ormlambda-4.0.4/src/ormlambda/sql/functions/min.py +24 -0
- ormlambda-4.0.4/src/ormlambda/sql/functions/sum.py +25 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/sqltypes.py +2 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/table/__init__.py +1 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/table/table.py +31 -45
- ormlambda-4.0.4/src/ormlambda/sql/table/table_proxy.py +88 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/type_api.py +4 -1
- ormlambda-4.0.4/src/ormlambda/sql/types.py +30 -0
- ormlambda-4.0.4/src/ormlambda/statements/__init__.py +1 -0
- ormlambda-4.0.4/src/ormlambda/statements/base_statement.py +85 -0
- ormlambda-4.0.4/src/ormlambda/statements/interfaces/IStatements.py +299 -0
- ormlambda-4.0.4/src/ormlambda/statements/interfaces/__init__.py +1 -0
- ormlambda-4.0.4/src/ormlambda/statements/query_builder.py +331 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/statements/statements.py +122 -115
- ormlambda-4.0.4/src/ormlambda/statements/types.py +37 -0
- ormlambda-4.0.4/src/ormlambda/util/__init__.py +9 -0
- ormlambda-3.35.3/src/ormlambda/util/__init__.py → ormlambda-4.0.4/src/ormlambda/util/langhelpers.py +30 -30
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/util/module_tree/dynamic_module.py +1 -1
- ormlambda-4.0.4/src/ormlambda/util/preloaded.py +80 -0
- ormlambda-4.0.4/src/ormlambda/util/typing.py +15 -0
- ormlambda-3.35.3/src/ormlambda/__init__.py +0 -59
- ormlambda-3.35.3/src/ormlambda/common/abstract_classes/__init__.py +0 -3
- ormlambda-3.35.3/src/ormlambda/common/abstract_classes/clause_info_converter.py +0 -65
- ormlambda-3.35.3/src/ormlambda/common/abstract_classes/decomposition_query.py +0 -141
- ormlambda-3.35.3/src/ormlambda/common/abstract_classes/query_base.py +0 -15
- ormlambda-3.35.3/src/ormlambda/common/global_checker.py +0 -28
- ormlambda-3.35.3/src/ormlambda/common/interfaces/ICustomAlias.py +0 -7
- ormlambda-3.35.3/src/ormlambda/common/interfaces/IDecompositionQuery.py +0 -33
- ormlambda-3.35.3/src/ormlambda/databases/__init__.py +0 -4
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/__init__.py +0 -3
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/ST_AsText.py +0 -37
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/ST_Contains.py +0 -36
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/__init__.py +0 -14
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/count.py +0 -33
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/delete.py +0 -9
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/drop_table.py +0 -26
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/group_by.py +0 -17
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/having.py +0 -12
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/insert.py +0 -9
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/joins.py +0 -14
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/limit.py +0 -6
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/offset.py +0 -6
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/order.py +0 -8
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/update.py +0 -8
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/upsert.py +0 -9
- ormlambda-3.35.3/src/ormlambda/databases/my_sql/clauses/where.py +0 -7
- ormlambda-3.35.3/src/ormlambda/dialects/__init__.py +0 -39
- ormlambda-3.35.3/src/ormlambda/dialects/interface/__init__.py +0 -1
- ormlambda-3.35.3/src/ormlambda/dialects/mysql/__init__.py +0 -84
- ormlambda-3.35.3/src/ormlambda/sql/__init__.py +0 -3
- ormlambda-3.35.3/src/ormlambda/sql/clause_info/__init__.py +0 -4
- ormlambda-3.35.3/src/ormlambda/sql/clause_info/aggregate_function_base.py +0 -96
- ormlambda-3.35.3/src/ormlambda/sql/clause_info/clause_info_context.py +0 -87
- ormlambda-3.35.3/src/ormlambda/sql/clause_info/interface/IAggregate.py +0 -10
- ormlambda-3.35.3/src/ormlambda/sql/clauses/alias.py +0 -45
- ormlambda-3.35.3/src/ormlambda/sql/clauses/count.py +0 -57
- ormlambda-3.35.3/src/ormlambda/sql/clauses/group_by.py +0 -30
- ormlambda-3.35.3/src/ormlambda/sql/clauses/interfaces/ISelect.py +0 -17
- ormlambda-3.35.3/src/ormlambda/sql/clauses/new_join.py +0 -119
- ormlambda-3.35.3/src/ormlambda/sql/clauses/select.py +0 -51
- ormlambda-3.35.3/src/ormlambda/sql/clauses/where.py +0 -65
- ormlambda-3.35.3/src/ormlambda/sql/column/__init__.py +0 -1
- ormlambda-3.35.3/src/ormlambda/sql/compiler.py +0 -427
- ormlambda-3.35.3/src/ormlambda/sql/functions/concat.py +0 -48
- ormlambda-3.35.3/src/ormlambda/sql/functions/max.py +0 -48
- ormlambda-3.35.3/src/ormlambda/sql/functions/min.py +0 -39
- ormlambda-3.35.3/src/ormlambda/sql/functions/sum.py +0 -41
- ormlambda-3.35.3/src/ormlambda/sql/types.py +0 -27
- ormlambda-3.35.3/src/ormlambda/statements/__init__.py +0 -3
- ormlambda-3.35.3/src/ormlambda/statements/base_statement.py +0 -123
- ormlambda-3.35.3/src/ormlambda/statements/interfaces/IStatements.py +0 -345
- ormlambda-3.35.3/src/ormlambda/statements/interfaces/__init__.py +0 -1
- ormlambda-3.35.3/src/ormlambda/statements/query_builder.py +0 -163
- ormlambda-3.35.3/src/ormlambda/statements/types.py +0 -57
- ormlambda-3.35.3/src/ormlambda/util/load_module.py +0 -21
- ormlambda-3.35.3/src/ormlambda/util/plugin_loader.py +0 -32
- ormlambda-3.35.3/src/ormlambda/util/typing.py +0 -6
- {ormlambda-3.35.3 → ormlambda-4.0.4}/AUTHORS +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/LICENSE +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/caster/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/caster/base_caster.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/caster/interfaces/ICaster.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/caster/interfaces/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/abstract_classes/non_query_base.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/enums/condition_types.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/enums/join_type.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/interfaces/IJoinSelector.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/common/interfaces/INonQueryCommand.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/default/__init__.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/__init__.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/caster.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/__init__.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/boolean.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/bytes.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/date.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/datetime.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/decimal.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/float.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/int.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/iterable.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/json.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/none.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/point.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql}/caster/types/string.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/mysql/mysqlconnector.py +0 -0
- {ormlambda-3.35.3/src/ormlambda/databases/my_sql → ormlambda-4.0.4/src/ormlambda/dialects/mysql/repository}/pool_types.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/sqlite/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/sqlite/base.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/dialects/sqlite/pysqlite.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/engine/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/engine/create.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/engine/url.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/engine/utils.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/env.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/model/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/repository/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/repository/interfaces/IDatabaseConnection.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/repository/interfaces/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clause_info/interface/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/delete.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/interfaces/IDelete.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/interfaces/IInsert.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/interfaces/IUpdate.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/interfaces/IUpsert.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/join/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/clauses/upsert.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/interfaces/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/table/fields.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/table/table_constructor.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/sql/visitors.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/types/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/types/metadata.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/src/ormlambda/util/module_tree/__init__.py +0 -0
- {ormlambda-3.35.3 → ormlambda-4.0.4}/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
|
+
Version: 4.0.4
|
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
|
@@ -90,16 +90,7 @@ If we were used `select_one` method, we retrieved `tuple[Address, City, Country]
|
|
90
90
|
|
91
91
|
## Filter by `where` condition
|
92
92
|
|
93
|
-
|
94
|
-
```python
|
95
|
-
result = AddressModel.where(
|
96
|
-
[
|
97
|
-
Address.address_id >= 10,
|
98
|
-
Address.address_id <= 30,
|
99
|
-
]
|
100
|
-
).select()
|
101
|
-
```
|
102
|
-
Or by using a lambda function that returns an iterable for tables where the name is unusually long.
|
93
|
+
We can use lambda function that returns an iterable to pass the iterable like.
|
103
94
|
|
104
95
|
```python
|
105
96
|
result = AddressModel.where(
|
@@ -119,7 +110,7 @@ result = AddressModel.where(Address.City.Country.country_id == 87).select()
|
|
119
110
|
We can also return `Address`, `City` or `Country` if needed.
|
120
111
|
|
121
112
|
```python
|
122
|
-
result = AddressModel.where(
|
113
|
+
result = AddressModel.where(lambda x: x.City.Country.country_id == 87).select(lambda x: (x, x.City, x.City.Country))
|
123
114
|
```
|
124
115
|
|
125
116
|
### Pass variables to the `where` method
|
@@ -127,10 +118,10 @@ result = AddressModel.where(Address.City.Country.country_id == 87).select(lambda
|
|
127
118
|
LOWER = 10
|
128
119
|
UPPER = 30
|
129
120
|
|
130
|
-
AddressModel.where(
|
121
|
+
AddressModel.where(lambda x:
|
131
122
|
[
|
132
|
-
|
133
|
-
|
123
|
+
x.address_id >= LOWER,
|
124
|
+
x.address_id <= UPPER,
|
134
125
|
]
|
135
126
|
).select()
|
136
127
|
```
|
@@ -238,7 +229,7 @@ result = (
|
|
238
229
|
AddressModel
|
239
230
|
.order(lambda a: a.address_id, order_type="DESC")
|
240
231
|
.where(lambda x: x.City.Country.country_id >= 50)
|
241
|
-
.select(
|
232
|
+
.select()
|
242
233
|
)
|
243
234
|
|
244
235
|
```
|
@@ -246,13 +237,12 @@ Also you can use `ConditionType` enum for `regular expressions` and get, for exa
|
|
246
237
|
|
247
238
|
|
248
239
|
```python
|
249
|
-
|
240
|
+
response = (
|
250
241
|
AddressModel
|
251
|
-
.order(
|
252
|
-
.where(
|
242
|
+
.order(lambda x: x.address_id, order_type="DESC")
|
243
|
+
.where(lambda x: x.City.Country.country.regex(r"^[A]"))
|
253
244
|
.limit(100)
|
254
|
-
.select(
|
255
|
-
lambda a: (
|
245
|
+
.select(lambda a: (
|
256
246
|
a,
|
257
247
|
a.City,
|
258
248
|
a.City.Country,
|
@@ -261,13 +251,9 @@ address, city, country = (
|
|
261
251
|
)
|
262
252
|
|
263
253
|
|
264
|
-
for a in
|
254
|
+
for a,c,co in response:
|
265
255
|
print(a.address_id)
|
266
|
-
|
267
|
-
for c in city:
|
268
256
|
print(c.city_id)
|
269
|
-
|
270
|
-
for co in country:
|
271
257
|
print(co.country)
|
272
258
|
```
|
273
259
|
|
@@ -276,10 +262,9 @@ In the example above, we see that the `result` var returns a tuple of tuples. Ho
|
|
276
262
|
|
277
263
|
```python
|
278
264
|
result = (
|
279
|
-
AddressModel.where(
|
265
|
+
AddressModel.where(lambda x: x.City.Country.country.regex(r"^[A]"))
|
280
266
|
.limit(100)
|
281
|
-
.select(
|
282
|
-
lambda a: (
|
267
|
+
.select(lambda a: (
|
283
268
|
a.address_id,
|
284
269
|
a.City.city_id,
|
285
270
|
a.City.Country.country_id,
|
@@ -296,19 +281,19 @@ with this approach, we will obtain a dictionary where the key will be the concat
|
|
296
281
|
|
297
282
|
## max
|
298
283
|
```python
|
299
|
-
res = AddressModel.max(
|
284
|
+
res = AddressModel.max(lambda x: x.address_id)
|
300
285
|
```
|
301
286
|
## min
|
302
287
|
```python
|
303
|
-
res = AddressModel.min(
|
288
|
+
res = AddressModel.min(lambda x: x.address_id)
|
304
289
|
```
|
305
290
|
## sum
|
306
291
|
```python
|
307
|
-
res = AddressModel.sum(
|
292
|
+
res = AddressModel.sum(lambda x: x.address_id)
|
308
293
|
```
|
309
294
|
## count
|
310
295
|
```python
|
311
|
-
res = AddressModel.count(
|
296
|
+
res = AddressModel.count(lambda x: x.address_id)
|
312
297
|
```
|
313
298
|
|
314
299
|
## 1. Concat
|
@@ -318,28 +303,23 @@ The `concat` method allows you to concatenate multiple columns or values into a
|
|
318
303
|
### Usage
|
319
304
|
|
320
305
|
```python
|
321
|
-
response =
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
)
|
334
|
-
),
|
335
|
-
),
|
336
|
-
flavour=dict,
|
337
|
-
)
|
306
|
+
response = (
|
307
|
+
ORM(Address, db)
|
308
|
+
.where(lambda x: x.City.Country.country.regex(r"^Spain"))
|
309
|
+
.first(
|
310
|
+
lambda x: (
|
311
|
+
x.address,
|
312
|
+
x.City.city,
|
313
|
+
Concat(("Address: ", x.address, " - city: ", x.City.city, " - country: ", x.City.Country.country)),
|
314
|
+
),
|
315
|
+
flavour=dict,
|
316
|
+
)
|
317
|
+
)
|
338
318
|
|
339
319
|
{
|
340
|
-
"
|
341
|
-
"
|
342
|
-
"
|
320
|
+
"address": "939 Probolinggo Loop",
|
321
|
+
"city": "A Coruña (La Coruña)",
|
322
|
+
"concat": "Address: 939 Probolinggo Loop - city: A Coruña (La Coruña) - country: Spain",
|
343
323
|
}
|
344
324
|
```
|
345
325
|
As you can see in the response, the result is a dictionary where the keys are a combination of the table name and the column name. This is done to avoid collisions with columns from other tables that might have the same name.
|
@@ -364,15 +344,13 @@ class Response(BaseModel):
|
|
364
344
|
engine= create_engine(DATABASE_URL)
|
365
345
|
model = ORM(Address,engine)
|
366
346
|
|
367
|
-
count_name = Column(column_name="count")
|
368
|
-
|
369
347
|
res = (
|
370
348
|
self.model
|
371
|
-
.groupby(
|
372
|
-
.select(
|
349
|
+
.groupby(lambda x: x.district)
|
350
|
+
.select(lambda x:
|
373
351
|
(
|
374
|
-
|
375
|
-
|
352
|
+
x.district,
|
353
|
+
Count(x.address),
|
376
354
|
),
|
377
355
|
flavour=Response,
|
378
356
|
)
|
@@ -387,12 +365,12 @@ The `having` method is used to filter results based on aggregate functions. It i
|
|
387
365
|
```python
|
388
366
|
res = (
|
389
367
|
model
|
390
|
-
.groupby(
|
391
|
-
.having(
|
392
|
-
.select(
|
368
|
+
.groupby(lambda x: x.district)
|
369
|
+
.having(lambda x: x.count > 4)
|
370
|
+
.select(lambda x:
|
393
371
|
(
|
394
|
-
|
395
|
-
|
372
|
+
x.district,
|
373
|
+
Count(x.address,alias="count"),
|
396
374
|
),
|
397
375
|
flavour=Response,
|
398
376
|
)
|
@@ -422,9 +400,9 @@ select = (
|
|
422
400
|
ORM(Address, db)
|
423
401
|
.order(lambda x: x.City.Country.country, "DESC")
|
424
402
|
.limit(10)
|
425
|
-
.where(
|
426
|
-
.first(
|
427
|
-
|
403
|
+
.where(lambda x: x.City.Country.country == "Spain")
|
404
|
+
.first(lambda x:
|
405
|
+
(
|
428
406
|
x.address,
|
429
407
|
x.City.city,
|
430
408
|
x.City.Country.country,
|
@@ -444,14 +422,13 @@ print(select.city)
|
|
444
422
|
print(select.country)
|
445
423
|
```
|
446
424
|
|
447
|
-
##
|
448
|
-
|
425
|
+
## Aggregation method
|
426
|
+
You can also use `aggregation methods` to create more informative queries.
|
449
427
|
```python
|
450
|
-
result = AddressModel.select_one(
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
AddressModel.count(x.address_id),
|
428
|
+
result = AddressModel.select_one(lambda x: (
|
429
|
+
Min(x.address_id),
|
430
|
+
Max(x.address_id),
|
431
|
+
Count(x.address_id),
|
455
432
|
),flavour=dict
|
456
433
|
)
|
457
434
|
```
|
@@ -468,11 +445,11 @@ Getting something like
|
|
468
445
|
You also can use custom alias for each method
|
469
446
|
|
470
447
|
```python
|
471
|
-
AddressModel.select_one(
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
448
|
+
AddressModel.select_one(lambda x:
|
449
|
+
(
|
450
|
+
Min(x.address_id),
|
451
|
+
Max(x.address_id, alias="custom-max"),
|
452
|
+
Count(x.address_id),
|
476
453
|
),
|
477
454
|
flavour=dict,
|
478
455
|
)
|
@@ -77,16 +77,7 @@ If we were used `select_one` method, we retrieved `tuple[Address, City, Country]
|
|
77
77
|
|
78
78
|
## Filter by `where` condition
|
79
79
|
|
80
|
-
|
81
|
-
```python
|
82
|
-
result = AddressModel.where(
|
83
|
-
[
|
84
|
-
Address.address_id >= 10,
|
85
|
-
Address.address_id <= 30,
|
86
|
-
]
|
87
|
-
).select()
|
88
|
-
```
|
89
|
-
Or by using a lambda function that returns an iterable for tables where the name is unusually long.
|
80
|
+
We can use lambda function that returns an iterable to pass the iterable like.
|
90
81
|
|
91
82
|
```python
|
92
83
|
result = AddressModel.where(
|
@@ -106,7 +97,7 @@ result = AddressModel.where(Address.City.Country.country_id == 87).select()
|
|
106
97
|
We can also return `Address`, `City` or `Country` if needed.
|
107
98
|
|
108
99
|
```python
|
109
|
-
result = AddressModel.where(
|
100
|
+
result = AddressModel.where(lambda x: x.City.Country.country_id == 87).select(lambda x: (x, x.City, x.City.Country))
|
110
101
|
```
|
111
102
|
|
112
103
|
### Pass variables to the `where` method
|
@@ -114,10 +105,10 @@ result = AddressModel.where(Address.City.Country.country_id == 87).select(lambda
|
|
114
105
|
LOWER = 10
|
115
106
|
UPPER = 30
|
116
107
|
|
117
|
-
AddressModel.where(
|
108
|
+
AddressModel.where(lambda x:
|
118
109
|
[
|
119
|
-
|
120
|
-
|
110
|
+
x.address_id >= LOWER,
|
111
|
+
x.address_id <= UPPER,
|
121
112
|
]
|
122
113
|
).select()
|
123
114
|
```
|
@@ -225,7 +216,7 @@ result = (
|
|
225
216
|
AddressModel
|
226
217
|
.order(lambda a: a.address_id, order_type="DESC")
|
227
218
|
.where(lambda x: x.City.Country.country_id >= 50)
|
228
|
-
.select(
|
219
|
+
.select()
|
229
220
|
)
|
230
221
|
|
231
222
|
```
|
@@ -233,13 +224,12 @@ Also you can use `ConditionType` enum for `regular expressions` and get, for exa
|
|
233
224
|
|
234
225
|
|
235
226
|
```python
|
236
|
-
|
227
|
+
response = (
|
237
228
|
AddressModel
|
238
|
-
.order(
|
239
|
-
.where(
|
229
|
+
.order(lambda x: x.address_id, order_type="DESC")
|
230
|
+
.where(lambda x: x.City.Country.country.regex(r"^[A]"))
|
240
231
|
.limit(100)
|
241
|
-
.select(
|
242
|
-
lambda a: (
|
232
|
+
.select(lambda a: (
|
243
233
|
a,
|
244
234
|
a.City,
|
245
235
|
a.City.Country,
|
@@ -248,13 +238,9 @@ address, city, country = (
|
|
248
238
|
)
|
249
239
|
|
250
240
|
|
251
|
-
for a in
|
241
|
+
for a,c,co in response:
|
252
242
|
print(a.address_id)
|
253
|
-
|
254
|
-
for c in city:
|
255
243
|
print(c.city_id)
|
256
|
-
|
257
|
-
for co in country:
|
258
244
|
print(co.country)
|
259
245
|
```
|
260
246
|
|
@@ -263,10 +249,9 @@ In the example above, we see that the `result` var returns a tuple of tuples. Ho
|
|
263
249
|
|
264
250
|
```python
|
265
251
|
result = (
|
266
|
-
AddressModel.where(
|
252
|
+
AddressModel.where(lambda x: x.City.Country.country.regex(r"^[A]"))
|
267
253
|
.limit(100)
|
268
|
-
.select(
|
269
|
-
lambda a: (
|
254
|
+
.select(lambda a: (
|
270
255
|
a.address_id,
|
271
256
|
a.City.city_id,
|
272
257
|
a.City.Country.country_id,
|
@@ -283,19 +268,19 @@ with this approach, we will obtain a dictionary where the key will be the concat
|
|
283
268
|
|
284
269
|
## max
|
285
270
|
```python
|
286
|
-
res = AddressModel.max(
|
271
|
+
res = AddressModel.max(lambda x: x.address_id)
|
287
272
|
```
|
288
273
|
## min
|
289
274
|
```python
|
290
|
-
res = AddressModel.min(
|
275
|
+
res = AddressModel.min(lambda x: x.address_id)
|
291
276
|
```
|
292
277
|
## sum
|
293
278
|
```python
|
294
|
-
res = AddressModel.sum(
|
279
|
+
res = AddressModel.sum(lambda x: x.address_id)
|
295
280
|
```
|
296
281
|
## count
|
297
282
|
```python
|
298
|
-
res = AddressModel.count(
|
283
|
+
res = AddressModel.count(lambda x: x.address_id)
|
299
284
|
```
|
300
285
|
|
301
286
|
## 1. Concat
|
@@ -305,28 +290,23 @@ The `concat` method allows you to concatenate multiple columns or values into a
|
|
305
290
|
### Usage
|
306
291
|
|
307
292
|
```python
|
308
|
-
response =
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
)
|
321
|
-
),
|
322
|
-
),
|
323
|
-
flavour=dict,
|
324
|
-
)
|
293
|
+
response = (
|
294
|
+
ORM(Address, db)
|
295
|
+
.where(lambda x: x.City.Country.country.regex(r"^Spain"))
|
296
|
+
.first(
|
297
|
+
lambda x: (
|
298
|
+
x.address,
|
299
|
+
x.City.city,
|
300
|
+
Concat(("Address: ", x.address, " - city: ", x.City.city, " - country: ", x.City.Country.country)),
|
301
|
+
),
|
302
|
+
flavour=dict,
|
303
|
+
)
|
304
|
+
)
|
325
305
|
|
326
306
|
{
|
327
|
-
"
|
328
|
-
"
|
329
|
-
"
|
307
|
+
"address": "939 Probolinggo Loop",
|
308
|
+
"city": "A Coruña (La Coruña)",
|
309
|
+
"concat": "Address: 939 Probolinggo Loop - city: A Coruña (La Coruña) - country: Spain",
|
330
310
|
}
|
331
311
|
```
|
332
312
|
As you can see in the response, the result is a dictionary where the keys are a combination of the table name and the column name. This is done to avoid collisions with columns from other tables that might have the same name.
|
@@ -351,15 +331,13 @@ class Response(BaseModel):
|
|
351
331
|
engine= create_engine(DATABASE_URL)
|
352
332
|
model = ORM(Address,engine)
|
353
333
|
|
354
|
-
count_name = Column(column_name="count")
|
355
|
-
|
356
334
|
res = (
|
357
335
|
self.model
|
358
|
-
.groupby(
|
359
|
-
.select(
|
336
|
+
.groupby(lambda x: x.district)
|
337
|
+
.select(lambda x:
|
360
338
|
(
|
361
|
-
|
362
|
-
|
339
|
+
x.district,
|
340
|
+
Count(x.address),
|
363
341
|
),
|
364
342
|
flavour=Response,
|
365
343
|
)
|
@@ -374,12 +352,12 @@ The `having` method is used to filter results based on aggregate functions. It i
|
|
374
352
|
```python
|
375
353
|
res = (
|
376
354
|
model
|
377
|
-
.groupby(
|
378
|
-
.having(
|
379
|
-
.select(
|
355
|
+
.groupby(lambda x: x.district)
|
356
|
+
.having(lambda x: x.count > 4)
|
357
|
+
.select(lambda x:
|
380
358
|
(
|
381
|
-
|
382
|
-
|
359
|
+
x.district,
|
360
|
+
Count(x.address,alias="count"),
|
383
361
|
),
|
384
362
|
flavour=Response,
|
385
363
|
)
|
@@ -409,9 +387,9 @@ select = (
|
|
409
387
|
ORM(Address, db)
|
410
388
|
.order(lambda x: x.City.Country.country, "DESC")
|
411
389
|
.limit(10)
|
412
|
-
.where(
|
413
|
-
.first(
|
414
|
-
|
390
|
+
.where(lambda x: x.City.Country.country == "Spain")
|
391
|
+
.first(lambda x:
|
392
|
+
(
|
415
393
|
x.address,
|
416
394
|
x.City.city,
|
417
395
|
x.City.Country.country,
|
@@ -431,14 +409,13 @@ print(select.city)
|
|
431
409
|
print(select.country)
|
432
410
|
```
|
433
411
|
|
434
|
-
##
|
435
|
-
|
412
|
+
## Aggregation method
|
413
|
+
You can also use `aggregation methods` to create more informative queries.
|
436
414
|
```python
|
437
|
-
result = AddressModel.select_one(
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
AddressModel.count(x.address_id),
|
415
|
+
result = AddressModel.select_one(lambda x: (
|
416
|
+
Min(x.address_id),
|
417
|
+
Max(x.address_id),
|
418
|
+
Count(x.address_id),
|
442
419
|
),flavour=dict
|
443
420
|
)
|
444
421
|
```
|
@@ -455,11 +432,11 @@ Getting something like
|
|
455
432
|
You also can use custom alias for each method
|
456
433
|
|
457
434
|
```python
|
458
|
-
AddressModel.select_one(
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
435
|
+
AddressModel.select_one(lambda x:
|
436
|
+
(
|
437
|
+
Min(x.address_id),
|
438
|
+
Max(x.address_id, alias="custom-max"),
|
439
|
+
Count(x.address_id),
|
463
440
|
),
|
464
441
|
flavour=dict,
|
465
442
|
)
|
@@ -3,7 +3,7 @@ line-length = 320
|
|
3
3
|
|
4
4
|
[tool.poetry]
|
5
5
|
name = "ormlambda"
|
6
|
-
version = "
|
6
|
+
version = "4.0.4"
|
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
|
-
|
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
|
@@ -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 '
|
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,
|
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__}' "
|