FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmodel/sqlmodel/sql/_expression_select_cls.py at main · HitBeemo/sqlmodel · GitHub
HitBeemo
sqlmodel
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmodel
/
sqlmodel
/
sql
/
_expression_select_cls.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (33 loc) · 1.51 KB
Breadcrumbs
sqlmodel
/
sqlmodel
/
sql
/
_expression_select_cls.py
Copy path
File metadata and controls
43 lines (33 loc) · 1.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from
typing
import
(
Tuple
,
TypeVar
,
Union
,
)
from
sqlalchemy
.
sql
.
_typing
import
(
_ColumnExpressionArgument
,
)
from
sqlalchemy
.
sql
.
expression
import
Select
as
_Select
from
typing_extensions
import
Self
_T
=
TypeVar
(
"_T"
)
# Separate this class in SelectBase, Select, and SelectOfScalar so that they can share
# where and having without having type overlap incompatibility in session.exec().
class
SelectBase
(
_Select
[
Tuple
[
_T
]]):
inherit_cache
=
True
def
where
(
self
,
*
whereclause
:
Union
[
_ColumnExpressionArgument
[
bool
],
bool
])
->
Self
:
"""Return a new `Select` construct with the given expression added to
its `WHERE` clause, joined to the existing clause via `AND`, if any.
"""
return
super
().
where
(
*
whereclause
)
# type: ignore[arg-type]
def
having
(
self
,
*
having
:
Union
[
_ColumnExpressionArgument
[
bool
],
bool
])
->
Self
:
"""Return a new `Select` construct with the given expression added to
its `HAVING` clause, joined to the existing clause via `AND`, if any.
"""
return
super
().
having
(
*
having
)
# type: ignore[arg-type]
class
Select
(
SelectBase
[
_T
]):
inherit_cache
=
True
# This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different
# purpose. This is the same as a normal SQLAlchemy Select class where there's only one
# entity, so the result will be converted to a scalar by default. This way writing
# for loops on the results will feel natural.
class
SelectOfScalar
(
SelectBase
[
_T
]):
inherit_cache
=
True
Back
|
FazBrowse Home
|
New Git URL