ormlambda 3.12.2__tar.gz → 3.34.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.
- ormlambda-3.34.0/AUTHORS +32 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/PKG-INFO +1 -1
- {ormlambda-3.12.2 → ormlambda-3.34.0}/pyproject.toml +2 -1
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/__init__.py +2 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/caster/__init__.py +1 -1
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/caster/caster.py +29 -12
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/clause_info_converter.py +4 -12
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/decomposition_query.py +17 -2
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/non_query_base.py +9 -7
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/query_base.py +3 -1
- ormlambda-3.34.0/src/ormlambda/common/errors/__init__.py +50 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/interfaces/IQueryCommand.py +6 -2
- ormlambda-3.34.0/src/ormlambda/dialects/__init__.py +39 -0
- ormlambda-3.34.0/src/ormlambda/dialects/default/__init__.py +1 -0
- ormlambda-3.34.0/src/ormlambda/dialects/default/base.py +39 -0
- ormlambda-3.34.0/src/ormlambda/dialects/interface/__init__.py +1 -0
- ormlambda-3.34.0/src/ormlambda/dialects/interface/dialect.py +78 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/__init__.py +38 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/base.py +388 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/caster/caster.py +39 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/__init__.py +1 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/caster/types/boolean.py +35 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/bytes.py +7 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/datetime.py +7 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/float.py +7 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/int.py +7 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/iterable.py +7 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/none.py +8 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/point.py +4 -4
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/types/string.py +7 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/clauses/ST_AsText.py +8 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/clauses/ST_Contains.py +10 -5
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/__init__.py +13 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/count.py +33 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/delete.py +9 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/group_by.py +17 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/having.py +12 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/insert.py +9 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/joins.py +14 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/limit.py +6 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/offset.py +6 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/order.py +8 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/update.py +8 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/upsert.py +9 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/clauses/where.py +7 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/mysqlconnector.py +46 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/repository/__init__.py +1 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/repository/repository.py +212 -0
- ormlambda-3.34.0/src/ormlambda/dialects/mysql/types.py +732 -0
- ormlambda-3.34.0/src/ormlambda/dialects/sqlite/__init__.py +5 -0
- ormlambda-3.34.0/src/ormlambda/dialects/sqlite/base.py +47 -0
- ormlambda-3.34.0/src/ormlambda/dialects/sqlite/pysqlite.py +32 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/engine/__init__.py +1 -0
- ormlambda-3.34.0/src/ormlambda/engine/base.py +77 -0
- ormlambda-3.34.0/src/ormlambda/engine/create.py +21 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/engine/url.py +31 -19
- ormlambda-3.34.0/src/ormlambda/env.py +30 -0
- ormlambda-3.34.0/src/ormlambda/errors.py +17 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/model/base_model.py +7 -9
- ormlambda-3.34.0/src/ormlambda/repository/base_repository.py +44 -0
- ormlambda-3.34.0/src/ormlambda/repository/interfaces/IRepositoryBase.py +149 -0
- ormlambda-3.34.0/src/ormlambda/repository/response.py +134 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/aggregate_function_base.py +19 -9
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/clause_info.py +34 -17
- ormlambda-3.34.0/src/ormlambda/sql/clauses/__init__.py +14 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/alias.py +23 -6
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/count.py +15 -1
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/delete.py +22 -7
- ormlambda-3.34.0/src/ormlambda/sql/clauses/group_by.py +30 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/having.py +7 -2
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/insert.py +16 -9
- ormlambda-3.34.0/src/ormlambda/sql/clauses/interfaces/__init__.py +5 -0
- {ormlambda-3.12.2/src/ormlambda/components → ormlambda-3.34.0/src/ormlambda/sql/clauses}/join/join_context.py +15 -7
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/joins.py +29 -19
- ormlambda-3.34.0/src/ormlambda/sql/clauses/limit.py +15 -0
- ormlambda-3.34.0/src/ormlambda/sql/clauses/offset.py +15 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/order.py +14 -24
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/select.py +12 -13
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/update.py +24 -11
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/upsert.py +17 -12
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/clauses/where.py +28 -8
- ormlambda-3.34.0/src/ormlambda/sql/column/__init__.py +1 -0
- {ormlambda-3.12.2/src/ormlambda/sql → ormlambda-3.34.0/src/ormlambda/sql/column}/column.py +82 -22
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/comparer.py +51 -37
- ormlambda-3.34.0/src/ormlambda/sql/compiler.py +668 -0
- ormlambda-3.34.0/src/ormlambda/sql/ddl.py +82 -0
- ormlambda-3.34.0/src/ormlambda/sql/elements.py +36 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/foreign_key.py +61 -39
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/functions/concat.py +13 -5
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/functions/max.py +9 -4
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/functions/min.py +9 -13
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/functions/sum.py +8 -10
- ormlambda-3.34.0/src/ormlambda/sql/sqltypes.py +647 -0
- ormlambda-3.34.0/src/ormlambda/sql/table/__init__.py +1 -0
- ormlambda-3.12.2/src/ormlambda/sql/table/table_constructor.py → ormlambda-3.34.0/src/ormlambda/sql/table/table.py +13 -88
- ormlambda-3.34.0/src/ormlambda/sql/table/table_constructor.py +43 -0
- ormlambda-3.34.0/src/ormlambda/sql/type_api.py +35 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/types.py +3 -1
- ormlambda-3.34.0/src/ormlambda/sql/visitors.py +74 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/statements/__init__.py +1 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/statements/base_statement.py +28 -38
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/statements/interfaces/IStatements.py +8 -4
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/statements}/query_builder.py +35 -30
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/statements}/statements.py +57 -61
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/statements/types.py +2 -2
- ormlambda-3.34.0/src/ormlambda/types/__init__.py +24 -0
- ormlambda-3.34.0/src/ormlambda/types/metadata.py +42 -0
- ormlambda-3.34.0/src/ormlambda/util/__init__.py +87 -0
- {ormlambda-3.12.2/src/ormlambda/utils → ormlambda-3.34.0/src/ormlambda/util}/module_tree/dynamic_module.py +1 -1
- ormlambda-3.34.0/src/ormlambda/util/plugin_loader.py +32 -0
- ormlambda-3.34.0/src/ormlambda/util/typing.py +6 -0
- ormlambda-3.12.2/src/ormlambda/common/errors/__init__.py +0 -21
- ormlambda-3.12.2/src/ormlambda/components/__init__.py +0 -4
- ormlambda-3.12.2/src/ormlambda/components/delete/__init__.py +0 -2
- ormlambda-3.12.2/src/ormlambda/components/delete/abstract_delete.py +0 -17
- ormlambda-3.12.2/src/ormlambda/components/insert/__init__.py +0 -2
- ormlambda-3.12.2/src/ormlambda/components/insert/abstract_insert.py +0 -25
- ormlambda-3.12.2/src/ormlambda/components/select/__init__.py +0 -1
- ormlambda-3.12.2/src/ormlambda/components/update/__init__.py +0 -2
- ormlambda-3.12.2/src/ormlambda/components/update/abstract_update.py +0 -29
- ormlambda-3.12.2/src/ormlambda/components/upsert/__init__.py +0 -2
- ormlambda-3.12.2/src/ormlambda/components/upsert/abstract_upsert.py +0 -25
- ormlambda-3.12.2/src/ormlambda/databases/__init__.py +0 -5
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/__init__.py +0 -4
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/caster/caster.py +0 -39
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/__init__.py +0 -20
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/create_database.py +0 -35
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/drop_database.py +0 -17
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/drop_table.py +0 -26
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/group_by.py +0 -30
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/limit.py +0 -17
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/clauses/offset.py +0 -17
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/repository/__init__.py +0 -1
- ormlambda-3.12.2/src/ormlambda/databases/my_sql/repository/repository.py +0 -351
- ormlambda-3.12.2/src/ormlambda/engine/create.py +0 -35
- ormlambda-3.12.2/src/ormlambda/engine/template.py +0 -47
- ormlambda-3.12.2/src/ormlambda/repository/base_repository.py +0 -13
- ormlambda-3.12.2/src/ormlambda/repository/interfaces/IRepositoryBase.py +0 -42
- ormlambda-3.12.2/src/ormlambda/sql/dtypes.py +0 -94
- ormlambda-3.12.2/src/ormlambda/sql/table/__init__.py +0 -1
- ormlambda-3.12.2/src/ormlambda/utils/__init__.py +0 -1
- {ormlambda-3.12.2 → ormlambda-3.34.0}/LICENSE +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/README.md +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/caster/base_caster.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/caster/interfaces/ICaster.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/caster/interfaces/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/enums/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/enums/condition_types.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/enums/join_type.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/global_checker.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/interfaces/ICustomAlias.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/interfaces/IDecompositionQuery.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/interfaces/IJoinSelector.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/interfaces/INonQueryCommand.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/interfaces/__init__.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/dialects/mysql}/caster/__init__.py +0 -0
- /ormlambda-3.12.2/src/ormlambda/databases/my_sql/types.py → /ormlambda-3.34.0/src/ormlambda/dialects/mysql/repository/pool_types.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/engine/utils.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/model/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/repository/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/repository/interfaces/IDatabaseConnection.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/repository/interfaces/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/clause_info_context.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/interface/IAggregate.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/interface/IClauseInfo.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/clause_info/interface/__init__.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/components/delete → ormlambda-3.34.0/src/ormlambda/sql/clauses/interfaces}/IDelete.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/components/insert → ormlambda-3.34.0/src/ormlambda/sql/clauses/interfaces}/IInsert.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/components/select → ormlambda-3.34.0/src/ormlambda/sql/clauses/interfaces}/ISelect.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/components/update → ormlambda-3.34.0/src/ormlambda/sql/clauses/interfaces}/IUpdate.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/components/upsert → ormlambda-3.34.0/src/ormlambda/sql/clauses/interfaces}/IUpsert.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/components → ormlambda-3.34.0/src/ormlambda/sql/clauses}/join/__init__.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/databases/my_sql → ormlambda-3.34.0/src/ormlambda/sql}/functions/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/interfaces/__init__.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/sql/table/fields.py +0 -0
- {ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/statements/interfaces/__init__.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/utils → ormlambda-3.34.0/src/ormlambda/util}/module_tree/__init__.py +0 -0
- {ormlambda-3.12.2/src/ormlambda/utils → ormlambda-3.34.0/src/ormlambda/util}/module_tree/dfs_traversal.py +0 -0
ormlambda-3.34.0/AUTHORS
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
ormlambda was created by Pablo hernandez.
|
2
|
+
|
3
|
+
Some files was originally written by other authors from sqlalchemy library and rewritten by Pablo Hernandez
|
4
|
+
|
5
|
+
Major contributing authors include:
|
6
|
+
|
7
|
+
- Pablo Hernandez
|
8
|
+
- Jason Kirtland
|
9
|
+
- Michael Trier
|
10
|
+
- Diana Clarke
|
11
|
+
- Gaetan de Menten
|
12
|
+
- Lele Gaifax
|
13
|
+
- Jonathan Ellis
|
14
|
+
- Gord Thompson
|
15
|
+
- Federico Caselli
|
16
|
+
- Philip Jenvey
|
17
|
+
- Rick Morrison
|
18
|
+
- Chris Withers
|
19
|
+
- Ants Aasma
|
20
|
+
- Sheila Allen
|
21
|
+
- Paul Johnston
|
22
|
+
- Tony Locke
|
23
|
+
- Hajime Nakagami
|
24
|
+
- Vraj Mohan
|
25
|
+
- Robert Leftwich
|
26
|
+
- Taavi Burns
|
27
|
+
- Jonathan Vanasco
|
28
|
+
- Jeff Widman
|
29
|
+
- Scott Dugas
|
30
|
+
- Dobes Vandermeer
|
31
|
+
- Ville Skytta
|
32
|
+
- Rodrigo Menezes
|
@@ -3,7 +3,7 @@ line-length = 320
|
|
3
3
|
|
4
4
|
[tool.poetry]
|
5
5
|
name = "ormlambda"
|
6
|
-
version = "3.
|
6
|
+
version = "3.34.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"
|
@@ -20,6 +20,7 @@ pandas = "^2.2.2"
|
|
20
20
|
ruff = "^0.4.5"
|
21
21
|
parameterized = "^0.9.0"
|
22
22
|
pydantic = "^2.11.1"
|
23
|
+
sqlserver = "^0.0.17.1"
|
23
24
|
|
24
25
|
|
25
26
|
[build-system]
|
@@ -1,24 +1,26 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
|
4
|
-
from typing import Optional, Type, TYPE_CHECKING, Callable, overload
|
5
|
-
|
4
|
+
from typing import ClassVar, Optional, Type, TYPE_CHECKING, Callable, overload, get_args
|
5
|
+
from types import NoneType
|
6
|
+
from ormlambda.caster.interfaces import ICaster
|
6
7
|
from ormlambda.common.global_checker import GlobalChecker
|
7
8
|
from ormlambda.sql.types import ColumnType
|
8
|
-
from ormlambda.
|
9
|
+
from ormlambda.caster import BaseCaster
|
10
|
+
from ormlambda.sql.sqltypes import TypeEngine
|
11
|
+
|
9
12
|
|
10
13
|
if TYPE_CHECKING:
|
11
14
|
from ormlambda.caster import BaseCaster
|
12
|
-
from ormlambda.repository import IRepositoryBase
|
13
15
|
|
14
16
|
|
15
|
-
|
17
|
+
class Caster(ICaster):
|
18
|
+
PLACEHOLDER: ClassVar[str] = "%s"
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
self._caster = RepositoryTemplateDict().get(repository).caster
|
20
|
+
@classmethod
|
21
|
+
def set_placeholder(cls, char: str) -> None:
|
22
|
+
cls.PLACEHOLDER = char
|
23
|
+
return None
|
22
24
|
|
23
25
|
@overload
|
24
26
|
def for_column[T, TProp](self, column: Callable[[T], TProp], instance: T) -> BaseCaster[TProp, Type[TProp]]: ...
|
@@ -36,7 +38,7 @@ class Caster:
|
|
36
38
|
column_type = column.dtype
|
37
39
|
value = instance[column]
|
38
40
|
|
39
|
-
return self.
|
41
|
+
return self.cast(value, column_type)
|
40
42
|
|
41
43
|
@overload
|
42
44
|
def for_value[TProp](self, value: TProp) -> BaseCaster[TProp, Type[TProp]]: ...
|
@@ -45,4 +47,19 @@ class Caster:
|
|
45
47
|
|
46
48
|
def for_value[TProp, TType](self, value: TProp, value_type: Optional[TType] = None) -> BaseCaster[TProp, TType]:
|
47
49
|
column_type = value_type if value_type else type(value)
|
48
|
-
return self.
|
50
|
+
return self.cast(value, column_type)
|
51
|
+
|
52
|
+
@classmethod
|
53
|
+
def cast[TProp, TType](cls, value: TProp, type_value: Optional[TypeEngine[TType]] = None) -> BaseCaster[TProp, TType]:
|
54
|
+
if len(args := get_args(type_value)) > 1:
|
55
|
+
args = [x for x in args if x != NoneType]
|
56
|
+
|
57
|
+
type_value = args[0]
|
58
|
+
|
59
|
+
if isinstance(type_value, TypeEngine):
|
60
|
+
column_type = type_value.python_type
|
61
|
+
elif not type_value:
|
62
|
+
column_type = type(value)
|
63
|
+
else:
|
64
|
+
column_type = type_value
|
65
|
+
return cls.CASTER_SELECTOR()[column_type](value, column_type)
|
{ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/clause_info_converter.py
RENAMED
@@ -17,21 +17,13 @@ class ClauseInfoConverter[T, TProp](tp.Protocol):
|
|
17
17
|
class ConvertFromAnyType(ClauseInfoConverter[None, None]):
|
18
18
|
@classmethod
|
19
19
|
def convert(cls, data: tp.Any, alias_table: AliasType = "{table}", context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[None]]:
|
20
|
-
return [
|
21
|
-
ClauseInfo[None](
|
22
|
-
table=None,
|
23
|
-
column=data,
|
24
|
-
alias_table=alias_table,
|
25
|
-
alias_clause=kwargs.get("alias", None),
|
26
|
-
context=context,
|
27
|
-
)
|
28
|
-
]
|
20
|
+
return [ClauseInfo[None](table=None, column=data, alias_table=alias_table, alias_clause=kwargs.get("alias", None), context=context, **kwargs)]
|
29
21
|
|
30
22
|
|
31
23
|
class ConvertFromForeignKey[LT: Table, RT: Table](ClauseInfoConverter[RT, None]):
|
32
24
|
@classmethod
|
33
25
|
def convert(cls, data: ForeignKey[LT, RT], alias_table=None, context: ClauseContextType = None, **kwargs) -> list[ClauseInfo[RT]]:
|
34
|
-
return ConvertFromTable[RT].convert(data.tright, data.
|
26
|
+
return ConvertFromTable[RT].convert(data.tright, data.get_alias(kwargs["dialect"]), context, **kwargs)
|
35
27
|
|
36
28
|
|
37
29
|
class ConvertFromColumn[TProp](ClauseInfoConverter[None, TProp]):
|
@@ -44,9 +36,9 @@ class ConvertFromColumn[TProp](ClauseInfoConverter[None, TProp]):
|
|
44
36
|
"alias_table": alias_table,
|
45
37
|
"alias_clause": "{table}_{column}",
|
46
38
|
"context": context,
|
47
|
-
**kwargs,
|
48
39
|
}
|
49
|
-
|
40
|
+
attributes.update(**kwargs)
|
41
|
+
clause_info = ClauseInfo(**attributes)
|
50
42
|
return [clause_info]
|
51
43
|
|
52
44
|
|
{ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/decomposition_query.py
RENAMED
@@ -27,6 +27,9 @@ type ValueType = tp.Union[
|
|
27
27
|
tp.Type[ICustomAlias],
|
28
28
|
]
|
29
29
|
|
30
|
+
if tp.TYPE_CHECKING:
|
31
|
+
from ormlambda.dialects import Dialect
|
32
|
+
|
30
33
|
|
31
34
|
class DecompositionQueryBase[T: Table, *Ts](IDecompositionQuery[T, *Ts]):
|
32
35
|
@tp.overload
|
@@ -36,10 +39,20 @@ class DecompositionQueryBase[T: Table, *Ts](IDecompositionQuery[T, *Ts]):
|
|
36
39
|
@tp.overload
|
37
40
|
def __init__(self, tables: tuple[TableType[T]], columns: tuple[ColumnType], alias_table: str, context: ClauseContextType = ...) -> None: ...
|
38
41
|
|
39
|
-
def __init__(
|
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:
|
40
52
|
self.kwargs = kwargs
|
41
53
|
self._tables: tuple[TableType[T]] = tables if isinstance(tables, tp.Iterable) else (tables,)
|
42
54
|
|
55
|
+
self._dialect = dialect
|
43
56
|
self._columns: tp.Callable[[T], tuple] = columns
|
44
57
|
self._all_clauses: list[ClauseInfo | AggregateFunctionBase] = []
|
45
58
|
self._context: ClauseContextType = context if context else ClauseInfoContext()
|
@@ -88,7 +101,9 @@ class DecompositionQueryBase[T: Table, *Ts](IDecompositionQuery[T, *Ts]):
|
|
88
101
|
Table: ConvertFromTable[T],
|
89
102
|
}
|
90
103
|
classConverter = next((converter for obj, converter in VALUE_TYPE_MAPPED.items() if validation(data, obj)), ConvertFromAnyType)
|
91
|
-
|
104
|
+
self.kwargs.setdefault("dialect", self._dialect)
|
105
|
+
if "dialect" not in self.kwargs:
|
106
|
+
raise ValueError("You must specified 'dialect' variable")
|
92
107
|
return classConverter.convert(data, alias_table=self._alias_table, context=self._context, **self.kwargs)
|
93
108
|
|
94
109
|
def __add_clause[TTable: TableType](self, clauses: list[ClauseInfo[TTable]] | ClauseInfo[TTable]) -> None:
|
{ormlambda-3.12.2 → ormlambda-3.34.0}/src/ormlambda/common/abstract_classes/non_query_base.py
RENAMED
@@ -1,22 +1,26 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from abc import abstractmethod
|
3
|
-
from typing import Any, Optional, Type,
|
3
|
+
from typing import Any, Optional, Type, TYPE_CHECKING
|
4
4
|
|
5
5
|
from ormlambda.common.interfaces.INonQueryCommand import INonQueryCommand
|
6
6
|
|
7
7
|
if TYPE_CHECKING:
|
8
8
|
from ormlambda.repository import BaseRepository
|
9
|
+
from ormlambda.dialects import Dialect
|
9
10
|
from ormlambda import Table
|
11
|
+
from ormlambda.engine import Engine
|
10
12
|
|
11
13
|
|
12
|
-
class NonQueryBase[T: Type[Table], TRepo
|
14
|
+
class NonQueryBase[T: Type[Table], TRepo](INonQueryCommand):
|
13
15
|
__slots__: tuple[str, ...] = ("_model", "_repository", "_values", "_query")
|
14
16
|
|
15
|
-
def __init__(self, model: T, repository: TRepo) -> None:
|
17
|
+
def __init__(self, model: T, repository: TRepo, **kwargs) -> None:
|
16
18
|
self._model: T = model
|
17
|
-
self._repository: TRepo = repository
|
19
|
+
self._repository: BaseRepository[TRepo] = repository
|
18
20
|
self._values: list[tuple[Any]] = []
|
19
21
|
self._query: Optional[str] = None
|
22
|
+
self._dialect: Dialect = kwargs.get("dialect", None)
|
23
|
+
self._engine: Optional[Engine] = kwargs.get("engine", None)
|
20
24
|
|
21
25
|
@property
|
22
26
|
@abstractmethod
|
@@ -25,9 +29,7 @@ class NonQueryBase[T: Type[Table], TRepo: BaseRepository](INonQueryCommand):
|
|
25
29
|
@abstractmethod
|
26
30
|
def execute(self) -> None: ...
|
27
31
|
|
28
|
-
|
29
|
-
@override
|
30
|
-
def query(self) -> str:
|
32
|
+
def query(self, dialect: Dialect, **kwargs) -> str:
|
31
33
|
return self._query
|
32
34
|
|
33
35
|
@property
|
@@ -1,3 +1,4 @@
|
|
1
|
+
from __future__ import annotations
|
1
2
|
from abc import abstractmethod
|
2
3
|
from typing import TYPE_CHECKING
|
3
4
|
|
@@ -5,9 +6,10 @@ from ormlambda.common.interfaces import IQuery
|
|
5
6
|
|
6
7
|
if TYPE_CHECKING:
|
7
8
|
from ormlambda import Table
|
9
|
+
from ormlambda.dialects import Dialect
|
8
10
|
|
9
11
|
|
10
12
|
class QueryBase[T: Table](IQuery):
|
11
13
|
@property
|
12
14
|
@abstractmethod
|
13
|
-
def query(self) -> str: ...
|
15
|
+
def query(self, dialect: Dialect, **kwargs) -> str: ...
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
import inspect
|
3
|
+
import typing as tp
|
4
|
+
|
5
|
+
|
6
|
+
if tp.TYPE_CHECKING:
|
7
|
+
from ormlambda.sql.clause_info import ClauseInfo
|
8
|
+
|
9
|
+
|
10
|
+
class UnmatchedLambdaParameterError(Exception):
|
11
|
+
def __init__(self, expected_params: int, function: tp.Callable[..., tp.Any], *args: object) -> None:
|
12
|
+
super().__init__(*args)
|
13
|
+
self.expected_params = expected_params
|
14
|
+
self.found_param: tuple[str, ...] = tuple(inspect.signature(function).parameters)
|
15
|
+
|
16
|
+
def __str__(self) -> str:
|
17
|
+
return f"Unmatched number of parameters in lambda function with the number of tables: Expected {self.expected_params} parameters but found {str(self.found_param)}."
|
18
|
+
|
19
|
+
|
20
|
+
class NotKeysInIAggregateError(Exception):
|
21
|
+
def __init__(self, match_regex: list[str], *args: object) -> None:
|
22
|
+
super().__init__(*args)
|
23
|
+
self._match_regex: list[str] = match_regex
|
24
|
+
|
25
|
+
def __str__(self) -> str:
|
26
|
+
return f"We cannot use placeholders in IAggregate class. You used {self._match_regex}"
|
27
|
+
|
28
|
+
|
29
|
+
class AggregateFunctionError[T](Exception):
|
30
|
+
def __init__(self, clause: ClauseInfo[T], *args):
|
31
|
+
self.clause = clause
|
32
|
+
super().__init__(*args)
|
33
|
+
|
34
|
+
def __str__(self):
|
35
|
+
agg_methods = self.__get_all_aggregate_method(self.clause)
|
36
|
+
return f"You cannot use aggregation method like '{agg_methods}' to return model objects. Try specifying 'flavour' attribute as 'dict'."
|
37
|
+
|
38
|
+
def __get_all_aggregate_method(self, clauses: list[ClauseInfo]) -> str:
|
39
|
+
"""
|
40
|
+
Get the class name of those classes that inherit from 'AggregateFunctionBase' class in order to create a better error message.
|
41
|
+
"""
|
42
|
+
from ormlambda.sql.clause_info import AggregateFunctionBase
|
43
|
+
|
44
|
+
res: set[str] = set()
|
45
|
+
if not isinstance(clauses, tp.Iterable):
|
46
|
+
return clauses.__class__.__name__
|
47
|
+
for clause in clauses:
|
48
|
+
if isinstance(clause, AggregateFunctionBase):
|
49
|
+
res.add(clause.__class__.__name__)
|
50
|
+
return ", ".join(res)
|
@@ -1,12 +1,16 @@
|
|
1
|
+
from __future__ import annotations
|
1
2
|
from abc import abstractmethod, ABC
|
3
|
+
from typing import TYPE_CHECKING
|
4
|
+
|
5
|
+
if TYPE_CHECKING:
|
6
|
+
from ormlambda.dialects import Dialect
|
2
7
|
|
3
8
|
|
4
9
|
class IQuery(ABC):
|
5
10
|
"""Interface to queries that retrieve any element such as select, limit, offset, where, group by, etc..."""
|
6
11
|
|
7
|
-
@property
|
8
12
|
@abstractmethod
|
9
|
-
def query(self) -> str: ...
|
13
|
+
def query(self, dialect: Dialect, **kwargs) -> str: ...
|
10
14
|
|
11
15
|
def __repr__(self) -> str:
|
12
16
|
return f"{IQuery.__name__}: {self.__class__.__name__}"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import Callable, Optional, Type, TYPE_CHECKING
|
3
|
+
from ormlambda import util
|
4
|
+
import importlib
|
5
|
+
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from .interface import Dialect
|
8
|
+
|
9
|
+
|
10
|
+
__all__ = ("mysql", "sqlite")
|
11
|
+
|
12
|
+
|
13
|
+
def _auto_fn(name: str) -> Optional[Callable[[], Type[Dialect]]]:
|
14
|
+
"""default dialect importer.
|
15
|
+
|
16
|
+
plugs into the :class:`.PluginLoader`
|
17
|
+
as a first-hit system.
|
18
|
+
|
19
|
+
"""
|
20
|
+
if "." in name:
|
21
|
+
dialect, driver = name.split(".")
|
22
|
+
else:
|
23
|
+
dialect = name
|
24
|
+
driver = "base"
|
25
|
+
|
26
|
+
try:
|
27
|
+
module = importlib.import_module(f"ormlambda.dialects.{dialect}")
|
28
|
+
|
29
|
+
except ImportError:
|
30
|
+
return None
|
31
|
+
|
32
|
+
if hasattr(module, driver):
|
33
|
+
module = getattr(module, driver)
|
34
|
+
return lambda: module.dialect
|
35
|
+
else:
|
36
|
+
return None
|
37
|
+
|
38
|
+
|
39
|
+
registry = util.PluginLoader("ormlambda.dialects", auto_fn=_auto_fn)
|
@@ -0,0 +1 @@
|
|
1
|
+
from .base import DefaultDialect
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from ormlambda.dialects.interface import Dialect
|
2
|
+
from ormlambda.sql import compiler
|
3
|
+
from typing import Optional, Any
|
4
|
+
from types import ModuleType
|
5
|
+
from ormlambda import BaseRepository
|
6
|
+
|
7
|
+
|
8
|
+
class DefaultDialect(Dialect):
|
9
|
+
"""Default implementation of Dialect"""
|
10
|
+
|
11
|
+
statement_compiler = compiler.SQLCompiler
|
12
|
+
ddl_compiler = compiler.DDLCompiler
|
13
|
+
type_compiler_cls = compiler.GenericTypeCompiler
|
14
|
+
repository_cls = BaseRepository
|
15
|
+
default_paramstyle = "named"
|
16
|
+
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
dbapi: Optional[ModuleType] = None, # type: ignore
|
20
|
+
**kwargs: Any,
|
21
|
+
):
|
22
|
+
self.dbapi = dbapi
|
23
|
+
|
24
|
+
if self.dbapi is not None:
|
25
|
+
self.paramstyle = self.dbapi.paramstyle
|
26
|
+
else:
|
27
|
+
self.paramstyle = self.default_paramstyle
|
28
|
+
self.positional = self.paramstyle in (
|
29
|
+
"qmark",
|
30
|
+
"format",
|
31
|
+
"numeric",
|
32
|
+
"numeric_dollar",
|
33
|
+
)
|
34
|
+
|
35
|
+
tt_callable = self.type_compiler_cls
|
36
|
+
|
37
|
+
self.type_compiler_instance = self.type_compiler = tt_callable(self)
|
38
|
+
|
39
|
+
super().__init__(**kwargs)
|
@@ -0,0 +1 @@
|
|
1
|
+
from .dialect import Dialect # noqa: F401
|
@@ -0,0 +1,78 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
import abc
|
3
|
+
from typing import ClassVar, Optional, Type, TYPE_CHECKING
|
4
|
+
|
5
|
+
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from ormlambda.caster.caster import Caster
|
8
|
+
from ormlambda.repository.interfaces.IRepositoryBase import DBAPIConnection
|
9
|
+
from ormlambda.sql.types import DDLCompiler, SQLCompiler, TypeCompiler
|
10
|
+
from ormlambda import BaseRepository
|
11
|
+
|
12
|
+
|
13
|
+
class Dialect(abc.ABC):
|
14
|
+
"""
|
15
|
+
Abstract base class for all database dialects.
|
16
|
+
"""
|
17
|
+
|
18
|
+
dbapi: Optional[DBAPIConnection]
|
19
|
+
"""A reference to the DBAPI module object itself.
|
20
|
+
|
21
|
+
Ormlambda dialects import DBAPI modules using the classmethod
|
22
|
+
:meth:`.Dialect.import_dbapi`. The rationale is so that any dialect
|
23
|
+
module can be imported and used to generate SQL statements without the
|
24
|
+
need for the actual DBAPI driver to be installed. Only when an
|
25
|
+
:class:`.Engine` is constructed using :func:`.create_engine` does the
|
26
|
+
DBAPI get imported; at that point, the creation process will assign
|
27
|
+
the DBAPI module to this attribute.
|
28
|
+
|
29
|
+
Dialects should therefore implement :meth:`.Dialect.import_dbapi`
|
30
|
+
which will import the necessary module and return it, and then refer
|
31
|
+
to ``self.dbapi`` in dialect code in order to refer to the DBAPI module
|
32
|
+
contents.
|
33
|
+
|
34
|
+
.. versionchanged:: The :attr:`.Dialect.dbapi` attribute is exclusively
|
35
|
+
used as the per-:class:`.Dialect`-instance reference to the DBAPI
|
36
|
+
module. The previous not-fully-documented ``.Dialect.dbapi()``
|
37
|
+
classmethod is deprecated and replaced by :meth:`.Dialect.import_dbapi`.
|
38
|
+
|
39
|
+
"""
|
40
|
+
|
41
|
+
name: ClassVar[str]
|
42
|
+
"""The name of the dialect, e.g. 'sqlite', 'postgresql', etc."""
|
43
|
+
driver: ClassVar[str]
|
44
|
+
"""The driver used by the dialect, e.g. 'sqlite3', 'psycopg2', etc."""
|
45
|
+
|
46
|
+
ddl_compiler: ClassVar[Type[DDLCompiler]]
|
47
|
+
"""The DDL compiler class used by the dialect."""
|
48
|
+
|
49
|
+
statement_compiler: ClassVar[Type[SQLCompiler]]
|
50
|
+
"""The statement compiler class used by the dialect."""
|
51
|
+
|
52
|
+
type_compiler_cls: ClassVar[Type[TypeCompiler]]
|
53
|
+
"""The type compiler class used by the dialect."""
|
54
|
+
|
55
|
+
type_compiler_instance: ClassVar[TypeCompiler]
|
56
|
+
"""The instance of the type compiler class used by the dialect."""
|
57
|
+
|
58
|
+
repository_cls: ClassVar[Type[BaseRepository]]
|
59
|
+
"""The repository class used by the dialect."""
|
60
|
+
|
61
|
+
caster: ClassVar[Type[Caster]]
|
62
|
+
|
63
|
+
@classmethod
|
64
|
+
def get_dialect_cls(cls) -> Type[Dialect]:
|
65
|
+
return cls
|
66
|
+
|
67
|
+
@classmethod
|
68
|
+
@abc.abstractmethod
|
69
|
+
def import_dbapi(cls) -> DBAPIConnection:
|
70
|
+
"""
|
71
|
+
Import the DB API module for the dialect.
|
72
|
+
This method should be implemented by subclasses to import the
|
73
|
+
appropriate DB API module for the dialect.
|
74
|
+
"""
|
75
|
+
...
|
76
|
+
|
77
|
+
def __repr__(self):
|
78
|
+
return f"{Dialect.__name__}: {type(self).__name__}"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
from . import base
|
2
|
+
from . import mysqlconnector
|
3
|
+
|
4
|
+
from .types import ( # noqa: F401
|
5
|
+
NUMERIC,
|
6
|
+
DECIMAL,
|
7
|
+
DOUBLE,
|
8
|
+
REAL,
|
9
|
+
FLOAT,
|
10
|
+
INTEGER,
|
11
|
+
BIGINT,
|
12
|
+
MEDIUMINT,
|
13
|
+
TINYINT,
|
14
|
+
SMALLINT,
|
15
|
+
BIT,
|
16
|
+
TIME,
|
17
|
+
TIMESTAMP,
|
18
|
+
DATETIME,
|
19
|
+
YEAR,
|
20
|
+
TEXT,
|
21
|
+
TINYTEXT,
|
22
|
+
MEDIUMTEXT,
|
23
|
+
LONGTEXT,
|
24
|
+
VARCHAR,
|
25
|
+
CHAR,
|
26
|
+
NVARCHAR,
|
27
|
+
NCHAR,
|
28
|
+
TINYBLOB,
|
29
|
+
MEDIUMBLOB,
|
30
|
+
LONGBLOB,
|
31
|
+
)
|
32
|
+
|
33
|
+
|
34
|
+
from .repository import MySQLRepository # noqa: F401
|
35
|
+
from .caster import MySQLCaster # noqa: F401
|
36
|
+
|
37
|
+
# default dialect
|
38
|
+
base.dialect = dialect = mysqlconnector.dialect
|