squirreling 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/backend/dataSource.js +48 -15
- package/src/execute/aggregates.js +12 -34
- package/src/execute/execute.js +60 -87
- package/src/execute/expression.js +41 -21
- package/src/execute/having.js +4 -35
- package/src/execute/join.js +357 -0
- package/src/execute/utils.js +44 -6
- package/src/index.d.ts +4 -4
- package/src/parse/expression.js +4 -4
- package/src/parse/parse.js +59 -16
- package/src/types.d.ts +13 -8
package/src/types.d.ts
CHANGED
|
@@ -6,15 +6,13 @@
|
|
|
6
6
|
export interface AsyncDataSource {
|
|
7
7
|
getRows(): AsyncIterable<AsyncRow>
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
getKeys(): string[]
|
|
12
|
-
}
|
|
9
|
+
export type AsyncRow = Record<string, AsyncCell>
|
|
10
|
+
export type AsyncCell = () => Promise<SqlPrimitive>
|
|
13
11
|
|
|
14
|
-
export type
|
|
12
|
+
export type Row = Record<string, SqlPrimitive>[]
|
|
15
13
|
|
|
16
14
|
export interface ExecuteSqlOptions {
|
|
17
|
-
tables: Record<string,
|
|
15
|
+
tables: Record<string, Row | AsyncDataSource>
|
|
18
16
|
query: string
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -23,7 +21,7 @@ export type SqlPrimitive = string | number | bigint | boolean | null
|
|
|
23
21
|
export interface SelectStatement {
|
|
24
22
|
distinct: boolean
|
|
25
23
|
columns: SelectColumn[]
|
|
26
|
-
from
|
|
24
|
+
from: FromTable | FromSubquery
|
|
27
25
|
joins: JoinClause[]
|
|
28
26
|
where?: ExprNode
|
|
29
27
|
groupBy: ExprNode[]
|
|
@@ -33,6 +31,12 @@ export interface SelectStatement {
|
|
|
33
31
|
offset?: number
|
|
34
32
|
}
|
|
35
33
|
|
|
34
|
+
export interface FromTable {
|
|
35
|
+
kind: 'table'
|
|
36
|
+
table: string
|
|
37
|
+
alias?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
export interface FromSubquery {
|
|
37
41
|
kind: 'subquery'
|
|
38
42
|
query: SelectStatement
|
|
@@ -186,8 +190,9 @@ export interface OrderByItem {
|
|
|
186
190
|
export type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS'
|
|
187
191
|
|
|
188
192
|
export interface JoinClause {
|
|
189
|
-
|
|
193
|
+
joinType: JoinType
|
|
190
194
|
table: string
|
|
195
|
+
alias?: string
|
|
191
196
|
on?: ExprNode
|
|
192
197
|
}
|
|
193
198
|
|