Coverage for sqlmodel/sql/_expression_select_cls.py: 93%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
1from typing import ( 1abcdef
2 Tuple,
3 TypeVar,
4 Union,
5)
7from sqlalchemy.sql._typing import ( 1abcdef
8 _ColumnExpressionArgument,
9)
10from sqlalchemy.sql.expression import Select as _Select 1abcdef
11from typing_extensions import Self 1abcdef
13_T = TypeVar("_T") 1abcdef
16# Separate this class in SelectBase, Select, and SelectOfScalar so that they can share
17# where and having without having type overlap incompatibility in session.exec().
18class SelectBase(_Select[Tuple[_T]]): 1abcdef
19 inherit_cache = True 1abcdef
21 def where(self, *whereclause: Union[_ColumnExpressionArgument[bool], bool]) -> Self: 1abcdef
22 """Return a new `Select` construct with the given expression added to
23 its `WHERE` clause, joined to the existing clause via `AND`, if any.
24 """
25 return super().where(*whereclause) # type: ignore[arg-type] 2g h i j 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~daebecedeeefegeheiejekelemeneoepeqereseteuevewexeyezeAeBeCeDeEeFeGeHeIeJeKeLeMeNeOePeQeReSeTeUeVeWeXeYeZe0e1e2e3e4e5e6e7e8e9e!e#e$e%e'e(e)e*e+e,e-e.e/e:e;e=e?e@e[e
27 def having(self, *having: Union[_ColumnExpressionArgument[bool], bool]) -> Self: 1abcdef
28 """Return a new `Select` construct with the given expression added to
29 its `HAVING` clause, joined to the existing clause via `AND`, if any.
30 """
31 return super().having(*having) # type: ignore[arg-type]
34class Select(SelectBase[_T]): 1abcdef
35 inherit_cache = True 1abcdef
38# This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different
39# purpose. This is the same as a normal SQLAlchemy Select class where there's only one
40# entity, so the result will be converted to a scalar by default. This way writing
41# for loops on the results will feel natural.
42class SelectOfScalar(SelectBase[_T]): 1abcdef
43 inherit_cache = True 1abcdef