reydb 1.2.11__py3-none-any.whl → 1.2.13__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 CHANGED
@@ -170,21 +170,25 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
170
170
  """
171
171
 
172
172
  # Get.
173
- result = self.db.execute.select(
174
- self.db_names['config'],
175
- ['key', 'value', 'type', 'note'],
176
- order='IFNULL(`update_time`, `create_time`) DESC'
173
+ models = (
174
+ self.db.orm.select(DatabaseTableConfig)
175
+ .fields(DatabaseTableConfig.key, DatabaseTableConfig.value, DatabaseTableConfig.type, DatabaseTableConfig.note)
176
+ .order_by(
177
+ rorm.funcs.IFNULL(DatabaseTableConfig.update_time, DatabaseTableConfig.create_time)
178
+ .desc()
179
+ )
180
+ .execute()
177
181
  )
178
182
 
179
183
  # Convert.
180
184
  global_dict = {'datetime': Datetime}
181
185
  result = [
182
186
  {
183
- 'key': row['key'],
184
- 'value': eval(row['value'], global_dict),
185
- 'note': row['note']
187
+ 'key': model.key,
188
+ 'value': eval(model.value, global_dict),
189
+ 'note': model.note
186
190
  }
187
- for row in result
191
+ for model in models
188
192
  ]
189
193
 
190
194
  return result
@@ -205,18 +209,10 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
205
209
  """
206
210
 
207
211
  # Get.
208
- where = '`key` = :key'
209
- result = self.db.execute.select(
210
- self.db_names['config'],
211
- '`value`',
212
- where,
213
- limit=1,
214
- key=key
215
- )
216
- value = result.scalar()
212
+ model = self.db.orm.get(DatabaseTableConfig, key)
217
213
 
218
214
  # Default.
219
- if value is None:
215
+ if model.value is None:
220
216
  value = default
221
217
  else:
222
218
  global_dict = {'datetime': Datetime}
@@ -252,10 +248,11 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
252
248
  'type': type(default).__name__,
253
249
  'note': default_note
254
250
  }
255
- result = self.db.execute.insert(
256
- self.db_names['config'],
257
- data,
258
- 'ignore'
251
+ result = (
252
+ self.db.orm.insert(DatabaseTableConfig)
253
+ .values(data)
254
+ .ignore()
255
+ .execute()
259
256
  )
260
257
 
261
258
  # Get.
@@ -293,10 +290,11 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
293
290
  row['type'] = type(row['value']).__name__
294
291
 
295
292
  # Update.
296
- self.db.execute.insert(
297
- self.db_names['config'],
298
- data,
299
- 'update'
293
+ (
294
+ self.db.orm.insert(DatabaseTableConfig)
295
+ .values(data)
296
+ .update()
297
+ .execute()
300
298
  )
301
299
 
302
300
 
@@ -311,16 +309,16 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
311
309
 
312
310
  # Remove.
313
311
  if type(key) == str:
314
- where = '`key` = :key'
312
+ where = DatabaseTableConfig == key
315
313
  limit = 1
316
314
  else:
317
- where = '`key` in :key'
315
+ where = DatabaseTableConfig in key
318
316
  limit = None
319
- result = self.db.execute.delete(
320
- self.db_names['base.config'],
321
- where,
322
- limit=limit,
323
- key=key
317
+ result = (
318
+ self.db.orm.delete(DatabaseTableConfig)
319
+ .where(where)
320
+ .limit(limit)
321
+ .execute()
324
322
  )
325
323
 
326
324
  # Check.
@@ -338,17 +336,17 @@ class DatabaseConfig(DatabaseConfigSuper['rdb.Database']):
338
336
  """
339
337
 
340
338
  # Get.
341
- result = self.db.execute.select(
342
- self.db_names['config'],
343
- ['key', 'value']
339
+ models = (
340
+ self.db.orm.select(DatabaseTableConfig)
341
+ .fields('key', 'value')
342
+ .execute()
344
343
  )
345
344
 
346
345
  # Convert.
347
346
  global_dict = {'datetime': Datetime}
348
- result = result.to_dict('key', 'value')
349
347
  result = {
350
- key: eval(value, global_dict)
351
- for key, value in result.items()
348
+ model.key: eval(model.value, global_dict)
349
+ for model in models
352
350
  }
353
351
 
354
352
  return result
@@ -642,7 +640,7 @@ class DatabaseConfigAsync(DatabaseConfigSuper['rdb.DatabaseAsync']):
642
640
  where = '`key` in :key'
643
641
  limit = None
644
642
  result = await self.db.execute.delete(
645
- self.db_names['base.config'],
643
+ self.db_names['config'],
646
644
  where,
647
645
  limit=limit,
648
646
  key=key
reydb/rexec.py CHANGED
@@ -28,6 +28,7 @@ from .rbase import DatabaseBase, handle_sql, handle_data
28
28
 
29
29
  __all__ = (
30
30
  'Result',
31
+ 'ResultORM',
31
32
  'DatabaseExecuteSuper',
32
33
  'DatabaseExecute',
33
34
  'DatabaseExecuteAsync'
@@ -35,8 +36,8 @@ __all__ = (
35
36
 
36
37
 
37
38
  # Monkey path.
38
- Result_ = monkey_sqlalchemy_result_more_fetch()
39
- Result = Result_
39
+ _Result = monkey_sqlalchemy_result_more_fetch()
40
+ Result = _Result
40
41
  monkey_sqlalchemy_row_index_field()
41
42
 
42
43
 
reydb/rorm.py CHANGED
@@ -9,24 +9,27 @@
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
19
- from sqlalchemy.ext.asyncio import AsyncSessionTransaction
20
- from sqlalchemy import types
21
- 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
17
+ from sqlalchemy import Column, types, text as sqlalchemy_text
18
+ from sqlalchemy.orm import SessionTransaction, load_only
19
+ from sqlalchemy.orm.strategy_options import _AttrType
24
20
  from sqlalchemy.sql import func as sqlalchemy_func
21
+ from sqlalchemy.sql.dml import Update, Delete
22
+ from sqlalchemy.sql.sqltypes import TypeEngine
23
+ from sqlalchemy.sql._typing import _ColumnExpressionArgument
24
+ from sqlalchemy.ext.asyncio import AsyncSessionTransaction
25
+ from sqlalchemy.dialects.mysql import Insert, types as types_mysql
26
+ from sqlalchemy.exc import SAWarning
25
27
  from sqlmodel import SQLModel, Session, Table
26
- from sqlmodel.ext.asyncio.session import AsyncSession
27
28
  from sqlmodel.main import SQLModelMetaclass, FieldInfo, default_registry
29
+ from sqlmodel.ext.asyncio.session import AsyncSession
28
30
  from sqlmodel.sql._expression_select_cls import SelectOfScalar as Select
29
31
  from datetime import datetime, date, time, timedelta
32
+ from warnings import filterwarnings
30
33
  from reykit.rbase import CallableT, Null, throw, is_instance
31
34
 
32
35
  from . import rdb
@@ -35,6 +38,7 @@ from .rbase import (
35
38
  SessionTransactionT,
36
39
  DatabaseBase
37
40
  )
41
+ from .rexec import Result
38
42
 
39
43
 
40
44
  __all__ = (
@@ -52,13 +56,15 @@ __all__ = (
52
56
  'DatabaseORMStatementSuper',
53
57
  'DatabaseORMStatement',
54
58
  'DatabaseORMStatementAsync',
59
+ 'DatabaseORMStatementSelectSuper',
55
60
  'DatabaseORMStatementSelect',
56
- 'DatabaseORMStatementInsert',
57
- 'DatabaseORMStatementUpdate',
58
- 'DatabaseORMStatementDelete',
59
61
  'DatabaseORMStatementSelectAsync',
62
+ 'DatabaseORMStatementInsertSuper',
63
+ 'DatabaseORMStatementInsert',
60
64
  'DatabaseORMStatementInsertAsync',
65
+ 'DatabaseORMStatementUpdate',
61
66
  'DatabaseORMStatementUpdateAsync',
67
+ 'DatabaseORMStatementDelete',
62
68
  'DatabaseORMStatementDeleteAsync'
63
69
  )
64
70
 
@@ -67,7 +73,6 @@ DatabaseT = TypeVar('DatabaseT', 'rdb.Database', 'rdb.DatabaseAsync')
67
73
  DatabaseORMModelT = TypeVar('DatabaseORMModelT', bound='DatabaseORMModel')
68
74
  DatabaseORMT = TypeVar('DatabaseORMT', 'DatabaseORM', 'DatabaseORMAsync')
69
75
  DatabaseORMSessionT = TypeVar('DatabaseORMSessionT', 'DatabaseORMSession', 'DatabaseORMSessionAsync')
70
- DatabaseORMStatementReturn = TypeVar('DatabaseORMStatementReturn')
71
76
  DatabaseORMStatementSelectT = TypeVar('DatabaseORMStatementSelectT', 'DatabaseORMStatementSelect', 'DatabaseORMStatementSelectAsync')
72
77
  DatabaseORMStatementInsertT = TypeVar('DatabaseORMStatementInsertT', 'DatabaseORMStatementInsert', 'DatabaseORMStatementInsertAsync')
73
78
  DatabaseORMStatementUpdateT = TypeVar('DatabaseORMStatementUpdateT', 'DatabaseORMStatementUpdate', 'DatabaseORMStatementUpdateAsync')
@@ -660,7 +665,7 @@ class DatabaseORMSessionSuper(
660
665
  -------
661
666
  Instance.
662
667
  """
663
- print(model)
668
+
664
669
  # Set parameter.
665
670
  if is_instance(model):
666
671
  model = type(model)
@@ -1096,7 +1101,7 @@ class DatabaseORMSession(
1096
1101
 
1097
1102
 
1098
1103
  @overload
1099
- def select(self, model: Type[DatabaseORMModelT] | DatabaseORMModelT) -> 'DatabaseORMStatementSelect[list[DatabaseORMModelT]]': ...
1104
+ def select(self, model: Type[DatabaseORMModelT] | DatabaseORMModelT) -> 'DatabaseORMStatementSelect[DatabaseORMModelT]': ...
1100
1105
 
1101
1106
  select = DatabaseORMSessionSuper.select
1102
1107
 
@@ -1470,7 +1475,7 @@ class DatabaseORMSessionAsync(
1470
1475
 
1471
1476
 
1472
1477
  @overload
1473
- def select(self, model: Type[DatabaseORMModelT] | DatabaseORMModelT) -> 'DatabaseORMStatementSelectAsync[list[DatabaseORMModelT]]': ...
1478
+ def select(self, model: Type[DatabaseORMModelT] | DatabaseORMModelT) -> 'DatabaseORMStatementSelectAsync[DatabaseORMModelT]': ...
1474
1479
 
1475
1480
  select = DatabaseORMSessionSuper.select
1476
1481
 
@@ -1503,36 +1508,48 @@ class DatabaseORMStatementSuper(DatabaseORMBase, Generic[DatabaseORMSessionT]):
1503
1508
  self.model = model
1504
1509
 
1505
1510
 
1506
- class DatabaseORMStatement(DatabaseORMStatementSuper[DatabaseORMSession], Generic[DatabaseORMStatementReturn]):
1511
+ @overload
1512
+ def with_only_columns(self) -> NoReturn: ...
1513
+
1514
+
1515
+ class DatabaseORMStatement(DatabaseORMStatementSuper[DatabaseORMSession]):
1507
1516
  """
1508
1517
  Database ORM statement type.
1509
1518
  """
1510
1519
 
1511
1520
 
1512
- def execute(self) -> DatabaseORMStatementReturn:
1521
+ def execute(self) -> Result:
1513
1522
  """
1514
1523
  Execute statement.
1524
+
1525
+ Returns
1526
+ -------
1527
+ Result.
1515
1528
  """
1516
1529
 
1530
+ # Filter warning.
1531
+ filterwarnings(
1532
+ 'ignore',
1533
+ category=SAWarning,
1534
+ message=".*'inherit_cache' attribute to ``True``.*"
1535
+ )
1536
+
1517
1537
  # Transaction.
1518
1538
  self.sess.get_begin()
1519
1539
 
1520
1540
  # Execute.
1521
- result = self.sess.sess.exec(self)
1541
+ result: Result = self.sess.sess.exec(self)
1522
1542
 
1523
- ## Select.
1543
+ ## Select.)
1524
1544
  if isinstance(self, Select):
1525
- result = list(result)
1526
- else:
1527
- result = None
1545
+ result: list[DatabaseORMModel] = list(result)
1528
1546
 
1529
1547
  # Automatic commit.
1530
1548
  if self.sess.autocommit:
1531
1549
 
1532
1550
  ## Select.
1533
1551
  if isinstance(self, Select):
1534
- for model in result:
1535
- self.sess.sess.expunge(model)
1552
+ self.sess.sess.expunge_all()
1536
1553
 
1537
1554
  self.sess.commit()
1538
1555
  self.sess.close()
@@ -1540,36 +1557,44 @@ class DatabaseORMStatement(DatabaseORMStatementSuper[DatabaseORMSession], Generi
1540
1557
  return result
1541
1558
 
1542
1559
 
1543
- class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsync], Generic[DatabaseORMStatementReturn]):
1560
+ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsync]):
1544
1561
  """
1545
1562
  Asynchronous dtabase ORM statement type.
1546
1563
  """
1547
1564
 
1548
1565
 
1549
- async def execute(self) -> DatabaseORMStatementReturn:
1566
+ async def execute(self) -> Result:
1550
1567
  """
1551
- Asynchronous execute statement.
1568
+ Asynchrouous execute statement.
1569
+
1570
+ Returns
1571
+ -------
1572
+ Result.
1552
1573
  """
1553
1574
 
1575
+ # Filter warning.
1576
+ filterwarnings(
1577
+ 'ignore',
1578
+ category=SAWarning,
1579
+ message=".*'inherit_cache' attribute to ``True``.*"
1580
+ )
1581
+
1554
1582
  # Transaction.
1555
1583
  await self.sess.get_begin()
1556
1584
 
1557
1585
  # Execute.
1558
- result = await self.sess.sess.exec(self)
1586
+ result: Result = await self.sess.sess.exec(self)
1559
1587
 
1560
1588
  ## Select.
1561
1589
  if isinstance(self, Select):
1562
- result = list(result)
1563
- else:
1564
- result = None
1590
+ result: list[DatabaseORMModel] = list(result)
1565
1591
 
1566
1592
  # Automatic commit.
1567
1593
  if self.sess.autocommit:
1568
1594
 
1569
1595
  ## Select.
1570
1596
  if isinstance(self, Select):
1571
- for model in result:
1572
- self.sess.sess.expunge(model)
1597
+ self.sess.sess.expunge_all()
1573
1598
 
1574
1599
  await self.sess.commit()
1575
1600
  await self.sess.close()
@@ -1578,109 +1603,380 @@ class DatabaseORMStatementAsync(DatabaseORMStatementSuper[DatabaseORMSessionAsyn
1578
1603
  return result
1579
1604
 
1580
1605
 
1581
- class DatabaseORMStatementSelect(DatabaseORMStatement, Select, Generic[DatabaseORMStatementReturn]):
1606
+ class DatabaseORMStatementSelectSuper(DatabaseORMStatementSuper, Select):
1607
+ """
1608
+ Database ORM `select` statement super type.
1609
+
1610
+ Attributes
1611
+ ----------
1612
+ inherit_cache : Compatible type.
1613
+ """
1614
+
1615
+ inherit_cache: Final = True
1616
+
1617
+
1618
+ def fields(self, *names: str) -> Self:
1619
+ """
1620
+ Replace select fiedls.
1621
+
1622
+ Parameters
1623
+ ----------
1624
+ names : Field name. (Note: primary key automatic add)
1625
+
1626
+ Returns
1627
+ -------
1628
+ Set self.
1629
+ """
1630
+
1631
+ # Set.
1632
+ attrs = [
1633
+ self.model[name]
1634
+ for name in names
1635
+ ]
1636
+ set = load_only(*attrs)
1637
+ select = self.options(set)
1638
+
1639
+ return select
1640
+
1641
+
1642
+ def where(self, *clauses: str | _ColumnExpressionArgument[bool]) -> Self:
1643
+ """
1644
+ Set `WHERE` syntax.
1645
+
1646
+ Parameters
1647
+ ----------
1648
+ clauses : Judgement clauses.
1649
+ - `str`: SQL string.
1650
+ - `_ColumnExpressionArgument[bool]`: Clause.
1651
+
1652
+ Returns
1653
+ -------
1654
+ Set self.
1655
+ """
1656
+
1657
+ # Set parameter.
1658
+ clauses = [
1659
+ sqlalchemy_text(clause)
1660
+ if type(clause) == str
1661
+ else clause
1662
+ for clause in clauses
1663
+ ]
1664
+
1665
+ # Super.
1666
+ stmt = super().where(*clauses)
1667
+
1668
+ return stmt
1669
+
1670
+
1671
+ class DatabaseORMStatementSelect(DatabaseORMStatement, DatabaseORMStatementSelectSuper, Generic[DatabaseORMModelT]):
1582
1672
  """
1583
1673
  Database ORM `select` statement type.
1584
1674
 
1585
1675
  Attributes
1586
1676
  ----------
1587
- inherit_cache : Compatible `Select` type.
1677
+ inherit_cache : Compatible type.
1588
1678
  """
1589
1679
 
1590
1680
  inherit_cache: Final = True
1591
1681
 
1592
1682
 
1593
1683
  @overload
1594
- def execute(self) -> DatabaseORMStatementReturn: ...
1684
+ def execute(self) -> list[DatabaseORMModelT]: ...
1595
1685
 
1596
1686
  execute = DatabaseORMStatement.execute
1597
1687
 
1598
1688
 
1599
- class DatabaseORMStatementInsert(DatabaseORMStatement[None], Insert):
1689
+ class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync, DatabaseORMStatementSelectSuper, Generic[DatabaseORMModelT]):
1600
1690
  """
1601
- Database ORM `insert` statement type.
1691
+ Asynchronous database ORM `select` statement type.
1602
1692
 
1603
1693
  Attributes
1604
1694
  ----------
1605
- inherit_cache : Compatible `Select` type.
1695
+ inherit_cache : Compatible type.
1606
1696
  """
1607
1697
 
1608
1698
  inherit_cache: Final = True
1609
1699
 
1610
1700
 
1611
- class DatabaseORMStatementUpdate(DatabaseORMStatement[None], Update):
1701
+ @overload
1702
+ async def execute(self) -> list[DatabaseORMModelT]: ...
1703
+
1704
+ execute = DatabaseORMStatementAsync.execute
1705
+
1706
+
1707
+ class DatabaseORMStatementInsertSuper(DatabaseORMStatementSuper, Insert):
1612
1708
  """
1613
- Database ORM `update` statement type.
1709
+ Database ORM `select` statement super type.
1614
1710
 
1615
1711
  Attributes
1616
1712
  ----------
1617
- inherit_cache : Compatible `Update` type.
1713
+ inherit_cache : Compatible type.
1618
1714
  """
1619
1715
 
1620
1716
  inherit_cache: Final = True
1621
1717
 
1622
1718
 
1623
- class DatabaseORMStatementDelete(DatabaseORMStatement[None], Delete):
1719
+ def ignore(self) -> Self:
1720
+ """
1721
+ Add `IGNORE` syntax.
1722
+
1723
+ Returns
1724
+ -------
1725
+ Set self.
1726
+ """
1727
+
1728
+ # Set.
1729
+ insert = self.prefix_with('IGNORE')
1730
+
1731
+ return insert
1732
+
1733
+
1734
+ @overload
1735
+ def update(self, *names: str) -> Self: ...
1736
+
1737
+ @overload
1738
+ def update(self, **values: Any) -> Self: ...
1739
+
1740
+ @overload
1741
+ def update(self) -> Self: ...
1742
+
1743
+ def update(self, *names: str, **values: Any) -> Self:
1744
+ """
1745
+ Add `ON DUPLICATE KEY UPDATE`.
1746
+
1747
+ Parameters
1748
+ ----------
1749
+ names : Field name. One to one update to this field value. (i.e. `field = VALUE(field)`)
1750
+ values : Scalar value. One to many update to this value. (i.e. `field = :value`)
1751
+ - `Empty`: All parameters omit. One to one update to all fields value. (i.e. `field = VALUE(field), ...`)
1752
+
1753
+ Returns
1754
+ -------
1755
+ Set self.
1756
+
1757
+ Examples
1758
+ --------
1759
+ >>> data = [{'score': 1}, {'score': 2}]
1760
+
1761
+ Name.
1762
+ >>> orm.insert(model).values(data).update('score')
1763
+
1764
+ Value.
1765
+ >>> orm.insert(model).values(data).update(score=0)
1766
+
1767
+ Empty.
1768
+ >>> orm.insert(model).values(data).update()
1769
+ """
1770
+
1771
+ # Set.
1772
+
1773
+ ## Name.
1774
+ if names != ():
1775
+ columns: dict[str, Column] = {
1776
+ name: self.inserted[name]
1777
+ for name in names
1778
+ }
1779
+ insert = self.on_duplicate_key_update(**columns)
1780
+
1781
+ ## Value.
1782
+ elif values != {}:
1783
+ insert = self.on_duplicate_key_update(**values)
1784
+
1785
+ ## Empty.
1786
+ else:
1787
+ columns: dict[str, Column] = dict(self.inserted.items())
1788
+ insert = self.on_duplicate_key_update(**columns)
1789
+
1790
+ return insert
1791
+
1792
+
1793
+ class DatabaseORMStatementInsert(DatabaseORMStatement, DatabaseORMStatementInsertSuper):
1624
1794
  """
1625
- Database ORM `delete` statement type.
1795
+ Database ORM `insert` statement type.
1626
1796
 
1627
1797
  Attributes
1628
1798
  ----------
1629
- inherit_cache : Compatible `Delete` type.
1799
+ inherit_cache : Compatible type.
1630
1800
  """
1631
1801
 
1632
1802
  inherit_cache: Final = True
1633
1803
 
1634
1804
 
1635
- class DatabaseORMStatementSelectAsync(DatabaseORMStatementAsync, Select):
1805
+ class DatabaseORMStatementInsertAsync(DatabaseORMStatementAsync, DatabaseORMStatementInsertSuper):
1636
1806
  """
1637
- Asynchronous database ORM `select` statement type.
1807
+ Asynchronous database ORM `insert` statement type.
1638
1808
 
1639
1809
  Attributes
1640
1810
  ----------
1641
- inherit_cache : Compatible `Select` type.
1811
+ inherit_cache : Compatible type.
1642
1812
  """
1643
1813
 
1644
1814
  inherit_cache: Final = True
1645
1815
 
1646
1816
 
1647
- @overload
1648
- async def execute(self) -> DatabaseORMStatementReturn: ...
1817
+ class DatabaseORMStatementUpdateSuper(DatabaseORMStatementSuper, Update):
1818
+ """
1819
+ Database ORM `update` statement super type.
1649
1820
 
1650
- execute = DatabaseORMStatementAsync.execute
1821
+ Attributes
1822
+ ----------
1823
+ inherit_cache : Compatible type.
1824
+ """
1825
+
1826
+ inherit_cache: Final = True
1827
+
1828
+
1829
+ def where(self, *clauses: str | _ColumnExpressionArgument[bool]) -> Self:
1830
+ """
1831
+ Set `WHERE` syntax.
1832
+
1833
+ Parameters
1834
+ ----------
1835
+ clauses : Judgement clauses.
1836
+ - `str`: SQL string.
1837
+ - `_ColumnExpressionArgument[bool]`: Clause.
1838
+
1839
+ Returns
1840
+ -------
1841
+ Set self.
1842
+ """
1843
+
1844
+ # Set parameter.
1845
+ clauses = [
1846
+ sqlalchemy_text(clause)
1847
+ if type(clause) == str
1848
+ else clause
1849
+ for clause in clauses
1850
+ ]
1851
+
1852
+ # Super.
1853
+ stmt = super().where(*clauses)
1854
+
1855
+ return stmt
1856
+
1857
+
1858
+ def limit(self, number: int) -> Self:
1859
+ """
1860
+ Set `limit` syntax.
1861
+
1862
+ Parameters
1863
+ ----------
1864
+ number : Limit number.
1865
+
1866
+ Returns
1867
+ -------
1868
+ Set self.
1869
+ """
1870
+
1871
+ # Set.
1872
+ update = self.with_dialect_options(mysql_limit=number)
1873
+
1874
+ return update
1651
1875
 
1652
1876
 
1653
- class DatabaseORMStatementInsertAsync(DatabaseORMStatementAsync[None], Insert):
1877
+ class DatabaseORMStatementUpdate(DatabaseORMStatement, DatabaseORMStatementUpdateSuper):
1654
1878
  """
1655
- Asynchronous database ORM `insert` statement type.
1879
+ Database ORM `update` statement type.
1656
1880
 
1657
1881
  Attributes
1658
1882
  ----------
1659
- inherit_cache : Compatible `Select` type.
1883
+ inherit_cache : Compatible type.
1660
1884
  """
1661
1885
 
1662
1886
  inherit_cache: Final = True
1663
1887
 
1664
1888
 
1665
- class DatabaseORMStatementUpdateAsync(DatabaseORMStatementAsync[None], Update):
1889
+ class DatabaseORMStatementUpdateAsync(DatabaseORMStatementAsync, DatabaseORMStatementUpdateSuper):
1666
1890
  """
1667
1891
  Asynchronous database ORM `update` statement type.
1668
1892
 
1669
1893
  Attributes
1670
1894
  ----------
1671
- inherit_cache : Compatible `Update` type.
1895
+ inherit_cache : Compatible type.
1896
+ """
1897
+
1898
+ inherit_cache: Final = True
1899
+
1900
+
1901
+ class DatabaseORMStatementDeleteSuper(DatabaseORMStatementSuper, Delete):
1902
+ """
1903
+ Database ORM `delete` statement super type.
1904
+
1905
+ Attributes
1906
+ ----------
1907
+ inherit_cache : Compatible type.
1908
+ """
1909
+
1910
+ inherit_cache: Final = True
1911
+
1912
+
1913
+ def where(self, *clauses: str | _ColumnExpressionArgument[bool]) -> Self:
1914
+ """
1915
+ Set `WHERE` syntax.
1916
+
1917
+ Parameters
1918
+ ----------
1919
+ clauses : Judgement clauses.
1920
+ - `str`: SQL string.
1921
+ - `_ColumnExpressionArgument[bool]`: Clause.
1922
+
1923
+ Returns
1924
+ -------
1925
+ Set self.
1926
+ """
1927
+
1928
+ # Set parameter.
1929
+ clauses = [
1930
+ sqlalchemy_text(clause)
1931
+ if type(clause) == str
1932
+ else clause
1933
+ for clause in clauses
1934
+ ]
1935
+
1936
+ # Super.
1937
+ stmt = super().where(*clauses)
1938
+
1939
+ return stmt
1940
+
1941
+
1942
+ def limit(self, number: int) -> Self:
1943
+ """
1944
+ Set `limit` syntax.
1945
+
1946
+ Parameters
1947
+ ----------
1948
+ number : Limit number.
1949
+
1950
+ Returns
1951
+ -------
1952
+ Set self.
1953
+ """
1954
+
1955
+ # Set.
1956
+ update = self.with_dialect_options(mysql_limit=number)
1957
+
1958
+ return update
1959
+
1960
+
1961
+ class DatabaseORMStatementDelete(DatabaseORMStatement, DatabaseORMStatementDeleteSuper):
1962
+ """
1963
+ Database ORM `delete` statement type.
1964
+
1965
+ Attributes
1966
+ ----------
1967
+ inherit_cache : Compatible type.
1672
1968
  """
1673
1969
 
1674
1970
  inherit_cache: Final = True
1675
1971
 
1676
1972
 
1677
- class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync[None], Delete):
1973
+ class DatabaseORMStatementDeleteAsync(DatabaseORMStatementAsync, DatabaseORMStatementDeleteSuper):
1678
1974
  """
1679
1975
  Asynchronous database ORM `delete` statement type.
1680
1976
 
1681
1977
  Attributes
1682
1978
  ----------
1683
- inherit_cache : Compatible `Delete` type.
1979
+ inherit_cache : Compatible type.
1684
1980
  """
1685
1981
 
1686
1982
  inherit_cache: Final = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reydb
3
- Version: 1.2.11
3
+ Version: 1.2.13
4
4
  Summary: Database method set.
5
5
  Project-URL: homepage, https://github.com/reyxbo/reydb/
6
6
  Author-email: Rey <reyxbo@163.com>
@@ -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=xoujEyZzkB9UwG8lkZBDBmeUOEo8Sr1Oktveos-EWWc,19168
5
+ reydb/rconfig.py,sha256=xXNZf0yMkNWK_7NMpCUg0osYHLCVYsy0QV3qlSvmVSI,19229
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=u6ZU5dljUktICvJFhUIzg3U7ME9fhICL3NyqZugz5H4,53010
9
+ reydb/rexec.py,sha256=HSu8fCgBjpKY1z6OJI6Ky_0sKMPEv_uCAEAcN7fd2i4,53028
10
10
  reydb/rinfo.py,sha256=LjrqTA7JJbWJsjXwV-zKpbE1htv-whg6239hoQj4yIU,18151
11
- reydb/rorm.py,sha256=kVe2PtF7pYy6zws8c9qBDYkY2ZmGoiHcio1wN_3LmEk,44244
12
- reydb-1.2.11.dist-info/METADATA,sha256=AiSPwqweD3Q8-g87j4HxIHO-OR-26X2F7vA3UKvgcT0,1622
13
- reydb-1.2.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- reydb-1.2.11.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
15
- reydb-1.2.11.dist-info/RECORD,,
11
+ reydb/rorm.py,sha256=NxY2qOCXDwyy_lSRWZPxQDhG8IuLLxbaqIWxOZ1DDys,50791
12
+ reydb-1.2.13.dist-info/METADATA,sha256=RJBvka1FTupRVLdIDJjUtbb7xJSVEaD4J-AYwyAxig0,1622
13
+ reydb-1.2.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ reydb-1.2.13.dist-info/licenses/LICENSE,sha256=UYLPqp7BvPiH8yEZduJqmmyEl6hlM3lKrFIefiD4rvk,1059
15
+ reydb-1.2.13.dist-info/RECORD,,
File without changes