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.12 to 1.0.13

6

lib/mysqlSimpleQuery.js

@@ -53,4 +53,4 @@ const dbQuery = require('./util/dbQuery');

whereBetween(key, value) {
this.whereLikeStatement[key] = value;
whereBetween(key, array) {
this.whereBetweenStatement[key] = array;
}

@@ -76,3 +76,3 @@

if (!isEmpty(this.whereBetweenStatement)) {
return dbQuery.parseWhereBetween(this.whereBetweenStatement);
return dbQuery.parseWhereBetween(this.whereBetweenStatement, this.whereConditionUsed);
}

@@ -79,0 +79,0 @@

@@ -68,3 +68,3 @@ const select = select => {

const parseWhereBetween = whereObject => {
const parseWhereBetween = (whereObject, where = false) => {
let whereStatement = [];

@@ -74,6 +74,6 @@

const value = whereObject[key];
whereStatement.push(`${key} BETWEEN "${value}"`);
whereStatement.push(`${key} BETWEEN "${value[0]}" AND "${value[1]}"`);
}
return `${whereStatement.join(' AND ')}`;
return `${where ? 'AND' : 'WHERE'} ${whereStatement.join(' AND ')}`;
};

@@ -80,0 +80,0 @@

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

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

@@ -54,4 +54,4 @@ const dbQuery = require('./util/dbQuery');

whereBetween(key, value) {
this.whereBetweenStatement[key] = value;
whereBetween(key, array) {
this.whereBetweenStatement[key] = array;
}

@@ -77,3 +77,3 @@

if(!isEmpty(this.whereBetweenStatement)) {
return dbQuery.parseWhereBetween(this.whereBetweenStatement);
return dbQuery.parseWhereBetween(this.whereBetweenStatement, this.whereConditionUsed);
}

@@ -80,0 +80,0 @@

@@ -73,3 +73,3 @@ const select = (select) => {

const parseWhereBetween = (whereObject) => {
const parseWhereBetween = (whereObject, where = false) => {
let whereStatement = [];

@@ -79,6 +79,6 @@

const value = whereObject[key];
whereStatement.push(`${key} BETWEEN "${value}"`);
whereStatement.push(`${key} BETWEEN "${value[0]}" AND "${value[1]}"`);
}
return `${whereStatement.join(' AND ')}`;
return `${(where ? 'AND' : 'WHERE')} ${whereStatement.join(' AND ')}`;
};

@@ -85,0 +85,0 @@

@@ -81,2 +81,25 @@ const expect = require('chai').expect;

it('With where in between statement', () => {
const test = new mysqlSimpleQuery();
test.select('*');
test.from('table');
test.whereBetween('column', ['1', '2']);
const testResults = test.query();
expect(testResults).to.equal('SELECT * FROM table WHERE column BETWEEN "1" AND "2";');
});
it('With where in between and other where statement', () => {
const test = new mysqlSimpleQuery();
test.select('*');
test.from('table');
test.where('key', '%value%');
test.whereBetween('column', ['1', '2']);
const testResults = test.query();
expect(testResults).to.equal('SELECT * FROM table WHERE key="%value%" AND column BETWEEN "1" AND "2";');
});
it('Query with limit', () => {

@@ -83,0 +106,0 @@ const test = new mysqlSimpleQuery();

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