Socket
Socket
Sign inDemoInstall

sql

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql - npm Package Compare versions

Comparing version 0.64.1 to 0.65.0

9

lib/dialect/mssql.js

@@ -9,2 +9,10 @@ // TODO: visitCreate needs to support schemas

/**
* Config can contain:
*
* questionMarkParameterPlaceholder:true which will use a "?" for the parameter placeholder instead of the @index.
*
* @param config
* @constructor
*/
var Mssql = function(config) {

@@ -27,2 +35,3 @@ this.output = [];

Mssql.prototype._getParameterPlaceholder = function(index, value) {
if (this.config.questionMarkParameterPlaceholder) return '?';
return '@' + index;

@@ -29,0 +38,0 @@ };

3

lib/dialect/postgres.js

@@ -788,2 +788,5 @@ 'use strict';

}
if (!columnNode.primaryKey && columnNode.unique) {
txt.push(' UNIQUE')
}
}

@@ -790,0 +793,0 @@

@@ -27,2 +27,3 @@ 'use strict';

this.autoGenerated = !!config.autoGenerated;
this.unique = !!config.unique;
},

@@ -29,0 +30,0 @@ as: function(alias) {

2

package.json

@@ -5,3 +5,3 @@ {

"description": "sql builder",
"version": "0.64.1",
"version": "0.65.0",
"homepage": "https://github.com/brianc/node-sql",

@@ -8,0 +8,0 @@ "license": "MIT",

@@ -464,1 +464,103 @@ 'use strict';

// UNIQUE COLUMN TESTS
Harness.test({
query: Table.define({
name: 'post',
columns: [{
name: 'id',
dataType: 'int',
//primaryKey: true,
//notNull: true,
unique: true
}]
}).create(),
pg: {
text : 'CREATE TABLE "post" ("id" int UNIQUE)',
string: 'CREATE TABLE "post" ("id" int UNIQUE)'
},
sqlite: {
text : 'CREATE TABLE "post" ("id" int UNIQUE)',
string: 'CREATE TABLE "post" ("id" int UNIQUE)'
},
mysql: {
text : 'CREATE TABLE `post` (`id` int UNIQUE)',
string: 'CREATE TABLE `post` (`id` int UNIQUE)'
},
mssql: {
text : 'CREATE TABLE [post] ([id] int UNIQUE)',
string: 'CREATE TABLE [post] ([id] int UNIQUE)'
},
oracle: {
text : 'CREATE TABLE "post" ("id" int UNIQUE)',
string: 'CREATE TABLE "post" ("id" int UNIQUE)'
},
params: []
});
Harness.test({
query: Table.define({
name: 'post',
columns: [{
name: 'id',
dataType: 'int',
//primaryKey: true,
notNull: true,
unique: true
}]
}).create(),
pg: {
text : 'CREATE TABLE "post" ("id" int NOT NULL UNIQUE)',
string: 'CREATE TABLE "post" ("id" int NOT NULL UNIQUE)'
},
sqlite: {
text : 'CREATE TABLE "post" ("id" int NOT NULL UNIQUE)',
string: 'CREATE TABLE "post" ("id" int NOT NULL UNIQUE)'
},
mysql: {
text : 'CREATE TABLE `post` (`id` int NOT NULL UNIQUE)',
string: 'CREATE TABLE `post` (`id` int NOT NULL UNIQUE)'
},
mssql: {
text : 'CREATE TABLE [post] ([id] int NOT NULL UNIQUE)',
string: 'CREATE TABLE [post] ([id] int NOT NULL UNIQUE)'
},
oracle: {
text : 'CREATE TABLE "post" ("id" int NOT NULL UNIQUE)',
string: 'CREATE TABLE "post" ("id" int NOT NULL UNIQUE)'
},
params: []
});
Harness.test({
query: Table.define({
name: 'post',
columns: [{
name: 'id',
dataType: 'int',
primaryKey: true,
//notNull: true,
unique: true
}]
}).create(),
pg: {
text : 'CREATE TABLE "post" ("id" int PRIMARY KEY)',
string: 'CREATE TABLE "post" ("id" int PRIMARY KEY)'
},
sqlite: {
text : 'CREATE TABLE "post" ("id" int PRIMARY KEY)',
string: 'CREATE TABLE "post" ("id" int PRIMARY KEY)'
},
mysql: {
text : 'CREATE TABLE `post` (`id` int PRIMARY KEY)',
string: 'CREATE TABLE `post` (`id` int PRIMARY KEY)'
},
mssql: {
text : 'CREATE TABLE [post] ([id] int PRIMARY KEY)',
string: 'CREATE TABLE [post] ([id] int PRIMARY KEY)'
},
oracle: {
text : 'CREATE TABLE "post" ("id" int PRIMARY KEY)',
string: 'CREATE TABLE "post" ("id" int PRIMARY KEY)'
},
params: []
});

@@ -198,2 +198,18 @@ 'use strict';

test('mssql default parameter place holder is @index', function() {
var Sql = sql.Sql;
var mssql = new Sql('mssql');
var query = mssql.select(user.id).from(user).where(user.email.equals('x@y.com')).toQuery();
assert.equal(query.text, 'SELECT [user].[id] FROM [user] WHERE ([user].[email] = @1)');
assert.equal(query.values[0], 'x@y.com');
});
test('mssql override default parameter placeholder with ?', function() {
var Sql = sql.Sql;
var mssql = new Sql('mssql',{questionMarkParameterPlaceholder:true});
var query = mssql.select(user.id).from(user).where(user.email.equals('x@y.com')).toQuery();
assert.equal(query.text, 'SELECT [user].[id] FROM [user] WHERE ([user].[email] = ?)');
assert.equal(query.values[0], 'x@y.com');
});
});
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