@zeit/cosmosdb-query
Advanced tools
Comparing version 0.3.1 to 0.4.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// @ts-ignore | ||
const parser_1 = require("./parser"); // eslint-disable-line import/no-unresolved | ||
const typeOf = (v) => { | ||
@@ -21,3 +23,3 @@ const t = typeof v; | ||
: a.length !== requiredTypes.length) { | ||
throw new Error(`The ${name} function requires ${isVariable ? "at least " : ""}${requiredTypes.length} argument(s)`); | ||
throw new parser_1.SyntaxError(`The ${name} function requires ${isVariable ? "at least " : ""}${requiredTypes.length} argument(s)`); | ||
} | ||
@@ -24,0 +26,0 @@ if (!types.every((t, i) => t.type === "any" || |
@@ -0,1 +1,2 @@ | ||
import { SyntaxError } from "./parser"; | ||
declare class Query { | ||
@@ -26,1 +27,2 @@ _query: string; | ||
export default _default; | ||
export { SyntaxError }; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const parser_1 = require("./parser"); // eslint-disable-line import/no-unresolved | ||
exports.SyntaxError = parser_1.SyntaxError; | ||
const transformer_1 = require("./transformer"); | ||
@@ -11,0 +12,0 @@ class Query { |
@@ -5,2 +5,4 @@ "use strict"; | ||
const aggregateFunctions = require("./aggregate-functions"); | ||
// @ts-ignore | ||
const parser_1 = require("./parser"); // eslint-disable-line import/no-unresolved | ||
function transform(ctx, node) { | ||
@@ -732,6 +734,6 @@ // eslint-disable-next-line no-use-before-define | ||
if (!ctx.document) { | ||
throw new SyntaxError("'SELECT *' is not valid if FROM clause is omitted."); | ||
throw new parser_1.SyntaxError("'SELECT *' is not valid if FROM clause is omitted."); | ||
} | ||
if (ctx.document.properties.length > 1) { | ||
throw new SyntaxError("'SELECT *' is only valid with a single input set."); | ||
throw new parser_1.SyntaxError("'SELECT *' is only valid with a single input set."); | ||
} | ||
@@ -816,3 +818,3 @@ } | ||
if (expressions.length > 1) { | ||
throw new Error("Multiple order-by items are not supported. Please specify a single order-by items."); | ||
throw new parser_1.SyntaxError("Multiple order-by items are not supported. Please specify a single order-by items."); | ||
} | ||
@@ -824,3 +826,3 @@ ctx.orderBy = transform(ctx, expressions[0]); | ||
if (expression.type !== "scalar_member_expression") { | ||
throw new Error("Unsupported ORDER BY clause. ORDER BY item expression could not be mapped to a document path."); | ||
throw new parser_1.SyntaxError("Unsupported ORDER BY clause. ORDER BY item expression could not be mapped to a document path."); | ||
} | ||
@@ -827,0 +829,0 @@ const node = transform(ctx, expression); |
{ | ||
"name": "@zeit/cosmosdb-query", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "A SQL parser and executer for Cosmos DB", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -94,5 +94,19 @@ # cosmosdb-query | ||
## Class: SyntaxError | ||
```js | ||
const { default: query, SyntaxError } = require("@zeit/cosmosdb-query"); | ||
try { | ||
query("INVALID SELECT").exec(items); | ||
} catch (err) { | ||
if (err instanceof SyntaxError) { | ||
console.error(err); | ||
} | ||
throw err; | ||
} | ||
``` | ||
## Supported queries | ||
All queries are supported except spatial functions |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226610
7394
112