Skip to content

Commit

Permalink
Fix sql adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Apr 19, 2012
1 parent 222b457 commit 16a1c21
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/adapters/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ MySQL.prototype.toDatabase = function (prop, val) {
}
}
}
if (!prop) return val;
if (prop.type.name === 'Number') return val;
if (prop.type.name === 'Date') {
if (!val) return 'NULL';
Expand Down
1 change: 1 addition & 0 deletions lib/adapters/sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function dateToMysql(val) {
}

SQLite3.prototype.toDatabase = function (prop, val) {
if (!prop) return val;
if (prop.type.name === 'Number') return val;
if (val === null) return 'NULL';
if (prop.type.name === 'Date') {
Expand Down
3 changes: 2 additions & 1 deletion test/common_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,8 @@ function testOrm(schema) {
User.find(user.id, function (err, user) {
test.ok(user !== u);
test.equal(user.passwd, 'qwertysalt');
User.all({where: {id: user.id}}, function (err, users) {
console.log(user.id);
User.all({where: {passwd: 'qwertysalt'}}, function (err, users) {
test.ok(users[0] !== user);
test.equal(users[0].passwd, 'qwertysalt');
User.create({passwd: 'asalat'}, function (err, usr) {
Expand Down

0 comments on commit 16a1c21

Please sign in to comment.