-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsqloxide.pyi
210 lines (162 loc) · 5.44 KB
/
sqloxide.pyi
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
from typing import Any, Generic, Literal, TypeAlias, TypedDict, TypeVar
Dialect: TypeAlias = Literal["generic", "ansi", "sqlite", "postgresql"]
def parse_sql(sql: str, dialect: Dialect) -> list[Statement]: ...
T = TypeVar("T")
ObjectName: TypeAlias = list[Ident]
"""
A name of a table, view, custom type, etc.
(possibly multi-part, i.e. db.schema.obj)
"""
Statement: TypeAlias = AstSelect | AstInsert | AstSetVariable | dict[str, Any]
"""
A top-level statement (SELECT, INSERT, CREATE, etc.)
See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/enum.Statement.html
"""
SetExpr: TypeAlias = AstSelect | AstSelect | AstQuery | AstValues | dict[str, Any]
"""
A node in a tree, representing a “query body” expression,
roughly: `SELECT ... [ {UNION|EXCEPT|INTERSECT} SELECT ...]`
See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/enum.SetExpr.html
"""
Expr: TypeAlias = AstIdentifier | dict[str, Any]
"""
A SQL expression of any type.
See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/enum.Expr.html
"""
Value: TypeAlias = dict[str, Any]
"""
Primitive SQL values such as number and string.
See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/enum.Value.html
"""
TableFactor: TypeAlias = dict[str, Any]
"""
A table name or a parenthesized subquery with an optional alias.
See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/enum.TableFactor.html
"""
JoinOperator: TypeAlias = dict[str, Any]
"""See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/enum.JoinOperator.html"""
class One(TypedDict, Generic[T]):
One: T
class Many(TypedDict, Generic[T]):
Many: list[T]
class AstSelect(TypedDict):
Select: Select
class AstSetVariable(TypedDict):
SetVariable: SetVariable
class AstInsert(TypedDict):
Insert: Insert
class AstIdentifier(TypedDict):
"""An identifier (e.g. table name or column name)"""
Identifier: Ident
class AstCompoundIdentifier(TypedDict):
"""A multi-part identifier (e.g. table_alias.column or schema.table.col)"""
CompoundIdentifier: list[Ident]
class AstValue(TypedDict):
"""A literal value, such as string, number, date or NULL."""
Value: Value
class AstValues(TypedDict):
"""An insert VALUES clause."""
Values: Values
class AstQuery(TypedDict):
"""
A parenthesized subquery (SELECT ...),
used in an expression like SELECT (subquery) AS x or WHERE (subquery) = x
"""
Query: Query
class AstSubquery(TypedDict):
"""
A parenthesized SELECT subquery.
When part of a `SetExpr`, a subquery may include more set operations
in its body and an optional ORDER BY / LIMIT.
"""
Query: Query
class AstTable(TypedDict):
Table: Table
class Ident(TypedDict):
"""An identifier, decomposed into its value or character data and the quote style."""
value: str
quote_style: Any | None
class SetVariable(TypedDict):
"""
SET <variable> = expression;
SET (variable[, ...]) = (expression[, ...]);
"""
local: bool
hivevar: bool
variables: One[ObjectName] | Many[ObjectName]
value: list[Expr]
class Select(TypedDict("Select", {"from": list[TableWithJoins]})):
select_token: Any # AttachedToken
distinct: Any | None # Option<Distinct>
top: Any | None # Option<Top,
top_before_distinct: bool
projection: list[Any] # Vec<SelectItem>
into: Any | None # Option<SelectInto>
lateral_views: list[Any] # Vec<LateralView>
prewhere: Expr | None
selection: Expr | None
group_by: Any # GroupByExpr,
cluster_by: list[Expr]
distribute_by: list[Expr]
sort_by: list[Expr]
having: Expr | None
named_window: list[Any] # Vec<NamedWindowDefinition>
qualify: Expr | None
window_before_qualify: bool
value_table_mode: Any | None # Option<ValueTableMode>
connect_by: Any | None # Option<ConnectBy>
class Insert(TypedDict("Insert", {"or": Any | None})):
"""
An INSERT statement.
See https://docs.rs/sqlparser/0.51.0/sqlparser/ast/struct.Insert.html
"""
ignore: bool
into: bool
table_name: ObjectName
table_alias: Any | None
columns: list[Ident]
overwrite: bool
source: Query | None
"""A SQL query that specifies what to insert"""
partitioned: Any | None
after_columns: list[Any]
table: bool
on: dict[str, Any] | None # e.g. {"OnConflict": {"conflict_target": None, "action": "DoNothing"}},
returning: Any | None
replace_into: bool
priority: Any | None
insert_alias: Any | None
class Query(TypedDict("Query", {"with": Any | None})):
"""
The most complete variant of a SELECT query expression,
optionally including WITH, UNION / other set operations, and ORDER BY.
"""
body: SetExpr
order_by: Any | None
limit: Any | None
limit_by: list[Any]
offset: Any | None
fetch: Any | None
locks: list[Any]
for_clause: Any | None
settings: Any | None
format_clause: Any | None
class Values(TypedDict):
explicit_row: bool
rows: list[list[Expr]]
class TableWithJoins(TypedDict):
relation: TableFactor
joins: list[Join]
class Join(TypedDict("Join", {"global": bool})):
relation: TableFactor
join_operator: JoinOperator
class Table(TypedDict):
name: ObjectName
alias: Any | None # Option<TableAlias>
args: Any | None # Option<TableFunctionArgs>
with_hints: list[Expr]
version: Any | None # Option<TableVersion>
with_ordinality: bool
partitions: list[Ident]
json_path: Any | None # Option<JsonPath>
sample: Any | None # Option<TableSampleKind>