Permalink
Browse files

Adds support for mysql alpha 2.0 driver. Fixes Issue #45

  • Loading branch information...
1 parent 9edc3e0 commit 2cba331d843c91023f7f185d4aa7a4e66aa826c9 @tvernon tvernon committed Nov 16, 2012
Showing with 21 additions and 8 deletions.
  1. +11 −1 lib/drivers/mysql.js
  2. +3 −0 lib/sqltree.js
  3. +6 −7 test/update.js
  4. +1 −0 test_helpers/test_utils.js
View
@@ -93,7 +93,17 @@ var MySqlDriver = Driver.extend({
conn = new MySqlConnection(this, opts.db, false, opts);
callback(null, conn);
} else {
- var db = new mysql.createClient(opts);
+ var db;
+ if (typeof(mysql.createConnection) === 'undefined') {
+ db = new mysql.createClient(opts);
+ } else {
+ db = new mysql.createConnection(opts);
+ db.connect(function(err) {
+ if (err) {
+ console.log(err);
+ }
+ });
+ }
conn = new MySqlConnection(this, db, true, opts);
callback(null, conn);
}
View
@@ -132,6 +132,9 @@ var SqlTree = Class.extend({
var key;
var trueFunc = function () { return true; };
for (key in row) {
+ if (key == 'parse' || key == '_typeCast') {
+ continue;
+ }
var column = this.getColumnByAlias(key);
if (!column) {
throw new Error('Could not find column from alias "' + key + '"');
View
@@ -1,4 +1,3 @@
-
var persist = require("../lib/persist");
var type = persist.type;
var nodeunit = require("nodeunit");
@@ -178,15 +177,15 @@ exports['Update'] = nodeunit.testCase({
test.equals("Bob Smith", results[0].name);
test.equals(20, results[0].age);
- test.equals(origDate.getTime(), results[0].lastUpdated);
+ test.equals(origDate.getTime(), new Date(results[0].lastUpdated).getTime());
test.equals("Joe Blow", results[1].name);
test.equals(19, results[1].age);
- test.equals(lastUpdated.getTime(), results[1].lastUpdated);
+ test.equals(lastUpdated.getTime(), new Date(results[1].lastUpdated).getTime());
test.equals("Joe Smith", results[2].name);
test.equals(19, results[2].age);
- test.equals(lastUpdated.getTime(), results[2].lastUpdated);
+ test.equals(lastUpdated.getTime(), new Date(results[2].lastUpdated).getTime());
test.done();
});
@@ -214,15 +213,15 @@ exports['Update'] = nodeunit.testCase({
test.equals("Bob Smith", results[0].name);
test.equals(19, results[0].age);
- test.equals(lastUpdated.getTime(), results[0].lastUpdated);
+ test.equals(lastUpdated.getTime(), new Date(results[0].lastUpdated).getTime());
test.equals("Joe Blow", results[1].name);
test.equals(19, results[1].age);
- test.equals(lastUpdated.getTime(), results[1].lastUpdated);
+ test.equals(lastUpdated.getTime(), new Date(results[1].lastUpdated).getTime());
test.equals("Joe Smith", results[2].name);
test.equals(19, results[2].age);
- test.equals(lastUpdated.getTime(), results[2].lastUpdated);
+ test.equals(lastUpdated.getTime(), new Date(results[2].lastUpdated).getTime());
test.done();
});
@@ -123,6 +123,7 @@ exports.connect = function(persist, callback) {
} else {
persist.connect({
driver: 'mysql',
+ host: 'localhost',
user: 'root',
password: 'root',
database: 'test'

0 comments on commit 2cba331

Please sign in to comment.