Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@minatojs/driver-sqlite

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@minatojs/driver-sqlite - npm Package Compare versions

Comparing version 3.8.2 to 3.8.3

24

lib/index.js

@@ -94,2 +94,4 @@ "use strict";

this.evalOperators.$concat = (args) => `(${args.map((arg) => this.parseEval(arg)).join("||")})`;
this.evalOperators.$modulo = ([left, right]) => `modulo(${this.parseEval(left)}, ${this.parseEval(right)})`;
this.evalOperators.$log = ([left, right]) => (0, import_cosmokit.isNullable)(right) ? `log(${this.parseEval(left)})` : `log(${this.parseEval(left)}) / log(${this.parseEval(right)})`;
this.evalOperators.$length = (expr) => this.createAggr(expr, (value) => `count(${value})`, (value) => {

@@ -104,2 +106,8 @@ if (this.state.sqlType === "json") {

});
this.evalOperators.$number = (arg) => {
const value = this.parseEval(arg);
const res = this.state.sqlType === "raw" ? `cast(${this.parseEval(arg)} as double)` : `cast(${value} / 1000 as integer)`;
this.state.sqlType = "raw";
return `ifnull(${res}, 0)`;
};
this.define({

@@ -301,2 +309,4 @@ types: ["boolean"],

this.db.create_function("json_array_contains", (array, value) => +JSON.parse(array).includes(JSON.parse(value)));
this.db.create_function("modulo", (left, right) => left % right);
this.db.create_function("rand", () => Math.random());
}

@@ -426,6 +436,6 @@ async stop() {

stmt.free();
logger.debug("> %s", sql);
logger.debug("> %s", sql, params);
return result;
} catch (e) {
logger.warn("> %s", sql);
logger.warn("> %s", sql, params);
throw e;

@@ -471,3 +481,6 @@ }

const filter = this.sql.parseQuery(query);
__privateMethod(this, _run, run_fn).call(this, `UPDATE ${(0, import_sql_utils.escapeId)(table)} SET ${assignment} WHERE ${filter}`, updateFields.map((key) => row[key]));
__privateMethod(this, _run, run_fn).call(this, `UPDATE ${(0, import_sql_utils.escapeId)(table)} SET ${assignment} WHERE ${filter}`, updateFields.map((key) => {
var _a;
return (_a = row[key]) != null ? _a : null;
}));
return 1;

@@ -481,3 +494,6 @@ }, "#update");

const sql = `INSERT INTO ${(0, import_sql_utils.escapeId)(table)} (${__privateMethod(this, _joinKeys, joinKeys_fn).call(this, keys)}) VALUES (${Array(keys.length).fill("?").join(", ")})`;
return __privateMethod(this, _run, run_fn).call(this, sql, keys.map((key) => data[key]), () => __privateMethod(this, _get, get_fn).call(this, `SELECT last_insert_rowid() AS id`));
return __privateMethod(this, _run, run_fn).call(this, sql, keys.map((key) => {
var _a;
return (_a = data[key]) != null ? _a : null;
}), () => __privateMethod(this, _get, get_fn).call(this, `SELECT last_insert_rowid() AS id`));
}, "#create");

@@ -484,0 +500,0 @@ __name(_SQLiteDriver, "SQLiteDriver");

8

package.json
{
"name": "@minatojs/driver-sqlite",
"version": "3.8.2",
"version": "3.8.3",
"description": "SQLite Driver for Minato",

@@ -29,9 +29,9 @@ "main": "lib/index.js",

"peerDependencies": {
"@minatojs/core": "^2.7.0"
"@minatojs/core": "^2.8.0"
},
"devDependencies": {
"@minatojs/tests": "^1.8.2"
"@minatojs/tests": "^1.8.3"
},
"dependencies": {
"@minatojs/sql-utils": "^4.2.0",
"@minatojs/sql-utils": "^4.2.1",
"@minatojs/sql.js": "^3.1.0",

@@ -38,0 +38,0 @@ "cosmokit": "^1.5.1",

@@ -55,2 +55,6 @@ import { clone, deepEqual, Dict, difference, isNullable, makeArray } from 'cosmokit'

this.evalOperators.$concat = (args) => `(${args.map(arg => this.parseEval(arg)).join('||')})`
this.evalOperators.$modulo = ([left, right]) => `modulo(${this.parseEval(left)}, ${this.parseEval(right)})`
this.evalOperators.$log = ([left, right]) => isNullable(right)
? `log(${this.parseEval(left)})`
: `log(${this.parseEval(left)}) / log(${this.parseEval(right)})`
this.evalOperators.$length = (expr) => this.createAggr(expr, value => `count(${value})`, value => {

@@ -65,2 +69,9 @@ if (this.state.sqlType === 'json') {

})
this.evalOperators.$number = (arg) => {
const value = this.parseEval(arg)
const res = this.state.sqlType === 'raw' ? `cast(${this.parseEval(arg)} as double)`
: `cast(${value} / 1000 as integer)`
this.state.sqlType = 'raw'
return `ifnull(${res}, 0)`
}

@@ -273,2 +284,4 @@ this.define<boolean, number>({

this.db.create_function('json_array_contains', (array, value) => +(JSON.parse(array) as any[]).includes(JSON.parse(value)))
this.db.create_function('modulo', (left, right) => left % right)
this.db.create_function('rand', () => Math.random())
}

@@ -294,6 +307,6 @@

stmt.free()
logger.debug('> %s', sql)
logger.debug('> %s', sql, params)
return result
} catch (e) {
logger.warn('> %s', sql)
logger.warn('> %s', sql, params)
throw e

@@ -382,3 +395,3 @@ }

const filter = this.sql.parseQuery(query)
this.#run(`UPDATE ${escapeId(table)} SET ${assignment} WHERE ${filter}`, updateFields.map((key) => row[key]))
this.#run(`UPDATE ${escapeId(table)} SET ${assignment} WHERE ${filter}`, updateFields.map((key) => row[key] ?? null))
return 1

@@ -407,3 +420,3 @@ }

const sql = `INSERT INTO ${escapeId(table)} (${this.#joinKeys(keys)}) VALUES (${Array(keys.length).fill('?').join(', ')})`
return this.#run(sql, keys.map(key => data[key]), () => this.#get(`SELECT last_insert_rowid() AS id`))
return this.#run(sql, keys.map(key => data[key] ?? null), () => this.#get(`SELECT last_insert_rowid() AS id`))
}

@@ -410,0 +423,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc