reydb 1.2.8__py3-none-any.whl → 1.2.10__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 -0
- reydb/rerror.py +1 -0
- reydb/rorm.py +62 -26
- {reydb-1.2.8.dist-info → reydb-1.2.10.dist-info}/METADATA +1 -1
- {reydb-1.2.8.dist-info → reydb-1.2.10.dist-info}/RECORD +7 -7
- {reydb-1.2.8.dist-info → reydb-1.2.10.dist-info}/WHEEL +0 -0
- {reydb-1.2.8.dist-info → reydb-1.2.10.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -43,6 +43,7 @@ class DatabaseTableConfig(rorm.Model, table=True):
|
|
43
43
|
Database `config` table model.
|
44
44
|
"""
|
45
45
|
|
46
|
+
__name__ = 'config'
|
46
47
|
__comment__ = 'Config data table.'
|
47
48
|
create_time: rorm.Datetime = rorm.Field(field_default=':create_time', not_null=True, index_n=True, comment='Config create time.')
|
48
49
|
update_time: rorm.Datetime = rorm.Field(field_default=':update_time', index_n=True, comment='Config update time.')
|
reydb/rerror.py
CHANGED
@@ -37,6 +37,7 @@ class DatabaseTableError(rorm.Model, table=True):
|
|
37
37
|
Database `error` table model.
|
38
38
|
"""
|
39
39
|
|
40
|
+
__name__ = 'error'
|
40
41
|
__comment__ = 'Error log table.'
|
41
42
|
create_time: rorm.Datetime = rorm.Field(field_default=':create_time', not_null=True, index_n=True, comment='Record create time.')
|
42
43
|
id: int = rorm.Field(rorm.types_mysql.INTEGER(unsigned=True), key_auto=True, comment='ID.')
|
reydb/rorm.py
CHANGED
@@ -27,7 +27,7 @@ from sqlmodel.ext.asyncio.session import AsyncSession
|
|
27
27
|
from sqlmodel.main import SQLModelMetaclass, FieldInfo, default_registry
|
28
28
|
from sqlmodel.sql._expression_select_cls import SelectOfScalar as Select
|
29
29
|
from datetime import datetime, date, time, timedelta
|
30
|
-
from reykit.rbase import CallableT, throw, is_instance
|
30
|
+
from reykit.rbase import CallableT, Null, throw, is_instance
|
31
31
|
|
32
32
|
from . import rdb
|
33
33
|
from .rbase import (
|
@@ -190,7 +190,7 @@ class DatabaseORMModelField(DatabaseORMBase, FieldInfo):
|
|
190
190
|
field_type: TypeEngine | None = None,
|
191
191
|
*,
|
192
192
|
field_default: str | Literal[':time'] | Literal[':create_time'] | Literal[':update_time'] = None,
|
193
|
-
arg_default: Any | Callable[[], Any] |
|
193
|
+
arg_default: Any | Callable[[], Any] | Null.Type = Null,
|
194
194
|
arg_update: Any | Callable[[], Any] = None,
|
195
195
|
name: str | None = None,
|
196
196
|
key: bool = False,
|
@@ -329,14 +329,14 @@ class DatabaseORMModelField(DatabaseORMBase, FieldInfo):
|
|
329
329
|
kwargs['sa_column_kwargs']['server_default'] = field_default
|
330
330
|
|
331
331
|
## Argument default.
|
332
|
-
arg_default = kwargs.pop('arg_default',
|
333
|
-
if arg_default
|
334
|
-
if
|
335
|
-
kwargs['
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
kwargs['default'] =
|
332
|
+
arg_default = kwargs.pop('arg_default', Null)
|
333
|
+
if arg_default == Null:
|
334
|
+
if kwargs['nullable']:
|
335
|
+
kwargs['default'] = None
|
336
|
+
elif callable(arg_default):
|
337
|
+
kwargs['default_factory'] = arg_default
|
338
|
+
else:
|
339
|
+
kwargs['default'] = arg_default
|
340
340
|
|
341
341
|
## Argument update.
|
342
342
|
if 'arg_update' in kwargs:
|
@@ -641,9 +641,9 @@ class DatabaseORMSessionSuper(
|
|
641
641
|
# Build.
|
642
642
|
match self:
|
643
643
|
case DatabaseORMSession():
|
644
|
-
select = DatabaseORMStatementSelect
|
644
|
+
select = DatabaseORMStatementSelect(self, model)
|
645
645
|
case DatabaseORMSessionAsync():
|
646
|
-
select = DatabaseORMStatementSelectAsync
|
646
|
+
select = DatabaseORMStatementSelectAsync(self, model)
|
647
647
|
|
648
648
|
return select
|
649
649
|
|
@@ -668,9 +668,9 @@ class DatabaseORMSessionSuper(
|
|
668
668
|
# Build.
|
669
669
|
match self:
|
670
670
|
case DatabaseORMSession():
|
671
|
-
insert = DatabaseORMStatementInsert
|
671
|
+
insert = DatabaseORMStatementInsert(self, model)
|
672
672
|
case DatabaseORMSessionAsync():
|
673
|
-
insert = DatabaseORMStatementInsertAsync
|
673
|
+
insert = DatabaseORMStatementInsertAsync(self, model)
|
674
674
|
|
675
675
|
return insert
|
676
676
|
|
@@ -695,9 +695,9 @@ class DatabaseORMSessionSuper(
|
|
695
695
|
# Build.
|
696
696
|
match self:
|
697
697
|
case DatabaseORMSession():
|
698
|
-
update = DatabaseORMStatementUpdate
|
698
|
+
update = DatabaseORMStatementUpdate(self, model)
|
699
699
|
case DatabaseORMSessionAsync():
|
700
|
-
update = DatabaseORMStatementUpdateAsync
|
700
|
+
update = DatabaseORMStatementUpdateAsync(self, model)
|
701
701
|
|
702
702
|
return update
|
703
703
|
|
@@ -722,9 +722,9 @@ class DatabaseORMSessionSuper(
|
|
722
722
|
# Build.
|
723
723
|
match self:
|
724
724
|
case DatabaseORMSession():
|
725
|
-
delete = DatabaseORMStatementDelete
|
725
|
+
delete = DatabaseORMStatementDelete(self, model)
|
726
726
|
case DatabaseORMSessionAsync():
|
727
|
-
delete = DatabaseORMStatementDeleteAsync
|
727
|
+
delete = DatabaseORMStatementDeleteAsync(self, model)
|
728
728
|
|
729
729
|
return delete
|
730
730
|
|
@@ -1095,6 +1095,12 @@ class DatabaseORMSession(
|
|
1095
1095
|
self.sess.expire(model)
|
1096
1096
|
|
1097
1097
|
|
1098
|
+
@overload
|
1099
|
+
def select(self, model: Type[DatabaseORMModelT] | DatabaseORMModelT) -> 'DatabaseORMStatementSelect[list[DatabaseORMModelT]]': ...
|
1100
|
+
|
1101
|
+
select = DatabaseORMSessionSuper.select
|
1102
|
+
|
1103
|
+
|
1098
1104
|
class DatabaseORMSessionAsync(
|
1099
1105
|
DatabaseORMSessionSuper[
|
1100
1106
|
DatabaseORMAsync,
|
@@ -1463,6 +1469,12 @@ class DatabaseORMSessionAsync(
|
|
1463
1469
|
self.sess.expire(model)
|
1464
1470
|
|
1465
1471
|
|
1472
|
+
@overload
|
1473
|
+
def select(self, model: Type[DatabaseORMModelT] | DatabaseORMModelT) -> 'DatabaseORMStatementSelectAsync[list[DatabaseORMModelT]]': ...
|
1474
|
+
|
1475
|
+
select = DatabaseORMSessionSuper.select
|
1476
|
+
|
1477
|
+
|
1466
1478
|
class DatabaseORMStatementSuper(DatabaseORMBase, Generic[DatabaseORMSessionT]):
|
1467
1479
|
"""
|
1468
1480
|
Database ORM statement super type.
|
@@ -1516,6 +1528,12 @@ class DatabaseORMStatement(DatabaseORMStatementSuper[DatabaseORMSession], Generi
|
|
1516
1528
|
|
1517
1529
|
# Automatic commit.
|
1518
1530
|
if self.sess.autocommit:
|
1531
|
+
|
1532
|
+
## Select.
|
1533
|
+
if isinstance(self, Select):
|
1534
|
+
for model in result:
|
1535
|
+
self.sess.sess.expunge(model)
|
1536
|
+
|
1519
1537
|
self.sess.commit()
|
1520
1538
|
self.sess.close()
|
1521
1539
|
|
@@ -1547,6 +1565,12 @@ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsyn
|
|
1547
1565
|
|
1548
1566
|
# Automatic commit.
|
1549
1567
|
if self.sess.autocommit:
|
1568
|
+
|
1569
|
+
## Select.
|
1570
|
+
if isinstance(self, Select):
|
1571
|
+
for model in result:
|
1572
|
+
self.sess.sess.expunge(model)
|
1573
|
+
|
1550
1574
|
await self.sess.commit()
|
1551
1575
|
await self.sess.close()
|
1552
1576
|
await self.sess.orm.db.dispose()
|
@@ -1554,7 +1578,7 @@ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsyn
|
|
1554
1578
|
return result
|
1555
1579
|
|
1556
1580
|
|
1557
|
-
class DatabaseORMStatementSelect(DatabaseORMStatement
|
1581
|
+
class DatabaseORMStatementSelect(DatabaseORMStatement, Select, Generic[DatabaseORMStatementReturn]):
|
1558
1582
|
"""
|
1559
1583
|
Database ORM `select` statement type.
|
1560
1584
|
|
@@ -1566,7 +1590,13 @@ class DatabaseORMStatementSelect(DatabaseORMStatement[list[DatabaseORMModelT]],
|
|
1566
1590
|
inherit_cache: Final = True
|
1567
1591
|
|
1568
1592
|
|
1569
|
-
|
1593
|
+
@overload
|
1594
|
+
def execute(self) -> DatabaseORMStatementReturn: ...
|
1595
|
+
|
1596
|
+
execute = DatabaseORMStatement.execute
|
1597
|
+
|
1598
|
+
|
1599
|
+
class DatabaseORMStatementInsert(DatabaseORMStatement[None], Insert):
|
1570
1600
|
"""
|
1571
1601
|
Database ORM `insert` statement type.
|
1572
1602
|
|
@@ -1578,7 +1608,7 @@ class DatabaseORMStatementInsert(DatabaseORMStatement[None], Insert, Generic[Dat
|
|
1578
1608
|
inherit_cache: Final = True
|
1579
1609
|
|
1580
1610
|
|
1581
|
-
class DatabaseORMStatementUpdate(DatabaseORMStatement[None], Update
|
1611
|
+
class DatabaseORMStatementUpdate(DatabaseORMStatement[None], Update):
|
1582
1612
|
"""
|
1583
1613
|
Database ORM `update` statement type.
|
1584
1614
|
|
@@ -1590,7 +1620,7 @@ class DatabaseORMStatementUpdate(DatabaseORMStatement[None], Update, Generic[Dat
|
|
1590
1620
|
inherit_cache: Final = True
|
1591
1621
|
|
1592
1622
|
|
1593
|
-
class DatabaseORMStatementDelete(DatabaseORMStatement[None], Delete
|
1623
|
+
class DatabaseORMStatementDelete(DatabaseORMStatement[None], Delete):
|
1594
1624
|
"""
|
1595
1625
|
Database ORM `delete` statement type.
|
1596
1626
|
|
@@ -1602,7 +1632,7 @@ class DatabaseORMStatementDelete(DatabaseORMStatement[None], Delete, Generic[Dat
|
|
1602
1632
|
inherit_cache: Final = True
|
1603
1633
|
|
1604
1634
|
|
1605
|
-
class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync
|
1635
|
+
class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync, Select):
|
1606
1636
|
"""
|
1607
1637
|
Asynchronous database ORM `select` statement type.
|
1608
1638
|
|
@@ -1614,7 +1644,13 @@ class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync[list[DatabaseORM
|
|
1614
1644
|
inherit_cache: Final = True
|
1615
1645
|
|
1616
1646
|
|
1617
|
-
|
1647
|
+
@overload
|
1648
|
+
async def execute(self) -> DatabaseORMStatementReturn: ...
|
1649
|
+
|
1650
|
+
execute = DatabaseORMStatementAsync.execute
|
1651
|
+
|
1652
|
+
|
1653
|
+
class DatabaseORMStatementInsertAsync(DatabaseORMStatementAsync[None], Insert):
|
1618
1654
|
"""
|
1619
1655
|
Asynchronous database ORM `insert` statement type.
|
1620
1656
|
|
@@ -1626,7 +1662,7 @@ class DatabaseORMStatementInsertAsync(DatabaseORMStatementAsync[None], Insert, G
|
|
1626
1662
|
inherit_cache: Final = True
|
1627
1663
|
|
1628
1664
|
|
1629
|
-
class DatabaseORMStatementUpdateAsync(DatabaseORMStatementAsync[None], Update
|
1665
|
+
class DatabaseORMStatementUpdateAsync(DatabaseORMStatementAsync[None], Update):
|
1630
1666
|
"""
|
1631
1667
|
Asynchronous database ORM `update` statement type.
|
1632
1668
|
|
@@ -1638,7 +1674,7 @@ class DatabaseORMStatementUpdateAsync(DatabaseORMStatementAsync[None], Update, G
|
|
1638
1674
|
inherit_cache: Final = True
|
1639
1675
|
|
1640
1676
|
|
1641
|
-
class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync[None], Delete
|
1677
|
+
class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync[None], Delete):
|
1642
1678
|
"""
|
1643
1679
|
Asynchronous database ORM `delete` statement type.
|
1644
1680
|
|
@@ -2,14 +2,14 @@ reydb/__init__.py,sha256=4mnlkfJfkBfxBpCotVUJ86f4AnT8plqlFbGiH3vZ4PM,550
|
|
2
2
|
reydb/rall.py,sha256=IxSPGh77xz7ndDC7J8kZ_66Gq_xTAztGtnELUku1Ouw,364
|
3
3
|
reydb/rbase.py,sha256=vx37yV6LlWP89nWAfYyOf0Xm3N_e9eB8z5Mxe-aTEo4,8248
|
4
4
|
reydb/rbuild.py,sha256=0jI0MNl-BIhQtuT_-GeXBPTjG76k9EE3wwEQXGhTJyc,80938
|
5
|
-
reydb/rconfig.py,sha256=
|
5
|
+
reydb/rconfig.py,sha256=xoujEyZzkB9UwG8lkZBDBmeUOEo8Sr1Oktveos-EWWc,19168
|
6
6
|
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
7
|
reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
|
8
|
-
reydb/rerror.py,sha256=
|
8
|
+
reydb/rerror.py,sha256=uwVuolRp-PmXXUZIA_Qd2S6NSOm1S0vDJvehX6l__U8,14888
|
9
9
|
reydb/rexec.py,sha256=djHx311c6mr1IjzNLqnGe-4yr3qNmYGUy4pHQA3WElQ,53042
|
10
10
|
reydb/rinfo.py,sha256=LjrqTA7JJbWJsjXwV-zKpbE1htv-whg6239hoQj4yIU,18151
|
11
|
-
reydb/rorm.py,sha256=
|
12
|
-
reydb-1.2.
|
13
|
-
reydb-1.2.
|
14
|
-
reydb-1.2.
|
15
|
-
reydb-1.2.
|
11
|
+
reydb/rorm.py,sha256=kVe2PtF7pYy6zws8c9qBDYkY2ZmGoiHcio1wN_3LmEk,44244
|
12
|
+
reydb-1.2.10.dist-info/METADATA,sha256=Egt0VRbjmWTbVl-MwSs7qNrLDKGGvRMYYNJ3xtrUmQ4,1622
|
13
|
+
reydb-1.2.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
reydb-1.2.10.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
+
reydb-1.2.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|