{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/185","labels_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/185/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/185/comments","events_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/185/events","html_url":"https://github.com/balderdashy/sails-postgresql/issues/185","id":102034973,"number":185,"title":"processor clobbers Buffers","user":{"login":"kevinburkeshyp","id":10735057,"avatar_url":"https://avatars.githubusercontent.com/u/10735057?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinburkeshyp","html_url":"https://github.com/kevinburkeshyp","followers_url":"https://api.github.com/users/kevinburkeshyp/followers","following_url":"https://api.github.com/users/kevinburkeshyp/following{/other_user}","gists_url":"https://api.github.com/users/kevinburkeshyp/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinburkeshyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinburkeshyp/subscriptions","organizations_url":"https://api.github.com/users/kevinburkeshyp/orgs","repos_url":"https://api.github.com/users/kevinburkeshyp/repos","events_url":"https://api.github.com/users/kevinburkeshyp/events{/privacy}","received_events_url":"https://api.github.com/users/kevinburkeshyp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-20T01:13:47Z","updated_at":"2015-08-20T01:26:38Z","closed_at":null,"body":"If you try creating a `'binary'` data type and passing a Buffer as the value, node-postgres returns a Buffer object, but the call to `_.cloneDeep(values)` converts a Buffer into a weird looking object. You can see that in this script: https://gist.github.com/kevinburkeshyp/c45a344a15e040ec6f0e.\r\n\r\nI'm not sure how to use that new Buffer object in a meaningful way. Maybe the Buffer should be converted to a string before calling `_.cloneDeep` on it. "},"comment":{"url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/comments/132844529","html_url":"https://github.com/balderdashy/sails-postgresql/issues/185#issuecomment-132844529","issue_url":"https://api.github.com/repos/balderdashy/sails-postgresql/issues/185","id":132844529,"user":{"login":"kevinburkeshyp","id":10735057,"avatar_url":"https://avatars.githubusercontent.com/u/10735057?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinburkeshyp","html_url":"https://github.com/kevinburkeshyp","followers_url":"https://api.github.com/users/kevinburkeshyp/followers","following_url":"https://api.github.com/users/kevinburkeshyp/following{/other_user}","gists_url":"https://api.github.com/users/kevinburkeshyp/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinburkeshyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinburkeshyp/subscriptions","organizations_url":"https://api.github.com/users/kevinburkeshyp/orgs","repos_url":"https://api.github.com/users/kevinburkeshyp/repos","events_url":"https://api.github.com/users/kevinburkeshyp/events{/privacy}","received_events_url":"https://api.github.com/users/kevinburkeshyp/received_events","type":"User","site_admin":false},"created_at":"2015-08-20T01:26:38Z","updated_at":"2015-08-20T01:26:38Z","body":"Here's a possible patch:\r\n\r\n```javascript\r\nProcessor.prototype.cast = function(table, values) {\r\n\r\n  var self = this;\r\n  for (var key in values) {\r\n    if (values.hasOwnProperty(key)) {\r\n      if (Buffer.isBuffer(values[key])) {\r\n        values[key] = values[key].toString('binary');\r\n      }\r\n    }\r\n  }\r\n```\r\n\r\nNote now there's a discrepancy between the passed in value (a Buffer) and the result you get back from the database (a string). \r\n\r\nYou can't pass in a string, at least, I couldn't get it to work. Creating new values failed with the error message '[object Object]' (that is the literal value, there is no object there) - nothing gets sent to the DB, it fails the anchor validation in waterline. Maybe I should report that as a separate error."}}