felixge/node-mysql — Issue #138: encoding problem with äüö in field names
Author: lordnox
Created: 2011-11-22 12:28:22+00:00
State: open

Hi,
there still is a little encoding problem with table names.

Test-Table:
```sql
CREATE TABLE `test` ( `Ä` INT(10) NULL ) COLLATE='latin1_swedish_ci' ENGINE=MyISAM ROW_FORMAT=DEFAULT;
INSERT INTO `test` (`Ä`) VALUES (123);
```
Test-Code:

handle = function(err, res, fields) {
console.log(res);
}
client.query 'SELECT * FROM test', handle

the result is:

[ { 'Ã?': 123 } ]

expected was:

[ { 'Ä': 123 } ]

My solution was to convert each fieldname to ascii:

handle = function(err, res, fields) {
result = []
conv = {}
Object.keys(fields).forEach(function(field) {
conv[field] = [(new Buffer(field, 'ascii')).toString('utf8')];
});
Object.keys(res).forEach(function(index) {
result[index] = {}
Object.keys(fields).forEach(function(field) {
result[index][conv[field]] = res[index][field];
});
});
console.log(result);
}

The problem seems to be somewhere deep in the parser. I hope there is a way to implement a encoding switch for this.

Thanks for your library