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 4.4.0 to 4.4.1

8

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

@@ -40,9 +40,9 @@ "type": "module",

"peerDependencies": {
"minato": "^3.4.0"
"minato": "^3.4.1"
},
"devDependencies": {
"@minatojs/tests": "^2.4.0"
"@minatojs/tests": "^2.4.1"
},
"dependencies": {
"@minatojs/sql-utils": "^5.4.0",
"@minatojs/sql-utils": "^5.4.1",
"@minatojs/sql.js": "^3.1.0",

@@ -49,0 +49,0 @@ "cosmokit": "^1.6.2"

import { Binary, deepEqual, Dict, difference, isNullable, makeArray, mapValues } from 'cosmokit'
import { Driver, Eval, executeUpdate, Field, hasSubquery, isEvalExpr, Selection, z } from 'minato'
import { Driver, Eval, executeUpdate, Field, getCell, hasSubquery, isEvalExpr, Selection, z } from 'minato'
import { escapeId } from '@minatojs/sql-utils'

@@ -13,11 +13,2 @@ import { resolve } from 'node:path'

function getValue(obj: any, path: string) {
if (path.includes('.')) {
const index = path.indexOf('.')
return getValue(obj[path.slice(0, index)] ?? {}, path.slice(index + 1))
} else {
return obj[path]
}
}
function getTypeDef({ deftype: type }: Field) {

@@ -353,12 +344,16 @@ switch (type) {

const primaryFields = makeArray(primary)
if ((Object.keys(query).length === 1 && query.$expr) || hasSubquery(sel.query) || Object.values(update).some(x => hasSubquery(x))) {
if (query.$expr || hasSubquery(sel.query) || Object.values(update).some(x => hasSubquery(x))) {
const sel2 = this.database.select(table as never, query)
sel2.tables[sel.ref] = sel2.table[sel2.ref]
delete sel2.table[sel2.ref]
sel2.tables[sel.ref] = sel2.tables[sel2.ref]
delete sel2.tables[sel2.ref]
sel2.ref = sel.ref
const project = mapValues(update as any, (value, key) => () => (isEvalExpr(value) ? value : Eval.literal(value, model.getType(key))))
const rawUpsert = await sel2.project({ ...project, ...Object.fromEntries(primaryFields.map(x => [x, x])) } as any).execute()
const rawUpsert = await sel2.project({
...project,
// do not touch sel2.row since it is not patched
...Object.fromEntries(primaryFields.map(x => [x, () => Eval('', [sel.ref, x], sel2.model.getType(x)!)])),
}).execute()
const upsert = rawUpsert.map(row => ({
...mapValues(update, (_, key) => getValue(row, key)),
...Object.fromEntries(primaryFields.map(x => [x, getValue(row, x)])),
...mapValues(update, (_, key) => getCell(row, key)),
...Object.fromEntries(primaryFields.map(x => [x, getCell(row, x)])),
}))

@@ -365,0 +360,0 @@ return this.database.upsert(table, upsert)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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