brianc/node-sql

BLOB node.js Buffer Support

Opened this issue · 1 comments

Currently if you pass a binary node.js Buffer object through (say an INSERT) statement, it gets coerced to a string.

For binary data it should probably convert the data to:

INSERT INTO mytable (blobvalue) VALUE (x'DEADBEAF');

For mysql and sqlite.

And for postgres:

INSERT INTO mytable (blobvalue) VALUE (decode('DEADBEAF', 'hex'));

Also, for create table statements, consider converting:

    var mytable = sql.Table.define({
      name: 'mytable',
      columns: [
        {
          name: 'key',
          dataType: 'BLOB'
        },
        {
          name: 'value',
          dataType: 'BLOB'
        }
      ]
    });

to a dataType of 'BYTEA' for postgres.

I've added a pull request which adds the INSERT statement support in PR #141