Coverage for sqlmodel / sql / _expression_select_cls.py: 100%
16 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
1from typing import ( 1abcdefghi
2 TypeVar,
3)
5from sqlalchemy.sql._typing import ( 1abcdefghi
6 _ColumnExpressionArgument,
7)
8from sqlalchemy.sql.expression import Select as _Select 1abcdefghi
9from typing_extensions import Self, TypeVarTuple, Unpack 1abcdefghi
11_T = TypeVar("_T") 1abcdefghi
12_Ts = TypeVarTuple("_Ts") 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[Unpack[_Ts]]): 1abcdefghi
18 inherit_cache = True 1abcdefghi
20 def where(self, *whereclause: _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) # ty: ignore[invalid-argument-type] 2s t u v j 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 ! # $ % ' k ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbl xbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(bm )b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcn yczcAcBcCcDcEcFcGcHcIcJcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)co *c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydp zdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)d*dq +d,d-d.d/d:d;d=d?d@d[d]d^d_d`d{d|d}d~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezer AeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e
26 def having(self, *having: _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) # ty: ignore[invalid-argument-type] 1jklmnopqr
33class Select(SelectBase[Unpack[_Ts]]): 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