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

@soinlabs/db

Package Overview
Dependencies
Maintainers
6
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soinlabs/db - npm Package Compare versions

Comparing version 1.1.0-alpha.56 to 1.1.0-alpha.58

116

lib/typeOrm/TypeOrmQueryBuilder.js

@@ -364,26 +364,60 @@ /* eslint-disable no-await-in-loop */

case Op.in:
// TODO: Manage null inside array
queries.push({
condition: `${tableName}${parentKey} IN (:...${parentKey}${paramNumber})`,
params: {
[`${parentKey}${paramNumber++}`]: meta.columns[parentKey]
.transformer
? meta.columns[parentKey].transformer.to(value)
: value,
},
})
case Op.in: {
const newValue = meta.columns[parentKey].transformer
? meta.columns[parentKey].transformer.to(value)
: value
if (newValue.includes(null)) {
if (newValue.length > 1) {
queries.push({
condition: `${tableName}${parentKey} IN (:...${parentKey}${paramNumber}) OR ${tableName}${parentKey} IS NULL`,
params: {
[`${parentKey}${paramNumber++}`]: newValue.filter(
x => x !== null
),
},
})
} else {
queries.push({
condition: `${tableName}${parentKey} IS NULL`,
})
}
} else {
queries.push({
condition: `${tableName}${parentKey} IN (:...${parentKey}${paramNumber})`,
params: {
[`${parentKey}${paramNumber++}`]: newValue,
},
})
}
break
case Op.notIn:
queries.push({
condition: `${tableName}${parentKey} NOT IN (:...${parentKey}${paramNumber})`,
params: {
[`${parentKey}${paramNumber++}`]: meta.columns[parentKey]
.transformer
? meta.columns[parentKey].transformer.to(value)
: value,
},
})
}
case Op.notIn: {
const newValue = meta.columns[parentKey].transformer
? meta.columns[parentKey].transformer.to(value)
: value
if (newValue.includes(null)) {
if (newValue.length > 1) {
queries.push({
condition: `${tableName}${parentKey} NOT IN (:...${parentKey}${paramNumber}) OR ${tableName}${parentKey} IS NOT NULL`,
params: {
[`${parentKey}${paramNumber++}`]: newValue.filter(
x => x !== null
),
},
})
} else {
queries.push({
condition: `${tableName}${parentKey} IS NOT NULL`,
})
}
} else {
queries.push({
condition: `${tableName}${parentKey} NOT IN (:...${parentKey}${paramNumber})`,
params: {
[`${parentKey}${paramNumber++}`]: newValue,
},
})
}
break
}
case Op.between:

@@ -468,6 +502,5 @@ // TODO: Between check array of 2 elements

case Op.or: {
// TODO: OR interno
const heapStart = queries.length
for (const elem of value) {
buildQueriesInternal(null, elem)
buildQueriesInternal(parentKey, elem)
}

@@ -522,11 +555,28 @@ const heapEnd = queries.length

if (parentKey === null) {
// TODO: Manage null inside array
queries.push({
condition: `${tableName}${key} IN (:...${key}${paramNumber})`,
params: {
[`${key}${paramNumber++}`]: meta.columns[key].transformer
? meta.columns[key].transformer.to(value)
: value,
},
})
const newValue = meta.columns[key].transformer
? meta.columns[key].transformer.to(value)
: value
if (newValue.includes(null)) {
if (newValue.length > 1) {
queries.push({
condition: `${tableName}${key} IN (:...${key}${paramNumber}) OR ${tableName}${key} IS NULL`,
params: {
[`${key}${paramNumber++}`]: newValue.filter(
x => x !== null
),
},
})
} else {
queries.push({
condition: `${tableName}${key} IS NULL`,
})
}
} else {
queries.push({
condition: `${tableName}${key} IN (:...${key}${paramNumber})`,
params: {
[`${key}${paramNumber++}`]: newValue,
},
})
}
} else {

@@ -533,0 +583,0 @@ // TODO: in reality it shouldn't enter here

{
"name": "@soinlabs/db",
"version": "1.1.0-alpha.56",
"version": "1.1.0-alpha.58",
"main": "index.js",

@@ -5,0 +5,0 @@ "repository": "",

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