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

13

lib/sqlQueryBuilder.js

@@ -491,5 +491,12 @@ var uuid = require('node-uuid'), pluralizer = require('pluralizer'), _ = require('lodash');

if (contains !== -1) {
var containsAlias = _selectProps[_selectAliases.indexOf(filter.substr(0, contains))];
whereString += (containsAlias ? containsAlias : (_sqlObject.fromAlias + "." + filter.substr(0, contains))) +
" LIKE '%" +
var prop = filter.substr(0, contains);
var containsAlias = _selectProps[_selectAliases.indexOf(prop)];
if(containsAlias){
whereString += containsAlias;
}else if(prop.indexOf(".") !== -1){
whereString += prop;
}else{
whereString += _sqlObject.fromAlias + "." + prop;
}
whereString += " LIKE '%" +
filter.substr(contains + 11, filter.lastIndexOf("\"") - (contains + 11)) +

@@ -496,0 +503,0 @@ "%'";

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

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

@@ -473,2 +473,23 @@ /**

});
it('it is called with filters with an alias that includes a tablename', function(done){
var req = {
query: {
rows: 100,
page: 1,
filters: 'Yard.Name.Contains("athen")'
}
};
(sqlBuilder()
.select("al.Id, al.Name, al.Code, y.Name as [Yard.Name]")
.from("AccountLocations al")
.leftJoin("Yards y")
.processListRequest(req.query)
.build())
.should.equal("WITH SelectedItems AS (SELECT al.Id, al.Name, al.Code, y.Name as [Yard.Name], ROW_NUMBER() OVER (ORDER BY al.Created) AS Position FROM AccountLocations al " +
"LEFT JOIN Yards y ON al.Yard_id = y.Id WHERE Yard.Name LIKE '%athen%') SELECT *, (Select MAX(Position) From SelectedItems) as 'TotalRows' " +
"FROM SelectedItems WHERE Position > 0 AND Position <= 100 ");
done();
});
});
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