reydb 1.2.10__py3-none-any.whl → 1.2.12__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 +7 -5
- reydb/rexec.py +0 -1
- reydb/rorm.py +50 -12
- {reydb-1.2.10.dist-info → reydb-1.2.12.dist-info}/METADATA +1 -1
- {reydb-1.2.10.dist-info → reydb-1.2.12.dist-info}/RECORD +7 -7
- {reydb-1.2.10.dist-info → reydb-1.2.12.dist-info}/WHEEL +0 -0
- {reydb-1.2.10.dist-info → reydb-1.2.12.dist-info}/licenses/LICENSE +0 -0
reydb/rconfig.py
CHANGED
@@ -170,11 +170,13 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
|
|
170
170
|
"""
|
171
171
|
|
172
172
|
# Get.
|
173
|
-
result = self.db.
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
)
|
173
|
+
result = self.db.orm.select(
|
174
|
+
DatabaseTableConfig
|
175
|
+
).fields(
|
176
|
+
DatabaseTableConfig.key, DatabaseTableConfig.value, DatabaseTableConfig.type, DatabaseTableConfig.note
|
177
|
+
).order_by(
|
178
|
+
rorm.funcs.IFNULL(DatabaseTableConfig.update_time, DatabaseTableConfig.create_time).desc()
|
179
|
+
).execute()
|
178
180
|
|
179
181
|
# Convert.
|
180
182
|
global_dict = {'datetime': Datetime}
|
reydb/rexec.py
CHANGED
@@ -17,7 +17,6 @@ from reykit.rbase import throw, get_first_notnone
|
|
17
17
|
from reykit.rdata import FunctionGenerator
|
18
18
|
from reykit.rmonkey import monkey_sqlalchemy_result_more_fetch, monkey_sqlalchemy_row_index_field
|
19
19
|
from reykit.rrand import randn
|
20
|
-
from reykit.rre import findall
|
21
20
|
from reykit.rstdout import echo as recho
|
22
21
|
from reykit.rtable import TableData, Table
|
23
22
|
from reykit.rtime import TimeMark, time_to
|
reydb/rorm.py
CHANGED
@@ -9,22 +9,22 @@
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
|
12
|
-
from typing import Self, Any, Type, Literal, TypeVar, Generic, Final, overload
|
12
|
+
from typing import Self, Any, Type, Literal, TypeVar, Generic, Final, NoReturn, overload
|
13
13
|
from collections.abc import Callable
|
14
14
|
from functools import wraps as functools_wraps
|
15
15
|
from inspect import iscoroutinefunction as inspect_iscoroutinefunction
|
16
16
|
from pydantic import ConfigDict, field_validator as pydantic_field_validator, model_validator as pydantic_model_validator
|
17
|
-
from sqlalchemy import text as sqlalchemy_text
|
18
|
-
from sqlalchemy.orm import SessionTransaction
|
17
|
+
from sqlalchemy import types, text as sqlalchemy_text
|
18
|
+
from sqlalchemy.orm import SessionTransaction, load_only
|
19
|
+
from sqlalchemy.orm.strategy_options import _AttrType
|
20
|
+
from sqlalchemy.sql import func as sqlalchemy_func
|
21
|
+
from sqlalchemy.sql.dml import Insert, Update, Delete
|
22
|
+
from sqlalchemy.sql.sqltypes import TypeEngine
|
19
23
|
from sqlalchemy.ext.asyncio import AsyncSessionTransaction
|
20
|
-
from sqlalchemy import types
|
21
24
|
from sqlalchemy.dialects.mysql import types as types_mysql
|
22
|
-
from sqlalchemy.sql.sqltypes import TypeEngine
|
23
|
-
from sqlalchemy.sql.dml import Insert, Update, Delete
|
24
|
-
from sqlalchemy.sql import func as sqlalchemy_func
|
25
25
|
from sqlmodel import SQLModel, Session, Table
|
26
|
-
from sqlmodel.ext.asyncio.session import AsyncSession
|
27
26
|
from sqlmodel.main import SQLModelMetaclass, FieldInfo, default_registry
|
27
|
+
from sqlmodel.ext.asyncio.session import AsyncSession
|
28
28
|
from sqlmodel.sql._expression_select_cls import SelectOfScalar as Select
|
29
29
|
from datetime import datetime, date, time, timedelta
|
30
30
|
from reykit.rbase import CallableT, Null, throw, is_instance
|
@@ -1503,6 +1503,10 @@ class DatabaseORMStatementSuper(DatabaseORMBase, Generic[DatabaseORMSessionT]):
|
|
1503
1503
|
self.model = model
|
1504
1504
|
|
1505
1505
|
|
1506
|
+
@overload
|
1507
|
+
def with_only_columns(self) -> NoReturn: ...
|
1508
|
+
|
1509
|
+
|
1506
1510
|
class DatabaseORMStatement(DatabaseORMStatementSuper[DatabaseORMSession], Generic[DatabaseORMStatementReturn]):
|
1507
1511
|
"""
|
1508
1512
|
Database ORM statement type.
|
@@ -1532,7 +1536,8 @@ class DatabaseORMStatement(DatabaseORMStatementSuper[DatabaseORMSession], Generi
|
|
1532
1536
|
## Select.
|
1533
1537
|
if isinstance(self, Select):
|
1534
1538
|
for model in result:
|
1535
|
-
|
1539
|
+
if isinstance(model, DatabaseORMModel):
|
1540
|
+
self.sess.sess.expunge(model)
|
1536
1541
|
|
1537
1542
|
self.sess.commit()
|
1538
1543
|
self.sess.close()
|
@@ -1569,7 +1574,8 @@ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsyn
|
|
1569
1574
|
## Select.
|
1570
1575
|
if isinstance(self, Select):
|
1571
1576
|
for model in result:
|
1572
|
-
|
1577
|
+
if isinstance(model, DatabaseORMModel):
|
1578
|
+
self.sess.sess.expunge(model)
|
1573
1579
|
|
1574
1580
|
await self.sess.commit()
|
1575
1581
|
await self.sess.close()
|
@@ -1578,7 +1584,39 @@ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsyn
|
|
1578
1584
|
return result
|
1579
1585
|
|
1580
1586
|
|
1581
|
-
class
|
1587
|
+
class DatabaseORMStatementSelectSuper(DatabaseORMStatementSuper, Select):
|
1588
|
+
"""
|
1589
|
+
Database ORM `select` statement type.
|
1590
|
+
|
1591
|
+
Attributes
|
1592
|
+
----------
|
1593
|
+
inherit_cache : Compatible `Select` type.
|
1594
|
+
"""
|
1595
|
+
|
1596
|
+
inherit_cache: Final = True
|
1597
|
+
|
1598
|
+
|
1599
|
+
def fields(self, *field: _AttrType) -> Self:
|
1600
|
+
"""
|
1601
|
+
Replace select fiedls.
|
1602
|
+
|
1603
|
+
Parameters
|
1604
|
+
----------
|
1605
|
+
field : Field set.
|
1606
|
+
|
1607
|
+
Returns
|
1608
|
+
-------
|
1609
|
+
Set self.
|
1610
|
+
"""
|
1611
|
+
|
1612
|
+
# Set.
|
1613
|
+
set = load_only(*field)
|
1614
|
+
select = self.options(set)
|
1615
|
+
|
1616
|
+
return select
|
1617
|
+
|
1618
|
+
|
1619
|
+
class DatabaseORMStatementSelect(DatabaseORMStatement, DatabaseORMStatementSelectSuper, Generic[DatabaseORMStatementReturn]):
|
1582
1620
|
"""
|
1583
1621
|
Database ORM `select` statement type.
|
1584
1622
|
|
@@ -1632,7 +1670,7 @@ class DatabaseORMStatementDelete(DatabaseORMStatement[None], Delete):
|
|
1632
1670
|
inherit_cache: Final = True
|
1633
1671
|
|
1634
1672
|
|
1635
|
-
class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync,
|
1673
|
+
class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync, DatabaseORMStatementSelectSuper, Generic[DatabaseORMStatementReturn]):
|
1636
1674
|
"""
|
1637
1675
|
Asynchronous database ORM `select` statement type.
|
1638
1676
|
|
@@ -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=9tMDKivwju08kIAl7CahOMdvmuuO1Q_4I_JhMPWUbvg,19319
|
6
6
|
reydb/rconn.py,sha256=guRaR8N6RuzZzujwaeq7HhKWTizF9SrUBqEAFjfjpoo,6909
|
7
7
|
reydb/rdb.py,sha256=syyqZbEu92NbCj9O6_T6iAv7E46CyfQOC4T8qtPfHNs,14364
|
8
8
|
reydb/rerror.py,sha256=uwVuolRp-PmXXUZIA_Qd2S6NSOm1S0vDJvehX6l__U8,14888
|
9
|
-
reydb/rexec.py,sha256=
|
9
|
+
reydb/rexec.py,sha256=u6ZU5dljUktICvJFhUIzg3U7ME9fhICL3NyqZugz5H4,53010
|
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=VkldNaXpTz-lGhrz-8CDuBWxnDY9uBbZphsP1Jpe84E,45188
|
12
|
+
reydb-1.2.12.dist-info/METADATA,sha256=hE9zm7viJ_8CcZPI4NTZfGWqMn9AHQvvFtpmHEzCAbA,1622
|
13
|
+
reydb-1.2.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
reydb-1.2.12.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
|
15
|
+
reydb-1.2.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|