rado 0.2.21 → 0.2.23

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.
@@ -3,7 +3,7 @@ import { ColumnType } from "../define/Column.js";
3
3
  import { BinOpType, Expr, ExprData, ExprType, UnOpType } from "../define/Expr.js";
4
4
  import { OrderDirection } from "../define/OrderBy.js";
5
5
  import { ParamType } from "../define/Param.js";
6
- import { Query, QueryType } from "../define/Query.js";
6
+ import { QueryData, QueryType } from "../define/Query.js";
7
7
  import { Target, TargetType } from "../define/Target.js";
8
8
  import { Statement } from "./Statement.js";
9
9
  var binOps = {
@@ -225,11 +225,11 @@ var Formatter = class {
225
225
  formatTransaction(ctx, { op, id }) {
226
226
  const { stmt } = ctx;
227
227
  switch (op) {
228
- case Query.TransactionOperation.Begin:
228
+ case QueryData.TransactionOperation.Begin:
229
229
  return stmt.raw("SAVEPOINT").addIdentifier(id);
230
- case Query.TransactionOperation.Commit:
230
+ case QueryData.TransactionOperation.Commit:
231
231
  return stmt.raw("RELEASE").addIdentifier(id);
232
- case Query.TransactionOperation.Rollback:
232
+ case QueryData.TransactionOperation.Rollback:
233
233
  return stmt.raw("ROLLBACK TO").addIdentifier(id);
234
234
  }
235
235
  }
@@ -446,57 +446,6 @@ var Formatter = class {
446
446
  stmt.add("AS").addIdentifier("result");
447
447
  return stmt;
448
448
  }
449
- formatExprJson(ctx, expr) {
450
- return this.formatExpr({ ...ctx, formatAsJson: true }, expr);
451
- }
452
- formatExprValue(ctx, expr) {
453
- return this.formatExpr({ ...ctx, formatAsJson: false }, expr);
454
- }
455
- retrieveField(expr, field) {
456
- switch (expr.type) {
457
- case ExprType.Record:
458
- return expr.fields[field];
459
- case ExprType.Merge:
460
- return this.retrieveField(expr.a, field) || this.retrieveField(expr.b, field);
461
- default:
462
- return void 0;
463
- }
464
- }
465
- formatField(ctx, expr, field) {
466
- const { stmt } = ctx;
467
- const fieldExpr = this.retrieveField(expr, field);
468
- if (fieldExpr)
469
- return this.formatExpr(ctx, fieldExpr);
470
- switch (expr.type) {
471
- case ExprType.Row:
472
- switch (expr.target.type) {
473
- case TargetType.Table:
474
- const column = expr.target.table.columns[field];
475
- const asBoolean = column?.type === ColumnType.Boolean && ctx.formatAsJson;
476
- const jsonColumn = column?.type === ColumnType.Json;
477
- const asJson = jsonColumn && ctx.formatAsJson;
478
- if (asJson) {
479
- stmt.raw("json");
480
- stmt.openParenthesis();
481
- }
482
- if (asBoolean)
483
- stmt.add(`json(iif(`);
484
- if (!ctx.skipTableName) {
485
- stmt.identifier(expr.target.table.alias || expr.target.table.name).raw(".");
486
- }
487
- stmt.identifier(field);
488
- if (asBoolean)
489
- stmt.add(`, 'true', 'false'))`);
490
- if (asJson)
491
- stmt.closeParenthesis();
492
- if (jsonColumn && !asJson)
493
- stmt.raw("->>'$'");
494
- return stmt;
495
- }
496
- default:
497
- return this.formatAccess(ctx, () => this.formatExpr(ctx, expr), field);
498
- }
499
- }
500
449
  formatString(ctx, input) {
501
450
  const { stmt } = ctx;
502
451
  return stmt.raw(this.escapeValue(String(input)));
@@ -548,164 +497,248 @@ var Formatter = class {
548
497
  return stmt;
549
498
  }
550
499
  }
551
- formatExpr({ formatAsIn, ...ctx }, expr) {
552
- const { stmt } = ctx;
500
+ formatExprJson(ctx, expr) {
501
+ return this.formatExpr({ ...ctx, formatAsJson: true }, expr);
502
+ }
503
+ formatExprValue(ctx, expr) {
504
+ return this.formatExpr({ ...ctx, formatAsJson: false }, expr);
505
+ }
506
+ formatExpr(ctx, expr) {
553
507
  switch (expr.type) {
554
508
  case ExprType.UnOp:
555
- switch (expr.op) {
556
- case UnOpType.IsNull:
557
- return this.formatExprValue(ctx, expr.expr).add("IS NULL");
558
- case UnOpType.Not:
559
- stmt.raw("NOT").openParenthesis();
560
- this.formatExprValue(ctx, expr.expr);
561
- return stmt.closeParenthesis();
562
- }
509
+ return this.formatUnOp(ctx, expr);
563
510
  case ExprType.BinOp:
564
- stmt.openParenthesis();
565
- this.formatExprValue(ctx, expr.a).add(binOps[expr.op]).space();
566
- const asIn = expr.op === BinOpType.In || expr.op === BinOpType.NotIn;
567
- this.formatExprValue({ ...ctx, formatAsIn: asIn }, expr.b);
568
- return stmt.closeParenthesis();
511
+ return this.formatBinOp(ctx, expr);
569
512
  case ExprType.Param:
570
- switch (expr.param.type) {
571
- case ParamType.Value:
572
- return this.formatValue(ctx, expr.param.value);
573
- case ParamType.Named:
574
- return stmt.param(expr.param);
575
- }
513
+ return this.formatParam(ctx, expr);
576
514
  case ExprType.Field:
577
- if (formatAsIn) {
578
- stmt.openParenthesis();
579
- stmt.raw("SELECT value FROM json_each");
580
- stmt.openParenthesis();
581
- this.formatExprJson(ctx, expr);
582
- stmt.closeParenthesis();
583
- return stmt.closeParenthesis();
584
- }
585
- return this.formatField(ctx, expr.expr, expr.field);
586
- case ExprType.Call: {
587
- if (expr.method === "cast") {
588
- const [e, type] = expr.params;
589
- const typeName = type.type === ExprType.Param && type.param.type === ParamType.Value && type.param.value;
590
- stmt.raw("cast").openParenthesis();
591
- this.formatExprValue(ctx, e).add("as").space();
592
- this.formatString(ctx, typeName);
593
- return stmt.closeParenthesis();
594
- } else if (expr.method === "exists") {
595
- stmt.raw("exists").space();
596
- return this.formatExprValue(ctx, expr.params[0]);
597
- } else {
598
- stmt.identifier(expr.method);
599
- for (const param of stmt.call(expr.params))
600
- this.formatExprValue(ctx, param);
601
- return stmt;
602
- }
603
- }
515
+ return this.formatField(ctx, expr);
516
+ case ExprType.Call:
517
+ return this.formatCall(ctx, expr);
604
518
  case ExprType.Query:
605
- if (!ctx.formatAsJson) {
606
- stmt.openParenthesis();
607
- this.format(ctx, expr.query);
608
- return stmt.closeParenthesis();
609
- }
610
- if (expr.query.singleResult) {
611
- stmt.openParenthesis();
612
- this.format({ ...ctx, topLevel: true }, expr.query);
613
- return stmt.closeParenthesis().raw(`->'$.result'`);
614
- }
615
- stmt.openParenthesis().raw(`SELECT json_group_array(result->'$.result')`).newline().raw("FROM").space().openParenthesis();
616
- this.format({ ...ctx, topLevel: true }, expr.query);
617
- return stmt.closeParenthesis().closeParenthesis();
519
+ return this.formatQuery(ctx, expr);
618
520
  case ExprType.Row:
619
- switch (expr.target.type) {
620
- case TargetType.Table:
621
- const table = Target.source(expr.target);
622
- if (!table)
623
- throw new Error(`Cannot select empty target`);
624
- if (ctx.tableAsExpr)
625
- return stmt.identifier(table.alias || table.name);
626
- stmt.identifier("json_object");
627
- for (const [key, column] of stmt.call(
628
- Object.entries(table.columns)
629
- )) {
630
- this.formatString(ctx, key).raw(", ");
631
- this.formatField(ctx, expr, column.name);
632
- }
633
- return stmt;
634
- case TargetType.Query:
635
- case TargetType.Expr:
636
- return stmt.identifier(expr.target.alias).raw(".value");
637
- default:
638
- throw new Error(`Cannot select from ${expr.target.type}`);
639
- }
521
+ return this.formatRow(ctx, expr);
640
522
  case ExprType.Merge:
641
- stmt.identifier("json_patch").openParenthesis();
642
- this.formatExpr({ ...ctx, formatAsJson: true }, expr.a);
643
- stmt.raw(", ");
644
- this.formatExpr({ ...ctx, formatAsJson: true }, expr.b);
523
+ return this.formatMerge(ctx, expr);
524
+ case ExprType.Record:
525
+ return this.formatRecord(ctx, expr);
526
+ case ExprType.Filter:
527
+ return this.formatFilter(ctx, expr);
528
+ case ExprType.Map:
529
+ return this.formatMap(ctx, expr);
530
+ }
531
+ }
532
+ formatUnOp(ctx, expr) {
533
+ const { stmt } = ctx;
534
+ switch (expr.op) {
535
+ case UnOpType.IsNull:
536
+ return this.formatExprValue(ctx, expr.expr).add("IS NULL");
537
+ case UnOpType.Not:
538
+ stmt.raw("NOT").openParenthesis();
539
+ this.formatExprValue(ctx, expr.expr);
645
540
  return stmt.closeParenthesis();
541
+ }
542
+ }
543
+ formatBinOp(ctx, expr) {
544
+ const { stmt } = ctx;
545
+ stmt.openParenthesis();
546
+ this.formatExprValue(ctx, expr.a).add(binOps[expr.op]).space();
547
+ const asIn = expr.op === BinOpType.In || expr.op === BinOpType.NotIn;
548
+ this.formatExprValue({ ...ctx, formatAsIn: asIn }, expr.b);
549
+ return stmt.closeParenthesis();
550
+ }
551
+ formatParam(ctx, expr) {
552
+ const { stmt } = ctx;
553
+ switch (expr.param.type) {
554
+ case ParamType.Value:
555
+ return this.formatValue(ctx, expr.param.value);
556
+ case ParamType.Named:
557
+ return stmt.param(expr.param);
558
+ }
559
+ }
560
+ retrieveField(expr, field) {
561
+ switch (expr.type) {
646
562
  case ExprType.Record:
647
- if (ctx.selectAsColumns) {
648
- const inner = { ...ctx, selectAsColumns: false };
649
- for (const [key, value] of stmt.separate(
650
- Object.entries(expr.fields)
651
- )) {
652
- this.formatExprJson(inner, value);
653
- }
654
- return stmt;
563
+ return expr.fields[field];
564
+ case ExprType.Merge:
565
+ return this.retrieveField(expr.a, field) || this.retrieveField(expr.b, field);
566
+ default:
567
+ return void 0;
568
+ }
569
+ }
570
+ formatFieldOf(ctx, from, field) {
571
+ const { stmt } = ctx;
572
+ const fieldExpr = this.retrieveField(from, field);
573
+ if (fieldExpr)
574
+ return this.formatExpr(ctx, fieldExpr);
575
+ switch (from.type) {
576
+ case ExprType.Row:
577
+ switch (from.target.type) {
578
+ case TargetType.Table:
579
+ const column = from.target.table.columns[field];
580
+ const asBoolean = column?.type === ColumnType.Boolean && ctx.formatAsJson;
581
+ const jsonColumn = column?.type === ColumnType.Json;
582
+ const asJson = jsonColumn && ctx.formatAsJson;
583
+ if (asJson) {
584
+ stmt.raw("json");
585
+ stmt.openParenthesis();
586
+ }
587
+ if (asBoolean)
588
+ stmt.add(`json(iif(`);
589
+ if (!ctx.skipTableName) {
590
+ stmt.identifier(from.target.table.alias || from.target.table.name).raw(".");
591
+ }
592
+ stmt.identifier(field);
593
+ if (asBoolean)
594
+ stmt.add(`, 'true', 'false'))`);
595
+ if (asJson)
596
+ stmt.closeParenthesis();
597
+ if (jsonColumn && !asJson)
598
+ stmt.raw("->>'$'");
599
+ return stmt;
655
600
  }
656
- stmt.identifier("json_object").openParenthesis();
657
- for (const [key, value] of stmt.separate(Object.entries(expr.fields))) {
601
+ default:
602
+ return this.formatAccess(ctx, () => this.formatExpr(ctx, from), field);
603
+ }
604
+ }
605
+ formatField({ formatAsIn, ...ctx }, expr) {
606
+ const { stmt } = ctx;
607
+ if (formatAsIn) {
608
+ stmt.openParenthesis();
609
+ stmt.raw("SELECT value FROM json_each");
610
+ stmt.openParenthesis();
611
+ this.formatExprJson(ctx, expr);
612
+ stmt.closeParenthesis();
613
+ return stmt.closeParenthesis();
614
+ }
615
+ return this.formatFieldOf(ctx, expr.expr, expr.field);
616
+ }
617
+ formatCall(ctx, expr) {
618
+ const { stmt } = ctx;
619
+ if (expr.method === "cast") {
620
+ const [e, type] = expr.params;
621
+ const typeName = type.type === ExprType.Param && type.param.type === ParamType.Value && type.param.value;
622
+ stmt.raw("CAST").openParenthesis();
623
+ this.formatExprValue(ctx, e).add("AS").space();
624
+ this.formatString(ctx, typeName);
625
+ return stmt.closeParenthesis();
626
+ } else if (expr.method === "exists") {
627
+ stmt.raw("EXISTS").space();
628
+ return this.formatExprValue(ctx, expr.params[0]);
629
+ } else {
630
+ stmt.identifier(expr.method);
631
+ for (const param of stmt.call(expr.params))
632
+ this.formatExprValue(ctx, param);
633
+ return stmt;
634
+ }
635
+ }
636
+ formatQuery(ctx, expr) {
637
+ const { stmt } = ctx;
638
+ if (!ctx.formatAsJson) {
639
+ stmt.openParenthesis();
640
+ this.format(ctx, expr.query);
641
+ return stmt.closeParenthesis();
642
+ }
643
+ if (expr.query.singleResult) {
644
+ stmt.openParenthesis();
645
+ this.format({ ...ctx, topLevel: true }, expr.query);
646
+ return stmt.closeParenthesis().raw(`->'$.result'`);
647
+ }
648
+ stmt.openParenthesis().raw(`SELECT json_group_array(result->'$.result')`).newline().raw("FROM").space().openParenthesis();
649
+ this.format({ ...ctx, topLevel: true }, expr.query);
650
+ return stmt.closeParenthesis().closeParenthesis();
651
+ }
652
+ formatRow(ctx, expr) {
653
+ const { stmt } = ctx;
654
+ switch (expr.target.type) {
655
+ case TargetType.Table:
656
+ const table = Target.source(expr.target);
657
+ if (!table)
658
+ throw new Error(`Cannot select empty target`);
659
+ if (ctx.tableAsExpr)
660
+ return stmt.identifier(table.alias || table.name);
661
+ stmt.identifier("json_object");
662
+ for (const [key, column] of stmt.call(Object.entries(table.columns))) {
658
663
  this.formatString(ctx, key).raw(", ");
659
- this.formatExprJson(ctx, value);
664
+ this.formatFieldOf(ctx, expr, column.name);
665
+ }
666
+ return stmt;
667
+ case TargetType.Query:
668
+ case TargetType.Expr:
669
+ return stmt.identifier(expr.target.alias).raw(".value");
670
+ default:
671
+ throw new Error(`Cannot select from ${expr.target.type}`);
672
+ }
673
+ }
674
+ formatMerge(ctx, expr) {
675
+ const { stmt } = ctx;
676
+ stmt.identifier("json_patch").openParenthesis();
677
+ this.formatExpr({ ...ctx, formatAsJson: true }, expr.a);
678
+ stmt.raw(", ");
679
+ this.formatExpr({ ...ctx, formatAsJson: true }, expr.b);
680
+ return stmt.closeParenthesis();
681
+ }
682
+ formatRecord(ctx, expr) {
683
+ const { stmt } = ctx;
684
+ if (ctx.selectAsColumns) {
685
+ const inner = { ...ctx, selectAsColumns: false };
686
+ for (const [key, value] of stmt.separate(Object.entries(expr.fields))) {
687
+ this.formatExprJson(inner, value);
688
+ }
689
+ return stmt;
690
+ }
691
+ stmt.identifier("json_object").openParenthesis();
692
+ for (const [key, value] of stmt.separate(Object.entries(expr.fields))) {
693
+ this.formatString(ctx, key).raw(", ");
694
+ this.formatExprJson(ctx, value);
695
+ }
696
+ return stmt.closeParenthesis();
697
+ }
698
+ formatFilter({ formatAsIn, ...ctx }, expr) {
699
+ const { stmt } = ctx;
700
+ const { target, condition } = expr;
701
+ switch (target.type) {
702
+ case TargetType.Expr:
703
+ stmt.openParenthesis();
704
+ if (!formatAsIn) {
705
+ stmt.raw("SELECT json_group_array(json(result)) FROM ").openParenthesis();
706
+ }
707
+ stmt.raw("SELECT value AS result").add("FROM json_each").openParenthesis();
708
+ this.formatExpr(ctx, target.expr);
709
+ stmt.closeParenthesis();
710
+ if (target.alias)
711
+ stmt.add("AS").addIdentifier(target.alias);
712
+ stmt.add("WHERE").space();
713
+ this.formatExprValue(ctx, condition);
714
+ if (!formatAsIn) {
715
+ stmt.closeParenthesis();
660
716
  }
661
717
  return stmt.closeParenthesis();
662
- case ExprType.Filter: {
663
- const { target, condition } = expr;
664
- switch (target.type) {
665
- case TargetType.Expr:
666
- stmt.openParenthesis();
667
- if (!formatAsIn) {
668
- stmt.raw("SELECT json_group_array(json(result)) FROM ").openParenthesis();
669
- }
670
- stmt.raw("SELECT value AS result").add("FROM json_each").openParenthesis();
671
- this.formatExpr(ctx, target.expr);
672
- stmt.closeParenthesis();
673
- if (target.alias)
674
- stmt.add("AS").addIdentifier(target.alias);
675
- stmt.add("WHERE").space();
676
- this.formatExprValue(ctx, condition);
677
- if (!formatAsIn) {
678
- stmt.closeParenthesis();
679
- }
680
- return stmt.closeParenthesis();
681
- default:
682
- throw new Error("todo");
718
+ default:
719
+ throw new Error("todo");
720
+ }
721
+ }
722
+ formatMap({ formatAsIn, ...ctx }, expr) {
723
+ const { stmt } = ctx;
724
+ const { target, result } = expr;
725
+ switch (target.type) {
726
+ case TargetType.Expr:
727
+ stmt.openParenthesis();
728
+ if (!formatAsIn) {
729
+ stmt.raw("SELECT json_group_array(json(result)) FROM ").openParenthesis();
683
730
  }
684
- }
685
- case ExprType.Map: {
686
- const { target, result } = expr;
687
- switch (target.type) {
688
- case TargetType.Expr:
689
- stmt.openParenthesis();
690
- if (!formatAsIn) {
691
- stmt.raw("SELECT json_group_array(json(result)) FROM ").openParenthesis();
692
- }
693
- stmt.raw("SELECT").space();
694
- this.formatExpr(ctx, result).add("AS result").add("FROM json_each").openParenthesis();
695
- this.formatExprJson(ctx, target.expr);
696
- stmt.closeParenthesis();
697
- if (target.alias)
698
- stmt.add("AS").addIdentifier(target.alias);
699
- if (!formatAsIn) {
700
- stmt.closeParenthesis();
701
- }
702
- return stmt.closeParenthesis();
703
- default:
704
- throw new Error("todo");
731
+ stmt.raw("SELECT").space();
732
+ this.formatExpr(ctx, result).add("AS result").add("FROM json_each").openParenthesis();
733
+ this.formatExprJson(ctx, target.expr);
734
+ stmt.closeParenthesis();
735
+ if (target.alias)
736
+ stmt.add("AS").addIdentifier(target.alias);
737
+ if (!formatAsIn) {
738
+ stmt.closeParenthesis();
705
739
  }
706
- }
740
+ return stmt.closeParenthesis();
707
741
  default:
708
- console.log(expr);
709
742
  throw new Error("todo");
710
743
  }
711
744
  }
@@ -47,7 +47,7 @@ var Statement = class {
47
47
  return this.space().identifier(name);
48
48
  }
49
49
  value(value) {
50
- this.paramData.push(ParamData.Value(value));
50
+ this.paramData.push(new ParamData.Value(value));
51
51
  return this.raw(INSERT_PARAM);
52
52
  }
53
53
  addValue(value) {
@@ -7,5 +7,5 @@ export declare class SqliteFormatter extends Formatter {
7
7
  escapeIdentifier(input: string): string;
8
8
  escapeString(input: string): string;
9
9
  formatAccess(ctx: FormatContext, mkSubject: () => void, field: string): Statement;
10
- formatExpr(ctx: FormatContext, expr: ExprData): Statement;
10
+ formatCall(ctx: FormatContext, expr: ExprData.Call): Statement;
11
11
  }
@@ -1,5 +1,4 @@
1
1
  // src/sqlite/SqliteFormatter.ts
2
- import { ExprType } from "../define/Expr.js";
3
2
  import { Formatter } from "../lib/Formatter.js";
4
3
  var BACKTICK = "`";
5
4
  var ESCAPE_BACKTICK = "``";
@@ -42,26 +41,23 @@ var SqliteFormatter = class extends Formatter {
42
41
  stmt.raw(formatAsJson ? "->" : "->>");
43
42
  return this.formatString(ctx, `$.${field}`);
44
43
  }
45
- formatExpr(ctx, expr) {
44
+ formatCall(ctx, expr) {
46
45
  const { stmt } = ctx;
47
- switch (expr.type) {
48
- case ExprType.Call:
49
- switch (expr.method) {
50
- case "match":
51
- const [from, query] = expr.params;
52
- this.formatExprValue({ ...ctx, tableAsExpr: true }, from);
53
- stmt.raw(" MATCH ");
54
- this.formatExprValue(ctx, query);
55
- return stmt;
56
- case "highlight":
57
- case "snippet":
58
- stmt.identifier(expr.method);
59
- for (const param of stmt.call(expr.params))
60
- this.formatExprValue({ ...ctx, tableAsExpr: true }, param);
61
- return stmt;
62
- }
46
+ switch (expr.method) {
47
+ case "match":
48
+ const [from, query] = expr.params;
49
+ this.formatExprValue({ ...ctx, tableAsExpr: true }, from);
50
+ stmt.raw(" MATCH ");
51
+ this.formatExprValue(ctx, query);
52
+ return stmt;
53
+ case "highlight":
54
+ case "snippet":
55
+ stmt.identifier(expr.method);
56
+ for (const param of stmt.call(expr.params))
57
+ this.formatExprValue({ ...ctx, tableAsExpr: true }, param);
58
+ return stmt;
63
59
  default:
64
- return super.formatExpr(ctx, expr);
60
+ return super.formatCall(ctx, expr);
65
61
  }
66
62
  }
67
63
  };
@@ -1,5 +1,5 @@
1
- import { Cursor } from '../define/Cursor';
2
1
  import { EV, Expr } from '../define/Expr';
2
+ import { Query } from '../define/Query';
3
3
  import { Table } from '../define/Table';
4
4
  export declare const SqliteFunctions: SqliteFunctions;
5
5
  export type SqliteFunctions = {
@@ -10,7 +10,7 @@ export type SqliteFunctions = {
10
10
  /**
11
11
  * The EXISTS operator always evaluates to one of the integer values 0 and 1. If executing the SELECT statement specified as the right-hand operand of the EXISTS operator would return one or more rows, then the EXISTS operator evaluates to 1. If executing the SELECT would return no rows at all, then the EXISTS operator evaluates to 0.
12
12
  */
13
- exists(cursor: Cursor<any>): Expr<boolean>;
13
+ exists(cursor: Query<any>): Expr<boolean>;
14
14
  /** Use the match operator for the FTS5 module */
15
15
  match(table: Table<any>, searchTerm: EV<string>): Expr<boolean>;
16
16
  /** The highlight() function returns a copy of the text from a specified column of the current row with extra markup text inserted to mark the start and end of phrase matches. */
@@ -157,7 +157,7 @@ export type SqliteFunctions = {
157
157
  julianday(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
158
158
  strftime(format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
159
159
  };
160
- export declare const count: (x?: Expr<any>) => Expr<number>, iif: <T>(x: EV<boolean>, y: EV<T>, z: EV<T>) => Expr<T>, exists: (cursor: Cursor<any>) => Expr<boolean>, match: (table: Table<any>, searchTerm: EV<string>) => Expr<boolean>, highlight: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>) => Expr<string>, snippet: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>) => Expr<string>, cast: {
160
+ export declare const count: (x?: Expr<any>) => Expr<number>, iif: <T>(x: EV<boolean>, y: EV<T>, z: EV<T>) => Expr<T>, exists: (cursor: Query<any>) => Expr<boolean>, match: (table: Table<any>, searchTerm: EV<string>) => Expr<boolean>, highlight: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>) => Expr<string>, snippet: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>) => Expr<string>, cast: {
161
161
  (x: EV<any>, type: 'text'): Expr<string>;
162
162
  (x: EV<any>, type: 'real'): Expr<number>;
163
163
  (x: EV<any>, type: 'integer'): Expr<number>;
@@ -1,5 +1,5 @@
1
- import { Cursor } from '../define/Cursor';
2
1
  import { Expr } from '../define/Expr';
2
+ import { Query } from '../define/Query';
3
3
  import { SchemaInstructions } from '../define/Schema';
4
4
  export declare namespace SqliteSchema {
5
5
  type Column = {
@@ -17,8 +17,8 @@ export declare namespace SqliteSchema {
17
17
  rootpage: number;
18
18
  sql: string;
19
19
  }
20
- function tableData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Column>>;
21
- function indexData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Index>>;
20
+ function tableData(tableName: Expr<string>): Query<Array<SqliteSchema.Column>>;
21
+ function indexData(tableName: Expr<string>): Query<Array<SqliteSchema.Index>>;
22
22
  function createInstructions(columnData: Array<Column>, indexData: Array<Index>): SchemaInstructions | undefined;
23
23
  function columnInstruction(column: Column): [string, string];
24
24
  function indexInstruction(index: Index): [string, string];
@@ -1,16 +1,16 @@
1
1
  // src/sqlite/SqliteSchema.ts
2
- import { Cursor } from "../define/Cursor.js";
2
+ import { Query } from "../define/Query.js";
3
3
  import { Statement } from "../lib/Statement.js";
4
4
  import { SqliteFormatter } from "./SqliteFormatter.js";
5
5
  var SqliteSchema;
6
6
  ((SqliteSchema2) => {
7
7
  const formatter = new SqliteFormatter();
8
8
  function tableData(tableName) {
9
- return Cursor.all`select * from pragma_table_info(${tableName}) order by cid`;
9
+ return Query.all`select * from pragma_table_info(${tableName}) order by cid`;
10
10
  }
11
11
  SqliteSchema2.tableData = tableData;
12
12
  function indexData(tableName) {
13
- return Cursor.all`select * from sqlite_master where type='index' and tbl_name=${tableName}`;
13
+ return Query.all`select * from sqlite_master where type='index' and tbl_name=${tableName}`;
14
14
  }
15
15
  SqliteSchema2.indexData = indexData;
16
16
  function createInstructions(columnData, indexData2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "better-sqlite3": "^7.5.1",
40
40
  "bun-types": "^0.5.0",
41
41
  "cross-env": "^7.0.3",
42
- "esbuild": "^0.17.7",
42
+ "esbuild": "^0.17.10",
43
43
  "glob": "^8.0.3",
44
44
  "rimraf": "^4.1.2",
45
45
  "sade": "^1.8.1",
@@ -47,7 +47,7 @@
47
47
  "sql.js": "^1.8.0",
48
48
  "sqlite3": "^5.1.4",
49
49
  "tsx": "^3.12.3",
50
- "typescript": "next",
50
+ "typescript": "beta",
51
51
  "uvu": "^0.5.6"
52
52
  },
53
53
  "volta": {
@@ -55,6 +55,6 @@
55
55
  },
56
56
  "packageManager": "yarn@3.3.1",
57
57
  "resolutions": {
58
- "esbuild": "0.17.7"
58
+ "esbuild": "0.17.10"
59
59
  }
60
60
  }