reydb 1.3.6__py3-none-any.whl → 1.3.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reydb/rconfig.py +1 -1
- reydb/rerror.py +1 -1
- reydb/rorm.py +56 -5
- {reydb-1.3.6.dist-info → reydb-1.3.7.dist-info}/METADATA +1 -1
- {reydb-1.3.6.dist-info → reydb-1.3.7.dist-info}/RECORD +7 -7
- {reydb-1.3.6.dist-info → reydb-1.3.7.dist-info}/WHEEL +0 -0
- {reydb-1.3.6.dist-info → reydb-1.3.7.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -38,7 +38,7 @@ ConfigValueT = TypeVar('T', bound=ConfigValue) # Any.
|
|
38
38
|
DatabaseEngineT = TypeVar('DatabaseEngineT', 'rengine.DatabaseEngine', 'rengine.DatabaseEngineAsync')
|
39
39
|
|
40
40
|
|
41
|
-
class DatabaseORMTableConfig(rorm.
|
41
|
+
class DatabaseORMTableConfig(rorm.Table):
|
42
42
|
"""
|
43
43
|
Database `config` table ORM model.
|
44
44
|
"""
|
reydb/rerror.py
CHANGED
reydb/rorm.py
CHANGED
@@ -29,7 +29,7 @@ from sqlalchemy.sql._typing import _ColumnExpressionArgument
|
|
29
29
|
from sqlalchemy.ext.asyncio import AsyncSessionTransaction
|
30
30
|
from sqlalchemy.dialects.mysql import Insert, types as types_mysql
|
31
31
|
from sqlalchemy.exc import SAWarning
|
32
|
-
from sqlmodel import SQLModel, Session, Table
|
32
|
+
from sqlmodel import SQLModel, Session, Table as STable
|
33
33
|
from sqlmodel.main import SQLModelMetaclass, FieldInfo, default_registry
|
34
34
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
35
35
|
from sqlmodel.sql._expression_select_cls import SelectOfScalar as Select
|
@@ -57,6 +57,8 @@ __all__ = (
|
|
57
57
|
'DatabaseORMModelField',
|
58
58
|
'DatabaseORMModel',
|
59
59
|
'DatabaseORMModelMethod',
|
60
|
+
'DatabaseORMModelTableMeta',
|
61
|
+
'DatabaseORMModelTable',
|
60
62
|
'DatabaseORMSuper',
|
61
63
|
'DatabaseORM',
|
62
64
|
'DatabaseORMAsync',
|
@@ -99,7 +101,7 @@ class DatabaseORMBase(DatabaseBase):
|
|
99
101
|
|
100
102
|
class DatabaseORMModelMeta(DatabaseORMBase, SQLModelMetaclass):
|
101
103
|
"""
|
102
|
-
Database ORM
|
104
|
+
Database ORM meta type.
|
103
105
|
"""
|
104
106
|
|
105
107
|
|
@@ -181,7 +183,7 @@ class DatabaseORMModelMeta(DatabaseORMBase, SQLModelMetaclass):
|
|
181
183
|
'__annotations__' in attrs
|
182
184
|
and hasattr(cls, '__table__')
|
183
185
|
):
|
184
|
-
table:
|
186
|
+
table: STable = cls.__table__
|
185
187
|
for index in table.indexes:
|
186
188
|
index_name = '_'.join(
|
187
189
|
column.key
|
@@ -383,7 +385,7 @@ class DatabaseORMModel(DatabaseORMBase, SQLModel, metaclass=model_metaclass):
|
|
383
385
|
|
384
386
|
|
385
387
|
@classmethod
|
386
|
-
def _get_table(cls_or_self) ->
|
388
|
+
def _get_table(cls_or_self) -> STable:
|
387
389
|
"""
|
388
390
|
Return mapping database table instance.
|
389
391
|
|
@@ -393,7 +395,7 @@ class DatabaseORMModel(DatabaseORMBase, SQLModel, metaclass=model_metaclass):
|
|
393
395
|
"""
|
394
396
|
|
395
397
|
# Get.
|
396
|
-
table:
|
398
|
+
table: STable = cls_or_self.__table__
|
397
399
|
|
398
400
|
return table
|
399
401
|
|
@@ -511,6 +513,54 @@ class DatabaseORMModelMethod(DatabaseORMBase):
|
|
511
513
|
return instance
|
512
514
|
|
513
515
|
|
516
|
+
class DatabaseORMModelTableMeta(DatabaseORMModelMeta):
|
517
|
+
"""
|
518
|
+
Database ORM table meta type.
|
519
|
+
"""
|
520
|
+
|
521
|
+
|
522
|
+
def __new__(
|
523
|
+
cls,
|
524
|
+
name: str,
|
525
|
+
bases: tuple[Type],
|
526
|
+
attrs: dict[str, Any],
|
527
|
+
**kwargs: Any
|
528
|
+
) -> Type:
|
529
|
+
"""
|
530
|
+
Create type.
|
531
|
+
|
532
|
+
Parameters
|
533
|
+
----------
|
534
|
+
name : Type name.
|
535
|
+
bases : Type base types.
|
536
|
+
attrs : Type attributes and methods dictionary.
|
537
|
+
kwargs : Type other key arguments.
|
538
|
+
"""
|
539
|
+
|
540
|
+
# Parameter.
|
541
|
+
if '__annotations__' in attrs:
|
542
|
+
kwargs['table'] = True
|
543
|
+
|
544
|
+
# Super.
|
545
|
+
new_cls = super().__new__(cls, name, bases, attrs, **kwargs)
|
546
|
+
|
547
|
+
return new_cls
|
548
|
+
|
549
|
+
|
550
|
+
class DatabaseORMModelTable(DatabaseORMModel, metaclass=DatabaseORMModelTableMeta):
|
551
|
+
"""
|
552
|
+
Database ORM model table type.
|
553
|
+
Based on `sqlalchemy` and `sqlmodel` package.
|
554
|
+
|
555
|
+
Examples
|
556
|
+
--------
|
557
|
+
>>> class Foo(DatabaseORMModelTable):
|
558
|
+
... __name__ = 'Table name, default is class name.'
|
559
|
+
... __comment__ = 'Table comment.'
|
560
|
+
... ...
|
561
|
+
"""
|
562
|
+
|
563
|
+
|
514
564
|
class DatabaseORMSuper(DatabaseORMBase, Generic[DatabaseEngineT, DatabaseORMSessionT]):
|
515
565
|
"""
|
516
566
|
Database ORM super type.
|
@@ -1956,6 +2006,7 @@ metadata = default_registry.metadata
|
|
1956
2006
|
|
1957
2007
|
## Database ORM model type.
|
1958
2008
|
Model = DatabaseORMModel
|
2009
|
+
Table = DatabaseORMModelTable
|
1959
2010
|
|
1960
2011
|
## Database ORM model field type.
|
1961
2012
|
Field = DatabaseORMModelField
|
@@ -2,15 +2,15 @@ reydb/__init__.py,sha256=BnJsTzcwqeQ8-5Boqsehgcpc1eSDkv41v0kdb10gAgM,643
|
|
2
2
|
reydb/rall.py,sha256=5GI0yuwF72XypNZ1DYIxKizo2Z5pR88Uv0nUpHKYhCk,379
|
3
3
|
reydb/rbase.py,sha256=S3ip2PxvLn2Spgv5G_xd7xgC-U4wjEoAZ7Up25ZQvLk,8223
|
4
4
|
reydb/rbuild.py,sha256=6ZkU3LGkIk04KTPtd8fgTC4pX93p1tvbOhZWWEi-v5A,40846
|
5
|
-
reydb/rconfig.py,sha256=
|
5
|
+
reydb/rconfig.py,sha256=uMzmOzs4ZJVmSmvH4X4Kj6TA2JjRUZHfyn6enGMS0Tc,18149
|
6
6
|
reydb/rconn.py,sha256=ujyTAqR7FLr758EHDr04e0MTHDGDQEF_-YkfkYc8XRI,6986
|
7
7
|
reydb/rdb.py,sha256=IhZLyXWZ5tiTWe2oq-nEkzTJW2ClvgT2-37OK-eOTXU,6063
|
8
8
|
reydb/rengine.py,sha256=4tEIWxhtQ220_DZYb180hXhUwcxKGnPcv0yLaH1l0X4,17048
|
9
|
-
reydb/rerror.py,sha256=
|
9
|
+
reydb/rerror.py,sha256=K681wWDpFrsTV7puoO1LIBLr0E-yqFxFn09k6kKCYHI,14779
|
10
10
|
reydb/rexec.py,sha256=bVPT8kueKnK5HWLtYklE5Vgc4crL7QxBEE3S0MQgRB4,52647
|
11
11
|
reydb/rinfo.py,sha256=c5otyOikGMVnLFhPbtlgmnFBRR3NMP7xcmMW-LQdaQk,18314
|
12
|
-
reydb/rorm.py,sha256=
|
13
|
-
reydb-1.3.
|
14
|
-
reydb-1.3.
|
15
|
-
reydb-1.3.
|
16
|
-
reydb-1.3.
|
12
|
+
reydb/rorm.py,sha256=yoK0DItEZvHHyjWpQwUES0VNRr1jvgcfKYoqf5CmBfU,51091
|
13
|
+
reydb-1.3.7.dist-info/METADATA,sha256=o1nWPZWLozuaIwgS15QG8rzwCbtq0RcGrhd-ljtdQEM,1653
|
14
|
+
reydb-1.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
reydb-1.3.7.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
16
|
+
reydb-1.3.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|