@malloydata/malloy 0.0.2 → 0.0.3
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 +12 -11
- package/dist/dialect/duckdb.d.ts +1 -1
- package/dist/dialect/duckdb.js +35 -37
- package/dist/dialect/postgres.d.ts +1 -1
- package/dist/dialect/postgres.js +15 -8
- package/dist/dialect/standardsql.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/lang/ast/apply-expr.js +2 -2
- package/dist/lang/ast/ast-expr.js +2 -12
- package/dist/lang/ast/ast-main.d.ts +2 -2
- package/dist/lang/ast/ast-main.js +2 -1
- package/dist/lang/field-space.d.ts +9 -7
- package/dist/lang/field-space.js +10 -8
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +108 -106
- package/dist/lang/lib/Malloy/MalloyLexer.js +1019 -1006
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +581 -590
- package/dist/lang/lib/Malloy/MalloyParser.js +1141 -1202
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2015 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1269 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
- package/dist/lang/parse-to-ast.d.ts +3 -4
- package/dist/lang/parse-to-ast.js +1 -1
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +2 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +2 -2
- package/dist/lang/test/field-symbols.spec.js +2 -2
- package/dist/lang/test/parse.spec.js +15 -0
- package/dist/lang/test/test-translator.js +1 -1
- package/dist/malloy.d.ts +1 -1
- package/dist/malloy.js +11 -5
- package/dist/md5.d.ts +1 -0
- package/dist/md5.js +30 -0
- package/dist/model/malloy_query.js +4 -6
- package/dist/model/malloy_types.d.ts +3 -1
- package/package.json +9 -14
- package/dist/dialect/dialect-map.d.ts +0 -3
- package/dist/dialect/dialect-map.js +0 -33
- package/dist/model/malloy-query.d.ts +0 -313
- package/dist/model/malloy-query.js +0 -2603
- package/dist/model/malloy-types.d.ts +0 -404
- package/dist/model/malloy-types.js +0 -242
- package/dist/model/sql-block.d.ts +0 -11
- package/dist/model/sql-block.js +0 -38
- package/dist/runtime-types.d.ts +0 -116
- package/dist/runtime-types.js +0 -40
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { ParserRuleContext } from "antlr4ts";
|
|
2
2
|
import type { ParseTree } from "antlr4ts/tree";
|
|
3
3
|
import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor";
|
|
4
|
-
import {
|
|
4
|
+
import { MalloyParserVisitor } from "./lib/Malloy/MalloyParserVisitor";
|
|
5
5
|
import * as parse from "./lib/Malloy/MalloyParser";
|
|
6
6
|
import * as ast from "./ast";
|
|
7
|
-
import { MessageLogger } from "./parse-log";
|
|
7
|
+
import { LogSeverity, MessageLogger } from "./parse-log";
|
|
8
8
|
import { MalloyParseRoot } from "./parse-malloy";
|
|
9
|
-
import { LogSeverity } from "./parse-log";
|
|
10
9
|
/**
|
|
11
10
|
* ANTLR visitor pattern parse tree traversal. Generates a Malloy
|
|
12
11
|
* AST from an ANTLR parse tree.
|
|
13
12
|
*/
|
|
14
|
-
export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElement> implements
|
|
13
|
+
export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElement> implements MalloyParserVisitor<ast.MalloyElement> {
|
|
15
14
|
readonly parse: MalloyParseRoot;
|
|
16
15
|
readonly msgLog: MessageLogger;
|
|
17
16
|
constructor(parse: MalloyParseRoot, msgLog: MessageLogger);
|
|
@@ -917,7 +917,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
917
917
|
return this.visitSQLStatementDef(pcx.sqlStatementDef());
|
|
918
918
|
}
|
|
919
919
|
visitSQLStatementDef(pcx) {
|
|
920
|
-
const commands = pcx.
|
|
920
|
+
const commands = pcx.SQL_STRING().text;
|
|
921
921
|
const sqlStmt = new ast.SQLStatement({
|
|
922
922
|
select: commands.slice(2, commands.length - 2),
|
|
923
923
|
connection: this.optionalText(pcx.connectionName()),
|
|
@@ -26,6 +26,7 @@ const EXPLORE_PROPERTIES = [
|
|
|
26
26
|
"accept",
|
|
27
27
|
"except",
|
|
28
28
|
"query",
|
|
29
|
+
"declare",
|
|
29
30
|
];
|
|
30
31
|
const QUERY_PROPERTIES = [
|
|
31
32
|
"group_by",
|
|
@@ -38,6 +39,7 @@ const QUERY_PROPERTIES = [
|
|
|
38
39
|
"where",
|
|
39
40
|
"having",
|
|
40
41
|
"nest",
|
|
42
|
+
"declare",
|
|
41
43
|
];
|
|
42
44
|
const MODEL_PROPERTIES = ["source", "explore", "query", "sql"];
|
|
43
45
|
class DocumentCompletionWalker {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonTokenStream } from "antlr4ts";
|
|
2
2
|
import { ParseTree } from "antlr4ts/tree";
|
|
3
|
-
import {
|
|
3
|
+
import { MalloyParserListener } from "../lib/Malloy/MalloyParserListener";
|
|
4
4
|
declare type SimpleRange = [number | undefined, number | undefined];
|
|
5
5
|
export interface FilterRef {
|
|
6
6
|
text: string;
|
|
@@ -19,7 +19,7 @@ export interface ExploreClauseRef {
|
|
|
19
19
|
filterLists: FilterList[];
|
|
20
20
|
range: SimpleRange;
|
|
21
21
|
}
|
|
22
|
-
export declare class ExploreQueryWalker implements
|
|
22
|
+
export declare class ExploreQueryWalker implements MalloyParserListener {
|
|
23
23
|
tokens: CommonTokenStream;
|
|
24
24
|
exploreClauseRefs: ExploreClauseRef[];
|
|
25
25
|
currentExploreClauseRef: ExploreClauseRef | undefined;
|
|
@@ -25,7 +25,7 @@ describe("structdef comprehension", () => {
|
|
|
25
25
|
type: "struct",
|
|
26
26
|
name: "test",
|
|
27
27
|
dialect: "standardsql",
|
|
28
|
-
structSource: { type: "table" },
|
|
28
|
+
structSource: { type: "table", tablePath: "test" },
|
|
29
29
|
structRelationship: { type: "basetable", connectionName: "test" },
|
|
30
30
|
fields: [field],
|
|
31
31
|
};
|
|
@@ -122,7 +122,7 @@ describe("structdef comprehension", () => {
|
|
|
122
122
|
{ type: "field", path: "t.a" },
|
|
123
123
|
],
|
|
124
124
|
},
|
|
125
|
-
structSource: { type: "table" },
|
|
125
|
+
structSource: { type: "table", tablePath: "t" },
|
|
126
126
|
fields: [{ type: "string", name: "a" }],
|
|
127
127
|
};
|
|
128
128
|
const struct = mkStructDef(field);
|
|
@@ -1124,6 +1124,21 @@ describe("error handling", () => {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
`).compileToFailWith("Output already has a field named 'astr'");
|
|
1126
1126
|
});
|
|
1127
|
+
test("rejoin a query is renamed", modelOK(`
|
|
1128
|
+
source: querySrc is from(
|
|
1129
|
+
table('malloytest.flights')->{
|
|
1130
|
+
group_by: origin
|
|
1131
|
+
nest: nested is { group_by: destination }
|
|
1132
|
+
}
|
|
1133
|
+
)
|
|
1134
|
+
|
|
1135
|
+
source: refineQuerySrc is querySrc {
|
|
1136
|
+
join_one: rejoin is querySrc on 7=8
|
|
1137
|
+
query: broken is {
|
|
1138
|
+
group_by: rejoin.nested.destination
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
`));
|
|
1127
1142
|
});
|
|
1128
1143
|
function getSelectOneStruct(sqlBlock) {
|
|
1129
1144
|
return {
|
|
@@ -27,7 +27,7 @@ const mockSchema = {
|
|
|
27
27
|
type: "struct",
|
|
28
28
|
name: "aTable",
|
|
29
29
|
dialect: "standardsql",
|
|
30
|
-
structSource: { type: "table" },
|
|
30
|
+
structSource: { type: "table", tablePath: "aTable" },
|
|
31
31
|
structRelationship: { type: "basetable", connectionName: "test" },
|
|
32
32
|
fields: [
|
|
33
33
|
{ type: "string", name: "astr" },
|
package/dist/malloy.d.ts
CHANGED
|
@@ -218,7 +218,7 @@ export declare class PreparedQuery {
|
|
|
218
218
|
get preparedResult(): PreparedResult;
|
|
219
219
|
get dialect(): string;
|
|
220
220
|
}
|
|
221
|
-
export declare function
|
|
221
|
+
export declare function parseTableURI(tableURI: string): {
|
|
222
222
|
connectionName?: string;
|
|
223
223
|
tablePath: string;
|
|
224
224
|
};
|
package/dist/malloy.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* GNU General Public License for more details.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CSVWriter = exports.JSONWriter = exports.DataWriter = exports.DataRecord = exports.DataArray = exports.Result = exports.ExploreMaterializer = exports.SQLBlockMaterializer = exports.PreparedResultMaterializer = exports.QueryMaterializer = exports.ModelMaterializer = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.Runtime = exports.ExploreField = exports.JoinRelationship = exports.QueryField = exports.Query = exports.StringField = exports.BooleanField = exports.NumberField = exports.TimestampField = exports.DateField = exports.TimestampTimeframe = exports.DateTimeframe = exports.AtomicField = exports.AtomicFieldType = exports.Explore = exports.SourceRelationship = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.PreparedResult = exports.DocumentCompletion = exports.DocumentSymbol = exports.DocumentPosition = exports.DocumentRange = exports.DocumentHighlight = exports.Parse = exports.
|
|
15
|
+
exports.CSVWriter = exports.JSONWriter = exports.DataWriter = exports.DataRecord = exports.DataArray = exports.Result = exports.ExploreMaterializer = exports.SQLBlockMaterializer = exports.PreparedResultMaterializer = exports.QueryMaterializer = exports.ModelMaterializer = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.Runtime = exports.ExploreField = exports.JoinRelationship = exports.QueryField = exports.Query = exports.StringField = exports.BooleanField = exports.NumberField = exports.TimestampField = exports.DateField = exports.TimestampTimeframe = exports.DateTimeframe = exports.AtomicField = exports.AtomicFieldType = exports.Explore = exports.SourceRelationship = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.PreparedResult = exports.DocumentCompletion = exports.DocumentSymbol = exports.DocumentPosition = exports.DocumentRange = exports.DocumentHighlight = exports.Parse = exports.parseTableURI = exports.PreparedQuery = exports.Model = exports.MalloyError = exports.Malloy = void 0;
|
|
16
16
|
const lang_1 = require("./lang");
|
|
17
17
|
const model_1 = require("./model");
|
|
18
18
|
class Malloy {
|
|
@@ -99,7 +99,7 @@ class Malloy {
|
|
|
99
99
|
// collect tables by connection name since there may be multiple connections
|
|
100
100
|
const tablesByConnection = new Map();
|
|
101
101
|
for (const connectionTableString of result.tables) {
|
|
102
|
-
const { connectionName } =
|
|
102
|
+
const { connectionName } = parseTableURI(connectionTableString);
|
|
103
103
|
let connectionToTablesMap = tablesByConnection.get(connectionName);
|
|
104
104
|
if (!connectionToTablesMap) {
|
|
105
105
|
connectionToTablesMap = [connectionTableString];
|
|
@@ -136,6 +136,9 @@ class Malloy {
|
|
|
136
136
|
const sqlRefsByConnection = new Map();
|
|
137
137
|
for (const missingSQLSchemaRef of result.sqlStructs) {
|
|
138
138
|
const connectionName = missingSQLSchemaRef.connection;
|
|
139
|
+
// if (connectionName === undefined) {
|
|
140
|
+
// throw new Error("Oops have not made it required here yet...");
|
|
141
|
+
// }
|
|
139
142
|
let connectionToSQLReferencesMap = sqlRefsByConnection.get(connectionName);
|
|
140
143
|
if (!connectionToSQLReferencesMap) {
|
|
141
144
|
connectionToSQLReferencesMap = [missingSQLSchemaRef];
|
|
@@ -434,8 +437,8 @@ class PreparedQuery {
|
|
|
434
437
|
}
|
|
435
438
|
}
|
|
436
439
|
exports.PreparedQuery = PreparedQuery;
|
|
437
|
-
function
|
|
438
|
-
const [firstPart, secondPart] =
|
|
440
|
+
function parseTableURI(tableURI) {
|
|
441
|
+
const [firstPart, secondPart] = tableURI.split(":");
|
|
439
442
|
if (secondPart) {
|
|
440
443
|
return { connectionName: firstPart, tablePath: secondPart };
|
|
441
444
|
}
|
|
@@ -443,7 +446,7 @@ function parseTableURL(tableURL) {
|
|
|
443
446
|
return { tablePath: firstPart };
|
|
444
447
|
}
|
|
445
448
|
}
|
|
446
|
-
exports.
|
|
449
|
+
exports.parseTableURI = parseTableURI;
|
|
447
450
|
/**
|
|
448
451
|
* A parsed Malloy document.
|
|
449
452
|
*/
|
|
@@ -2066,6 +2069,9 @@ class DataTimestamp extends ScalarData {
|
|
|
2066
2069
|
if (this._value instanceof Date) {
|
|
2067
2070
|
return this._value;
|
|
2068
2071
|
}
|
|
2072
|
+
else if (typeof this._value === "number") {
|
|
2073
|
+
return new Date(super.value);
|
|
2074
|
+
}
|
|
2069
2075
|
else if (typeof this._value !== "string") {
|
|
2070
2076
|
return new Date(this._value.value);
|
|
2071
2077
|
}
|
package/dist/md5.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const md5: (val: string) => string;
|
package/dist/md5.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.md5 = void 0;
|
|
27
|
+
const crypto = __importStar(require("crypto"));
|
|
28
|
+
const md5 = (val) => crypto.createHash("md5").update(val).digest("hex");
|
|
29
|
+
exports.md5 = md5;
|
|
30
|
+
//# sourceMappingURL=md5.js.map
|
|
@@ -21,7 +21,6 @@ const standardsql_1 = require("../dialect/standardsql");
|
|
|
21
21
|
const dialect_1 = require("../dialect");
|
|
22
22
|
const malloy_types_1 = require("./malloy_types");
|
|
23
23
|
const utils_1 = require("./utils");
|
|
24
|
-
const malloy_1 = require("../malloy");
|
|
25
24
|
const md5_1 = __importDefault(require("md5"));
|
|
26
25
|
// quote a string for SQL use. Perhaps should be in dialect.
|
|
27
26
|
function generateSQLStringLiteral(sourceString) {
|
|
@@ -769,7 +768,7 @@ class FieldInstanceResult {
|
|
|
769
768
|
addStructToJoin(qs, query, mayNeedUniqueKey, joinStack) {
|
|
770
769
|
var _a;
|
|
771
770
|
const name = qs.getIdentifier();
|
|
772
|
-
// we're already chasing the
|
|
771
|
+
// we're already chasing the dependency for this join.
|
|
773
772
|
if (joinStack.indexOf(name) !== -1) {
|
|
774
773
|
return;
|
|
775
774
|
}
|
|
@@ -1576,8 +1575,7 @@ class QueryQuery extends QueryField {
|
|
|
1576
1575
|
type: "basetable",
|
|
1577
1576
|
connectionName: this.parent.connectionName,
|
|
1578
1577
|
},
|
|
1579
|
-
|
|
1580
|
-
structSource: { type: "table" },
|
|
1578
|
+
structSource: { type: "query_result" },
|
|
1581
1579
|
resultMetadata: this.getResultMetadata(this.rootResult),
|
|
1582
1580
|
type: "struct",
|
|
1583
1581
|
};
|
|
@@ -2359,7 +2357,7 @@ FROM ${resultStage}\n`);
|
|
|
2359
2357
|
type: "basetable",
|
|
2360
2358
|
connectionName: this.parent.connectionName,
|
|
2361
2359
|
},
|
|
2362
|
-
structSource: { type: "
|
|
2360
|
+
structSource: { type: "query_result" },
|
|
2363
2361
|
};
|
|
2364
2362
|
}
|
|
2365
2363
|
}
|
|
@@ -2654,7 +2652,7 @@ class QueryStruct extends QueryNode {
|
|
|
2654
2652
|
structSourceSQL(stageWriter) {
|
|
2655
2653
|
switch (this.fieldDef.structSource.type) {
|
|
2656
2654
|
case "table": {
|
|
2657
|
-
const
|
|
2655
|
+
const tablePath = this.fieldDef.structSource.tablePath;
|
|
2658
2656
|
return this.dialect.quoteTablePath(tablePath);
|
|
2659
2657
|
}
|
|
2660
2658
|
case "sql":
|
|
@@ -389,7 +389,7 @@ interface SubquerySource {
|
|
|
389
389
|
/** where does the struct come from? */
|
|
390
390
|
export declare type StructSource = {
|
|
391
391
|
type: "table";
|
|
392
|
-
tablePath
|
|
392
|
+
tablePath: string;
|
|
393
393
|
} | {
|
|
394
394
|
type: "nested";
|
|
395
395
|
} | {
|
|
@@ -400,6 +400,8 @@ export declare type StructSource = {
|
|
|
400
400
|
} | {
|
|
401
401
|
type: "sql";
|
|
402
402
|
method: "nested" | "lastStage";
|
|
403
|
+
} | {
|
|
404
|
+
type: "query_result";
|
|
403
405
|
} | SubquerySource;
|
|
404
406
|
/** struct that is intrinsic to the table */
|
|
405
407
|
export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "GPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"homepage": "https://github.com/looker-open-source/malloy#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/looker-open-source/malloy"
|
|
11
|
+
},
|
|
7
12
|
"scripts": {
|
|
8
13
|
"test": "jest --config=../../jest.config.js",
|
|
9
|
-
"build-parser": "
|
|
14
|
+
"build-parser": "node src/lang/grammar/build_parser.js",
|
|
10
15
|
"testLang": "npm run test --testPathPattern=packages/malloy/src/lang",
|
|
11
16
|
"clean": "rm -rf src/lang/lib",
|
|
12
17
|
"build": "npm run build-parser && tsc --build",
|
|
@@ -15,23 +20,13 @@
|
|
|
15
20
|
"dependencies": {
|
|
16
21
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
17
22
|
"assert": "^2.0.0",
|
|
18
|
-
"blueimp-md5": "^2.19.0",
|
|
19
23
|
"lodash": "^4.17.20",
|
|
20
24
|
"luxon": "^1.26.0",
|
|
21
|
-
"md5": "^2.3.0"
|
|
22
|
-
"url": "^0.11.0"
|
|
25
|
+
"md5": "^2.3.0"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@types/lodash": "^4.14.165",
|
|
26
29
|
"@types/luxon": "^1.26.4",
|
|
27
|
-
"antlr4ts-cli": "^0.5.0-alpha.4"
|
|
28
|
-
"path": "^0.12.7"
|
|
29
|
-
},
|
|
30
|
-
"cross-os": {
|
|
31
|
-
"build-parser": {
|
|
32
|
-
"darwin": "sh build-parser.sh",
|
|
33
|
-
"linux": "sh build-parser.sh",
|
|
34
|
-
"win32": "build-parser.cmd"
|
|
35
|
-
}
|
|
30
|
+
"antlr4ts-cli": "^0.5.0-alpha.4"
|
|
36
31
|
}
|
|
37
32
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.registerDialect = exports.getDialect = void 0;
|
|
16
|
-
const postgres_1 = require("./postgres");
|
|
17
|
-
const standardsql_1 = require("./standardsql");
|
|
18
|
-
const dialectMap = new Map();
|
|
19
|
-
function getDialect(name) {
|
|
20
|
-
const d = dialectMap.get(name);
|
|
21
|
-
if (d === undefined) {
|
|
22
|
-
throw new Error(`Unknown Dialect ${name}`);
|
|
23
|
-
}
|
|
24
|
-
return d;
|
|
25
|
-
}
|
|
26
|
-
exports.getDialect = getDialect;
|
|
27
|
-
function registerDialect(d) {
|
|
28
|
-
dialectMap.set(d.name, d);
|
|
29
|
-
}
|
|
30
|
-
exports.registerDialect = registerDialect;
|
|
31
|
-
registerDialect(new postgres_1.PostgresDialect());
|
|
32
|
-
registerDialect(new standardsql_1.StandardSQLDialect());
|
|
33
|
-
//# sourceMappingURL=dialect-map.js.map
|