Coverage for sqlmodel / sql / _expression_select_cls.py: 93%
15 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-01-06 21:09 +0000
1from typing import ( 1abcdefghi
2 TypeVar,
3 Union,
4)
6from sqlalchemy.sql._typing import ( 1abcdefghi
7 _ColumnExpressionArgument,
8)
9from sqlalchemy.sql.expression import Select as _Select 1abcdefghi
10from typing_extensions import Self 1abcdefghi
12_T = TypeVar("_T") 1abcdefghi
15# Separate this class in SelectBase, Select, and SelectOfScalar so that they can share
16# where and having without having type overlap incompatibility in session.exec().
17class SelectBase(_Select[tuple[_T]]): 1abcdefghi
18 inherit_cache = True 1abcdefghi
20 def where(self, *whereclause: Union[_ColumnExpressionArgument[bool], bool]) -> Self: 1abcdefghi
21 """Return a new `Select` construct with the given expression added to
22 its `WHERE` clause, joined to the existing clause via `AND`, if any.
23 """
24 return super().where(*whereclause) # type: ignore[arg-type] 2j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcGcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*d+d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNe
26 def having(self, *having: Union[_ColumnExpressionArgument[bool], bool]) -> Self: 1abcdefghi
27 """Return a new `Select` construct with the given expression added to
28 its `HAVING` clause, joined to the existing clause via `AND`, if any.
29 """
30 return super().having(*having) # type: ignore[arg-type]
33class Select(SelectBase[_T]): 1abcdefghi
34 inherit_cache = True 1abcdefghi
37# This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different
38# purpose. This is the same as a normal SQLAlchemy Select class where there's only one
39# entity, so the result will be converted to a scalar by default. This way writing
40# for loops on the results will feel natural.
41class SelectOfScalar(SelectBase[_T]): 1abcdefghi
42 inherit_cache = True 1abcdefghi