rado 0.1.58 → 0.1.60

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.
@@ -1,4 +1,5 @@
1
1
  import { Driver } from '../lib/Driver';
2
+ import { CompileOptions } from '../lib/Formatter';
2
3
  import { EV, Expr } from './Expr';
3
4
  import { OrderBy } from './OrderBy';
4
5
  import { Query } from './Query';
@@ -13,7 +14,7 @@ export declare class Cursor<T> {
13
14
  query(): Query<T>;
14
15
  on(driver: Driver.Sync): T;
15
16
  on(driver: Driver.Async): Promise<T>;
16
- compile(driver: Driver): import("..").Statement;
17
+ compile(driver: Driver, options?: CompileOptions): import("..").Statement;
17
18
  toJSON(): Query<T>;
18
19
  }
19
20
  export declare namespace Cursor {
@@ -24,8 +24,8 @@ var Cursor = class {
24
24
  on(driver) {
25
25
  return driver.executeQuery(this.query());
26
26
  }
27
- compile(driver) {
28
- return driver.formatter.compile(this.query());
27
+ compile(driver, options) {
28
+ return driver.formatter.compile(this.query(), options);
29
29
  }
30
30
  toJSON() {
31
31
  return this.query();
@@ -23,14 +23,16 @@ export interface FormatContext {
23
23
  topLevel?: boolean;
24
24
  }
25
25
  type FormatSubject = (stmt: Statement, mkSubject: () => void) => void;
26
+ export interface CompileOptions extends Partial<FormatContext>, StatementOptions {
27
+ }
26
28
  export declare abstract class Formatter implements Sanitizer {
27
29
  constructor();
28
30
  abstract escapeValue(value: any): string;
29
31
  abstract escapeIdentifier(ident: string): string;
30
32
  abstract formatParamValue(paramValue: any): any;
31
33
  abstract formatAccess(ctx: FormatContext, mkSubject: () => void, field: string): Statement;
32
- compile<T>(query: Query<T>, options?: Partial<FormatContext>): Statement;
33
- createContext(options?: Partial<FormatContext> & StatementOptions): {
34
+ compile<T>(query: Query<T>, options?: CompileOptions): Statement;
35
+ createContext(options?: CompileOptions): {
34
36
  stmt: Statement;
35
37
  nameResult?: string | undefined;
36
38
  skipTableName?: boolean | undefined;
@@ -116,10 +116,8 @@ var Formatter = class {
116
116
  const { stmt } = ctx;
117
117
  const data = query.set || {};
118
118
  stmt.add("UPDATE").addIdentifier(query.table.name).add("SET").space();
119
- for (const key of stmt.separate(Object.keys(data))) {
120
- const column = query.table.columns[key];
121
- if (!column)
122
- continue;
119
+ const keys = Object.keys(data).filter((key) => query.table.columns[key]);
120
+ for (const key of stmt.separate(keys)) {
123
121
  stmt.identifier(key).add("=").space();
124
122
  const value = data[key];
125
123
  if (value instanceof Expr)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.1.58",
3
+ "version": "0.1.60",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",