From 46e65b7e63d73e0d83ffefa152ab193793c3e524 Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Wed, 26 Sep 2012 08:08:27 +0400 Subject: [PATCH] Update mysql to 2.0 --- lib/adapters/mysql.js | 2 +- package.json | 2 +- test/migration_test.coffee | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/adapters/mysql.js b/lib/adapters/mysql.js index 73e0140b..add85402 100644 --- a/lib/adapters/mysql.js +++ b/lib/adapters/mysql.js @@ -10,7 +10,7 @@ exports.initialize = function initializeSchema(schema, callback) { if (!mysql) return; var s = schema.settings; - schema.client = mysql.createClient({ + schema.client = mysql.createConnection({ host: s.host || 'localhost', port: s.port || 3306, user: s.username, diff --git a/package.json b/package.json index 733ed2b3..eb8e904b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "redis": "= 0.7.2", "hiredis": "latest", "mongoose": "latest", - "mysql": ">= 0.9.4", + "mysql": ">= 2.0.0-alpha3", "pg": "= 0.7.2", "sqlite3": ">= 2.0.18", "riak-js": ">= 0.4.1", diff --git a/test/migration_test.coffee b/test/migration_test.coffee index 1b6761c7..f4a2d526 100644 --- a/test/migration_test.coffee +++ b/test/migration_test.coffee @@ -45,10 +45,12 @@ getFields = (model, cb) -> getIndexes = (model, cb) -> query 'SHOW INDEXES FROM ' + model, (err, res) -> if err + console.log err cb err else indexes = {} - res.forEach (index) -> indexes[index.Key_name] = index if index.Seq_in_index == 1 + res.forEach (index) -> + indexes[index.Key_name] = index if index.Seq_in_index == '1' cb err, indexes it 'should run migration', (test) -> @@ -162,7 +164,7 @@ it 'should add single-column index', (test) -> getIndexes 'User', (err, ixs) -> test.ok ixs.email && ixs.email.Column_name == 'email' console.log(ixs) - test.equal ixs.email.Index_type, 'BTREE' # default + test.equal ixs.email.Index_type, 'BTREE', 'default index type' test.done() it 'should change type of single-column index', (test) -> @@ -172,7 +174,6 @@ it 'should change type of single-column index', (test) -> User.schema.autoupdate (err) -> return console.log(err) if err getIndexes 'User', (err, ixs) -> - console.log ixs.email test.ok ixs.email && ixs.email.Column_name == 'email' test.equal ixs.email.Index_type, 'BTREE' test.done()