-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder-interfaces.go
More file actions
80 lines (63 loc) · 1.65 KB
/
builder-interfaces.go
File metadata and controls
80 lines (63 loc) · 1.65 KB
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
package tomasql
type BuilderWithSelect interface {
SubQueryable
From(Table) BuilderWithTables
}
type BuilderWithTables interface {
SubQueryable
LeftJoin(Table) BuilderWithJoin
Join(Table) BuilderWithJoin
RightJoin(Table) BuilderWithJoin
Joins(...*JoinItem) BuilderWithTables
Where(Condition) BuilderWithWhere
GroupBy(ParametricSql, ...ParametricSql) BuilderWithGroupBy
OrderBy(SortColumn, ...SortColumn) BuilderWithOrderBy
}
type BuilderWithJoin interface {
SubQueryable
On(Condition) BuilderWithTables
}
type BuilderWithWhere interface {
SubQueryable
GroupBy(ParametricSql, ...ParametricSql) BuilderWithGroupBy
OrderBy(SortColumn, ...SortColumn) BuilderWithOrderBy
}
type BuilderWithGroupBy interface {
BuilderWithHaving
Having(Condition) BuilderWithHaving
}
type BuilderWithHaving interface {
SubQueryable
OrderBy(SortColumn, ...SortColumn) BuilderWithOrderBy
}
type BuilderWithOrderBy interface {
SubQueryable
Limit(int) BuilderWithLimit
}
type BuilderWithLimit interface {
SubQueryable
Offset(int) SQLable
}
type SQLable interface {
ParametricSql
SQL() (sql string, params []any)
}
type ParametricSql interface {
// SqlWithParams renders SQL with awareness of the context (SELECT, WHERE, etc.)
SqlWithParams(ParamsMap, RenderContext) (string, ParamsMap)
}
type SubQueryable interface {
SQLable
AsNamedSubQuery(string) Table
AsSubQuery() SQLable
}
type SortDirection string
const (
OrderByAsc SortDirection = "ASC"
OrderByDesc SortDirection = "DESC"
)
type SortColumn interface {
ParametricSql
// Column returns the underlying Column that this SortColumn represents or nil if it is not a Column (e.g. subquery).
Column() Column
}