@minatojs/sql-utils
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -21,3 +21,3 @@ "use strict"; | ||
// packages/sql-utils/src/index.ts | ||
// minato/packages/sql-utils/src/index.ts | ||
var src_exports = {}; | ||
@@ -42,6 +42,9 @@ __export(src_exports, { | ||
this.queryOperators = { | ||
// logical | ||
$or: (key, value) => this.logicalOr(value.map((value2) => this.parseFieldQuery(key, value2))), | ||
$and: (key, value) => this.logicalAnd(value.map((value2) => this.parseFieldQuery(key, value2))), | ||
$not: (key, value) => this.logicalNot(this.parseFieldQuery(key, value)), | ||
// existence | ||
$exists: (key, value) => this.createNullQuery(key, value), | ||
// comparison | ||
$eq: this.createEqualQuery, | ||
@@ -53,6 +56,9 @@ $ne: this.comparator("!="), | ||
$lte: this.comparator("<="), | ||
// membership | ||
$in: (key, value) => this.createMemberQuery(key, value, ""), | ||
$nin: (key, value) => this.createMemberQuery(key, value, " NOT"), | ||
// regexp | ||
$regex: (key, value) => this.createRegExpQuery(key, value), | ||
$regexFor: (key, value) => `${this.escape(value)} regexp ${key}`, | ||
// bitwise | ||
$bitsAllSet: (key, value) => `${key} & ${this.escape(value)} = ${this.escape(value)}`, | ||
@@ -62,2 +68,3 @@ $bitsAllClear: (key, value) => `${key} & ${this.escape(value)} = 0`, | ||
$bitsAnyClear: (key, value) => `${key} & ${this.escape(value)} != ${this.escape(value)}`, | ||
// list | ||
$el: (key, value) => { | ||
@@ -79,5 +86,7 @@ if (Array.isArray(value)) { | ||
this.evalOperators = { | ||
// universal | ||
$: (key) => this.getRecursive(key), | ||
$if: (args) => `if(${args.map((arg) => this.parseEval(arg)).join(", ")})`, | ||
$ifNull: (args) => `ifnull(${args.map((arg) => this.parseEval(arg)).join(", ")})`, | ||
// number | ||
$add: (args) => `(${args.map((arg) => this.parseEval(arg)).join(" + ")})`, | ||
@@ -87,6 +96,9 @@ $multiply: (args) => `(${args.map((arg) => this.parseEval(arg)).join(" * ")})`, | ||
$divide: this.binary("/"), | ||
// string | ||
$concat: (args) => `concat(${args.map((arg) => this.parseEval(arg)).join(", ")})`, | ||
// logical | ||
$or: (args) => this.logicalOr(args.map((arg) => this.parseEval(arg))), | ||
$and: (args) => this.logicalAnd(args.map((arg) => this.parseEval(arg))), | ||
$not: (arg) => this.logicalNot(this.parseEval(arg)), | ||
// boolean | ||
$eq: this.binary("="), | ||
@@ -98,2 +110,3 @@ $ne: this.binary("!="), | ||
$lte: this.binary("<="), | ||
// aggregation | ||
$sum: (expr) => `ifnull(sum(${this.parseAggr(expr)}), 0)`, | ||
@@ -214,3 +227,3 @@ $avg: (expr) => `avg(${this.parseAggr(expr)})`, | ||
} | ||
const prefix = !this.tables || key in fields ? "" : `${escapeId(table)}.`; | ||
const prefix = !this.tables || key === "_" || key in fields ? "" : `${escapeId(table)}.`; | ||
return this.transformKey(key, fields, prefix); | ||
@@ -217,0 +230,0 @@ } |
{ | ||
"name": "@minatojs/sql-utils", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "SQL Utilities for Minato", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
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
45208
407