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

mysql-simple-query

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-simple-query - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

17

lib/mysqlSimpleQuery.js

@@ -9,2 +9,3 @@ const dbQuery = require('./util/dbQuery');

this.whereStatement = {};
this.whereInStatement = {};
this.whereConditionUsed = false;

@@ -59,2 +60,6 @@ this.whereLikeStatement = {};

whereIn(key, array) {
this.whereInStatement[key] = array;
}
whereBetween(key, array) {

@@ -80,2 +85,10 @@ this.whereBetweenStatement[key] = array;

parseWhereIn() {
if (!isEmpty(this.whereInStatement)) {
return dbQuery.parseWhereIn(this.whereInStatement, this.whereConditionUsed);
}
return '';
}
parseWhereBetween() {

@@ -135,2 +148,6 @@ if (!isEmpty(this.whereBetweenStatement)) {

if (this.parseWhereIn() !== '') {
queryStatement += ` ${this.parseWhereIn()}`;
}
if (this.parseWhereLike() !== '') {

@@ -137,0 +154,0 @@ queryStatement += ` ${this.parseWhereLike()}`;

@@ -57,2 +57,13 @@ const select = select => {

const parseWhereIn = (whereObject, where = false) => {
let whereStatement = [];
for (let key of Object.keys(whereObject)) {
const value = whereObject[key];
whereStatement.push(`${key} IN (${value.join(',')})`);
}
return `${where ? 'AND' : 'WHERE'} ${whereStatement.join(' AND ')}`;
};
const parseWhereLike = (whereObject, orStatement = false, where = false) => {

@@ -132,2 +143,3 @@ let whereStatement = [];

parseWhere,
parseWhereIn,
parseWhereLike,

@@ -134,0 +146,0 @@ parseWhereBetween,

2

package.json
{
"name": "mysql-simple-query",
"version": "1.0.15",
"version": "1.0.16",
"description": "Simple query wrapper for mysql-promise to make querying, inserting, updating, and deleting easier for developers.",

@@ -5,0 +5,0 @@ "main": "mysqlSimpleQuery.js",

@@ -10,2 +10,3 @@ const dbQuery = require('./util/dbQuery');

this.whereStatement = {};
this.whereInStatement = {};
this.whereConditionUsed = false;

@@ -60,2 +61,6 @@ this.whereLikeStatement = {};

whereIn(key, array) {
this.whereInStatement[key] = array;
}
whereBetween(key, array) {

@@ -81,2 +86,10 @@ this.whereBetweenStatement[key] = array;

parseWhereIn() {
if(!isEmpty(this.whereInStatement)) {
return dbQuery.parseWhereIn(this.whereInStatement, this.whereConditionUsed);
}
return '';
}
parseWhereBetween() {

@@ -138,2 +151,6 @@ if(!isEmpty(this.whereBetweenStatement)) {

if(this.parseWhereIn() !== '') {
queryStatement += ` ${this.parseWhereIn()}`;
}
if(this.parseWhereLike() !== '') {

@@ -140,0 +157,0 @@ queryStatement += ` ${this.parseWhereLike()}`;

@@ -62,2 +62,13 @@ const select = (select) => {

const parseWhereIn = (whereObject, where = false) => {
let whereStatement = [];
for (let key of Object.keys(whereObject)) {
const value = whereObject[key];
whereStatement.push(`${key} IN (${value.join(',')})`);
}
return `${(where ? 'AND' : 'WHERE')} ${whereStatement.join(' AND ')}`;
};
const parseWhereLike = (whereObject, orStatement = false, where = false) => {

@@ -141,2 +152,3 @@ let whereStatement = [];

parseWhere,
parseWhereIn,
parseWhereLike,

@@ -143,0 +155,0 @@ parseWhereBetween,

@@ -171,2 +171,14 @@ const expect = require('chai').expect;

});
it('query with where in clause', () => {
const test = new mysqlSimpleQuery();
test.select('*');
test.from('table');
test.where('key', '%value%');
test.whereIn('column', [1, 2]);
const testResults = test.query();
expect(testResults).to.equal('SELECT * FROM table WHERE key="%value%" AND column IN (1,2);');
});
});
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