-
Notifications
You must be signed in to change notification settings - Fork 279
/
selection-node.ts
43 lines (37 loc) · 1.11 KB
/
selection-node.ts
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
import { freeze } from '../util/object-utils.js'
import { AliasNode } from './alias-node.js'
import { ColumnNode } from './column-node.js'
import { OperationNode } from './operation-node.js'
import { ReferenceNode } from './reference-node.js'
import { SelectAllNode } from './select-all-node.js'
type SelectionNodeChild = ColumnNode | ReferenceNode | AliasNode | SelectAllNode
export interface SelectionNode extends OperationNode {
readonly kind: 'SelectionNode'
readonly selection: SelectionNodeChild
}
/**
* @internal
*/
export const SelectionNode = freeze({
is(node: OperationNode): node is SelectionNode {
return node.kind === 'SelectionNode'
},
create(selection: SelectionNodeChild): SelectionNode {
return freeze({
kind: 'SelectionNode',
selection: selection,
})
},
createSelectAll(): SelectionNode {
return freeze({
kind: 'SelectionNode',
selection: SelectAllNode.create(),
})
},
createSelectAllFromTable(table: string): SelectionNode {
return freeze({
kind: 'SelectionNode',
selection: ReferenceNode.createSelectAll(table),
})
},
})