Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading floats not supported. #69

Open
chrisdew opened this issue Aug 16, 2012 · 0 comments
Open

Reading floats not supported. #69

chrisdew opened this issue Aug 16, 2012 · 0 comments

Comments

@chrisdew
Copy link
Contributor

When I try to read floats I get:

connected
building query select * from float_test
result { insert_id: undefined,
  affected_rows: undefined,
  rows: 
   [ { id: 1,
       fval: '_not_implemented_ MYSQL_TYPE_FLOAT \'\\u0000\\u0000\\u0001\\u0000\\u0000\\u0000¶ó�?\'' },
     { id: 2,
       fval: '_not_implemented_ MYSQL_TYPE_FLOAT \'\\u0000\\u0000\\u0002\\u0000\\u0000\\u0000{\\u0014\\u0016@\'' } ] }

when using the program:

var my = require("mysql-native");

var db = my.createTCPClient("172.27.1.40", 3306);
db.auto_prepare = true;
db.auth("test",  "chris", "passwd");
db.addListener('connect', function() {
  console.info("connected");
  var q = buildQuery("select * from float_test");
  q(db, [], function(err, result) {
    if (err) console.log("err", err);
    if (result) console.log("result", result);
  });
});

function buildQuery(sql, debug) {
  console.log("building query", sql);
  return function(db, data, callback) {
    //console.log("executing query", sql, data);
    var query = db.execute(sql, data);
    query.on('error', function(err) {
      console.warn("error", JSON.stringify(err), sql, data);
      callback(err);
    });
    query.on('result', function(result) {
      //console.info("result", result);
      callback(null, result);
    });
  }
}

with data that looks like:


mysql> select * from float_test;
+----+-------+
| id | fval  |
+----+-------+
|  1 | 1.234 | 
|  2 | 2.345 | 
+----+-------+
2 rows in set (0.00 sec)

mysql> describe float_test;
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| id    | int(10) | NO   | PRI | NULL    | auto_increment | 
| fval  | float   | NO   |     | 0       |                | 
+-------+---------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
sidorares added a commit that referenced this issue Aug 17, 2012
#69 test and fix reading float in non-zero position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant