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

Commit 381870ca by Sascha Depold

fixed date issue

1 parent bf894d63
...@@ -18,8 +18,8 @@ function xor(s1, s2) ...@@ -18,8 +18,8 @@ function xor(s1, s2)
function parseTime(s) function parseTime(s)
{ {
// TODO: add real parsing // no parsing here with non-binary prtocol, return date as is
return new Date(); return s;
} }
function parseString(s) function parseString(s)
...@@ -184,7 +184,7 @@ function auth(db, user, password) ...@@ -184,7 +184,7 @@ function auth(db, user, password)
{ {
c.serverStatus.protocolVersion = r.bytes(1); c.serverStatus.protocolVersion = r.bytes(1);
c.serverStatus.serverVersion = r.zstring(); c.serverStatus.serverVersion = r.zstring();
c.serverStatus.threadId = r.bytes(4); c.serverStatus.threadId = r.num(4);
var salt = r.bytes(8); var salt = r.bytes(8);
// TODO: whats this? comment and add fields o sercerStatus // TODO: whats this? comment and add fields o sercerStatus
r.bytes(1); r.bytes(1);
...@@ -263,7 +263,8 @@ function query(sql) ...@@ -263,7 +263,8 @@ function query(sql)
while (!r.eof()) while (!r.eof())
{ {
var field = this.fields[field_index]; var field = this.fields[field_index];
var value = string2type(r.lcstring(), field.type); // todo: move to serialiser unpackString var strValue = r.lcstring();
var value = string2type(strValue, field.type); // todo: move to serialiser unpackString
this.store_column(row, field, value) this.store_column(row, field, value)
field_index++; field_index++;
} }
...@@ -420,15 +421,17 @@ function execute(sql, parameters) ...@@ -420,15 +421,17 @@ function execute(sql, parameters)
var bitmap_byte; var bitmap_byte;
if (this.ps.field_count > 0) if (this.ps.field_count > 0)
bitmap_byte = r.num(1); bitmap_byte = r.num(1);
for (var f=0; f < this.ps.field_count; ++f) var numfields = this.ps.field_count;
for (var f=0; f < numfields; ++f)
{ {
null_bit_map.push( (bitmap_byte & bit) != 0); null_bit_map.push( (bitmap_byte & bit) != 0);
if (!((bit<<=1) & 255)) if (!((bit<<=1) & 255) && f + 1 < numfields)
{ {
bit= 1; bit= 1;
bitmap_byte = r.num(1); bitmap_byte = r.num(1);
} }
} }
var row = this.connection.row_as_hash ? {} : []; var row = this.connection.row_as_hash ? {} : [];
for (var f=0; f < this.ps.field_count; ++f) for (var f=0; f < this.ps.field_count; ++f)
{ {
......
...@@ -43,7 +43,7 @@ SequelizeHelper = { ...@@ -43,7 +43,7 @@ SequelizeHelper = {
valuesForInsertQuery: function(object) { valuesForInsertQuery: function(object) {
var actualValues = object.values, var actualValues = object.values,
result = [] result = []
SequelizeHelper.Hash.forEach(actualValues, function(value, key) { SequelizeHelper.Hash.forEach(actualValues, function(value, key) {
var dataType = object.table.attributes[key] var dataType = object.table.attributes[key]
result.push(SequelizeHelper.SQL.transformValueByDataType(value, dataType)) result.push(SequelizeHelper.SQL.transformValueByDataType(value, dataType))
......
...@@ -10,9 +10,11 @@ SequelizeTable = function(sequelize, tableName, attributes) { ...@@ -10,9 +10,11 @@ SequelizeTable = function(sequelize, tableName, attributes) {
var self = this var self = this
SequelizeHelper.Hash.forEach(values, function(value, key) { SequelizeHelper.Hash.forEach(values, function(value, key) {
if(attributes[key]) { if(attributes[key]) {
if(attributes[key] == Sequelize.BOOLEAN) { if(attributes[key].indexOf(Sequelize.BOOLEAN) > -1)
self[key] = ((value == 1) || (value == true)) ? true : false self[key] = ((value == 1) || (value == true)) ? true : false
} else else if(attributes[key].indexOf(Sequelize.DATE) > -1)
self[key] = (value instanceof Date) ? value : new Date(Date.parse(value))
else
self[key] = value self[key] = value
} }
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!