{"action":"created","issue":{"url":"https://api.github.com/repos/felixge/node-mysql/issues/1362","repository_url":"https://api.github.com/repos/felixge/node-mysql","labels_url":"https://api.github.com/repos/felixge/node-mysql/issues/1362/labels{/name}","comments_url":"https://api.github.com/repos/felixge/node-mysql/issues/1362/comments","events_url":"https://api.github.com/repos/felixge/node-mysql/issues/1362/events","html_url":"https://github.com/felixge/node-mysql/issues/1362","id":137495569,"number":1362,"title":"handling null in typecast function","user":{"login":"diginfo","id":6010010,"avatar_url":"https://avatars.githubusercontent.com/u/6010010?v=3","gravatar_id":"","url":"https://api.github.com/users/diginfo","html_url":"https://github.com/diginfo","followers_url":"https://api.github.com/users/diginfo/followers","following_url":"https://api.github.com/users/diginfo/following{/other_user}","gists_url":"https://api.github.com/users/diginfo/gists{/gist_id}","starred_url":"https://api.github.com/users/diginfo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diginfo/subscriptions","organizations_url":"https://api.github.com/users/diginfo/orgs","repos_url":"https://api.github.com/users/diginfo/repos","events_url":"https://api.github.com/users/diginfo/events{/privacy}","received_events_url":"https://api.github.com/users/diginfo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/felixge/node-mysql/labels/question","name":"question","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"milestone":null,"comments":16,"created_at":"2016-03-01T07:25:01Z","updated_at":"2016-03-04T05:20:33Z","closed_at":"2016-03-01T23:22:59Z","body":"I am trying to convert BLOBS to strings and NULL to '' (empty tring) but it looks like NULL kills the function.\r\n\r\nHow can I typecast NULL as '' and also prevent the BLOB typecast from crashing when it meets a NULL value ?\r\n\r\n    con.typeCast = function (field, next) {\r\n      if(!field.length) return(field.string() = '');\r\n      else if (field.length && field.type.indexOf('BLOB') !== -1) return field.string().toString('utf-8');\r\n      return next();\r\n    }\r\n\r\n    TypeError: Cannot read property 'toString' of null"},"comment":{"url":"https://api.github.com/repos/felixge/node-mysql/issues/comments/192109636","html_url":"https://github.com/felixge/node-mysql/issues/1362#issuecomment-192109636","issue_url":"https://api.github.com/repos/felixge/node-mysql/issues/1362","id":192109636,"user":{"login":"sidorares","id":173025,"avatar_url":"https://avatars.githubusercontent.com/u/173025?v=3","gravatar_id":"","url":"https://api.github.com/users/sidorares","html_url":"https://github.com/sidorares","followers_url":"https://api.github.com/users/sidorares/followers","following_url":"https://api.github.com/users/sidorares/following{/other_user}","gists_url":"https://api.github.com/users/sidorares/gists{/gist_id}","starred_url":"https://api.github.com/users/sidorares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidorares/subscriptions","organizations_url":"https://api.github.com/users/sidorares/orgs","repos_url":"https://api.github.com/users/sidorares/repos","events_url":"https://api.github.com/users/sidorares/events{/privacy}","received_events_url":"https://api.github.com/users/sidorares/received_events","type":"User","site_admin":false},"created_at":"2016-03-04T05:20:33Z","updated_at":"2016-03-04T05:20:33Z","body":"typecasts are performed on records you receive, not on the data you submit"}}