@malloydata/malloy 0.0.10-dev221124165006 → 0.0.10-dev221128232158

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.
@@ -54,6 +54,7 @@ export declare abstract class Dialect {
54
54
  ignoreInProject(_fieldName: string): boolean;
55
55
  abstract sqlCast(cast: TypecastFragment): Expr;
56
56
  abstract sqlLiteralTime(timeString: string, type: TimeFieldType, timezone: string): string;
57
+ abstract sqlLiteralString(literak: string): string;
57
58
  abstract sqlRegexpMatch(expr: Expr, regex: string): Expr;
58
59
  getFunctionInfo(functionName: string): FunctionInfo | undefined;
59
60
  dialectExpr(df: DialectFragment): Expr;
@@ -58,6 +58,8 @@ class Dialect {
58
58
  }
59
59
  case "timeLiteral":
60
60
  return [this.sqlLiteralTime(df.literal, df.literalType, df.timezone)];
61
+ case "stringLiteral":
62
+ return [this.sqlLiteralString(df.literal)];
61
63
  }
62
64
  }
63
65
  sqlSumDistinct(_key, _value) {
@@ -46,4 +46,5 @@ export declare class DuckDBDialect extends Dialect {
46
46
  sqlSumDistinct(key: string, value: string): string;
47
47
  sqlSampleTable(tableSQL: string, sample: Sampling | undefined): string;
48
48
  sqlOrderBy(orderTerms: string[]): string;
49
+ sqlLiteralString(literal: string): string;
49
50
  }
@@ -342,6 +342,9 @@ class DuckDBDialect extends dialect_1.Dialect {
342
342
  sqlOrderBy(orderTerms) {
343
343
  return `ORDER BY ${orderTerms.map((t) => `${t} NULLS LAST`).join(",")}`;
344
344
  }
345
+ sqlLiteralString(literal) {
346
+ return "'" + literal.replace(/'/g, "''") + "'";
347
+ }
345
348
  }
346
349
  exports.DuckDBDialect = DuckDBDialect;
347
350
  //# sourceMappingURL=duckdb.js.map
@@ -46,4 +46,5 @@ export declare class PostgresDialect extends Dialect {
46
46
  sqlSumDistinct(key: string, value: string): string;
47
47
  sqlSampleTable(tableSQL: string, sample: Sampling | undefined): string;
48
48
  sqlOrderBy(orderTerms: string[]): string;
49
+ sqlLiteralString(literal: string): string;
49
50
  }
@@ -310,6 +310,9 @@ class PostgresDialect extends dialect_1.Dialect {
310
310
  sqlOrderBy(orderTerms) {
311
311
  return `ORDER BY ${orderTerms.map((t) => `${t} NULLS LAST`).join(",")}`;
312
312
  }
313
+ sqlLiteralString(literal) {
314
+ return "'" + literal.replace(/'/g, "''") + "'";
315
+ }
313
316
  }
314
317
  exports.PostgresDialect = PostgresDialect;
315
318
  //# sourceMappingURL=postgres.js.map
@@ -43,4 +43,5 @@ export declare class StandardSQLDialect extends Dialect {
43
43
  sqlLiteralTime(timeString: string, type: "date" | "timestamp", timezone: string): string;
44
44
  sqlMeasureTime(from: TimeValue, to: TimeValue, units: string): Expr;
45
45
  sqlSampleTable(tableSQL: string, sample: Sampling | undefined): string;
46
+ sqlLiteralString(literal: string): string;
46
47
  }
@@ -357,6 +357,10 @@ ${(0, utils_1.indent)(sql)}
357
357
  }
358
358
  return tableSQL;
359
359
  }
360
+ sqlLiteralString(literal) {
361
+ const noVirgule = literal.replace(/\\/g, "\\\\");
362
+ return "'" + noVirgule.replace(/'/g, "\\'") + "'";
363
+ }
360
364
  }
361
365
  exports.StandardSQLDialect = StandardSQLDialect;
362
366
  //# sourceMappingURL=standardsql.js.map
@@ -71,9 +71,9 @@ export declare class FieldDeclaration extends MalloyElement {
71
71
  export declare class TypeMistmatch extends Error {
72
72
  }
73
73
  export declare class ExprString extends ExpressionDef {
74
- readonly value: string;
75
74
  elementType: string;
76
- constructor(value: string);
75
+ value: string;
76
+ constructor(src: string);
77
77
  getExpression(_fs: FieldSpace): ExprValue;
78
78
  }
79
79
  export declare class ExprNumber extends ExpressionDef {
@@ -221,13 +221,24 @@ class TypeMistmatch extends Error {
221
221
  }
222
222
  exports.TypeMistmatch = TypeMistmatch;
223
223
  class ExprString extends ExpressionDef {
224
- constructor(value) {
224
+ constructor(src) {
225
225
  super();
226
- this.value = value;
227
226
  this.elementType = "string literal";
227
+ const bareStr = src.slice(1, -1);
228
+ const val = bareStr.replace(/\\(.)/g, "$1");
229
+ this.value = val;
228
230
  }
229
231
  getExpression(_fs) {
230
- return { ...index_1.FT.stringT, value: [this.value] };
232
+ return {
233
+ ...index_1.FT.stringT,
234
+ value: [
235
+ {
236
+ type: "dialect",
237
+ function: "stringLiteral",
238
+ literal: this.value,
239
+ },
240
+ ],
241
+ };
231
242
  }
232
243
  }
233
244
  exports.ExprString = ExprString;
@@ -1269,6 +1269,8 @@ class QueryQuery extends QueryField {
1269
1269
  break;
1270
1270
  case "timeLiteral":
1271
1271
  break;
1272
+ case "stringLiteral":
1273
+ break;
1272
1274
  case "timeDiff":
1273
1275
  expressions.push(expr.left.value, expr.right.value);
1274
1276
  break;
@@ -184,7 +184,11 @@ export interface TimeLiteralFragment extends DialectFragmentBase {
184
184
  literalType: TimeFieldType;
185
185
  timezone: string;
186
186
  }
187
- export declare type DialectFragment = DivFragment | TimeLiteralFragment | NowFragment | TimeDeltaFragment | TimeDiffFragment | TimeTruncFragment | TypecastFragment | TimeExtractFragment | RegexpMatchFragment;
187
+ export interface StringLiteralFragment extends DialectFragmentBase {
188
+ function: "stringLiteral";
189
+ literal: string;
190
+ }
191
+ export declare type DialectFragment = DivFragment | TimeLiteralFragment | NowFragment | TimeDeltaFragment | TimeDiffFragment | TimeTruncFragment | TypecastFragment | TimeExtractFragment | StringLiteralFragment | RegexpMatchFragment;
188
192
  export declare type Fragment = string | ApplyFragment | ApplyValueFragment | FieldFragment | ParameterFragment | FilterFragment | AggregateFragment | UngroupFragment | DialectFragment;
189
193
  export declare type Expr = Fragment[];
190
194
  export interface TypedValue {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.10-dev221124165006",
3
+ "version": "0.0.10-dev221128232158",
4
4
  "license": "GPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",