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

sqlquerybuilder

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlquerybuilder - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

11

lib/selects.js

@@ -28,6 +28,8 @@ module.exports = function selects(self) {

self.select = function select(sel) {
if(!self._sqlObject.select)self._sqlObject.select="";
else self._sqlObject.select+=", ";
if (typeof(sel) == 'string') {
self._sqlObject.select = sel;
self._sqlObject.select += sel;
} else if (sel instanceof Array) {
self._sqlObject.select = "";
self._sqlObject.select += "";
for (var a = 0; a < sel.length; a++) {

@@ -38,3 +40,3 @@ self._sqlObject.select += sel[a];

} else if (sel instanceof Object) {
self._sqlObject.select = "";
self._sqlObject.select += "";
var props = Object.keys(sel);

@@ -65,4 +67,5 @@ for (var i = 0; i < props.length; i++) {

self.selectJoin = function selectJoin(selObj) {
if(!self._sqlObject.select)self._sqlObject.select="";
else self._sqlObject.select+=", ";
if (selObj instanceof Object) {
self._sqlObject.select = "";
var props = Object.keys(selObj);

@@ -69,0 +72,0 @@ for (var i = 0; i < props.length; i++) {

{
"name": "sqlquerybuilder",
"version": "0.0.19",
"version": "0.0.20",
"description": "Highly opinionated Sql Server Query Writer, mostly for internal use.",

@@ -5,0 +5,0 @@ "main": "./lib/index",

@@ -75,4 +75,21 @@ /**

});
it('should chain selects', function(done){
sqlBuilder().from('main')
.selectJoin({'main.Id':'Id', 'secondary.Id': 'secondary.Id'})
.join("tertiary")
.select({'tertiary.Property': 'Prop'})
.build().should.equal("SELECT main.Id AS 'Id', secondary.Id AS 'secondary.Id', tertiary.Property AS 'Prop' FROM main " +
"JOIN secondary ON main.secondary_id = secondary.Id JOIN tertiary ON main.tertiary_id = tertiary.Id ");
done();
});
it('should chain selects', function(done){
sqlBuilder().from('main')
.join("tertiary")
.select({'tertiary.Property': 'Prop'})
.selectJoin({'main.Id':'Id', 'secondary.Id': 'secondary.Id'})
.build().should.equal("SELECT tertiary.Property AS 'Prop', main.Id AS 'Id', secondary.Id AS 'secondary.Id' FROM main " +
"JOIN tertiary ON main.tertiary_id = tertiary.Id JOIN secondary ON main.secondary_id = secondary.Id ");
done();
});
});

@@ -150,2 +167,3 @@

});
});
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