不要怂,就是干,撸起袖子干!

Commit 0116710a by Joel Trost Committed by Matt Broadstone

Removed Seriate and put in NODE MSSQL

1 parent 6acb13dd
...@@ -11,7 +11,7 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -11,7 +11,7 @@ ConnectionManager = function(dialect, sequelize) {
this.sequelize.config.port = this.sequelize.config.port || 1433; this.sequelize.config.port = this.sequelize.config.port || 1433;
try { try {
this.lib = require(sequelize.config.dialectModulePath || 'seriate'); this.lib = require(sequelize.config.dialectModulePath || 'mssql');
} catch (err) { } catch (err) {
throw new Error('Please install seriate package manually'); throw new Error('Please install seriate package manually');
} }
...@@ -37,19 +37,30 @@ ConnectionManager.prototype.connect = function(config) { ...@@ -37,19 +37,30 @@ ConnectionManager.prototype.connect = function(config) {
connectionConfig[key] = config.dialectOptions[key]; connectionConfig[key] = config.dialectOptions[key];
}); });
} }
config = {
var connection = { user: connectionConfig.user,
config: { password: connectionConfig.password,
user: connectionConfig.user, server: connectionConfig.host,
password: connectionConfig.password, database: connectionConfig.database
server: connectionConfig.host,
database: connectionConfig.database
},
lib: self.lib
}; };
self.lib.connect(config, function(err) {
resolve(connection); // var request = new self.lib.Request();
// request.query('select 1 as number', function(err, recordset) {
// console.log('err2', err);
// console.log(recordset);
// });
});
// var connection = {
// config: {
// user: connectionConfig.user,
// password: connectionConfig.password,
// server: connectionConfig.host,
// database: connectionConfig.database
// },
// };
//connection = self.lib;
// connection.lib = self.lib.getPlainContext(connection.config);
resolve(self.lib);
}); });
}; };
ConnectionManager.prototype.disconnect = function(connection) { ConnectionManager.prototype.disconnect = function(connection) {
......
...@@ -468,7 +468,8 @@ module.exports = (function() { ...@@ -468,7 +468,8 @@ module.exports = (function() {
*/ */
startTransactionQuery: function(transaction, options) { startTransactionQuery: function(transaction, options) {
if (options.parent) { if (options.parent) {
return 'SAVE TRANSACTION ' + this.quoteIdentifier(transaction.name) + ';'; return '';
//return 'SAVE TRANSACTION ' + SqlGenerator.quoteIdentifier(transaction.name) + ';';
} }
return 'BEGIN TRANSACTION'; return 'BEGIN TRANSACTION';
......
...@@ -38,23 +38,31 @@ module.exports = (function() { ...@@ -38,23 +38,31 @@ module.exports = (function() {
var promise = new Utils.Promise(function(resolve, reject) { var promise = new Utils.Promise(function(resolve, reject) {
console.log(self.sql); console.log(self.sql);
self // self
.connection // .connection
.lib // .lib
.execute(self.connection.config, { query: self.sql }) // .step('',{ query: self.sql })
.then( // .error(function (err) {
function (data) { // console.log('err:', err);
promise.emit('sql', self.sql, self.connection.uuid); // err.sql = sql;
resolve(self.formatResults(data.result)); // reject(self.formatError(err));
}, // })
function (err) { // .end(function (result) {
console.log('err:', err); // console.log('res', result.query);
err.sql = sql; // resolve(self.formatResults(result.query));
reject(self.formatError(err)); // });
} // });
); var request = new self.connection.Request();
request.query(self.sql, function(err, recordset) {
promise.emit('sql', self.sql, self.connection.uuid);
if(err){
console.log(err.message);
reject(self.formatError(err));
}
resolve(self.formatResults(recordset));
});
}); });
return promise; return promise;
}; };
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
"sqlite3": "~3.0.0", "sqlite3": "~3.0.0",
"mysql": "~2.5.0", "mysql": "~2.5.0",
"pg": "~3.6.0", "pg": "~3.6.0",
"mssql": "^1.2.0",
"watchr": "~2.4.11", "watchr": "~2.4.11",
"chai": "~1.9.2", "chai": "~1.9.2",
"mocha": "~2.0.0", "mocha": "~2.0.0",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!