{"action":"created","issue":{"url":"https://api.github.com/repos/patriksimek/node-mssql/issues/343","repository_url":"https://api.github.com/repos/patriksimek/node-mssql","labels_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/343/labels{/name}","comments_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/343/comments","events_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/343/events","html_url":"https://github.com/patriksimek/node-mssql/issues/343","id":173629764,"number":343,"title":"Error when pass empty string to a query","user":{"login":"Kimel1","id":6690999,"avatar_url":"https://avatars.githubusercontent.com/u/6690999?v=3","gravatar_id":"","url":"https://api.github.com/users/Kimel1","html_url":"https://github.com/Kimel1","followers_url":"https://api.github.com/users/Kimel1/followers","following_url":"https://api.github.com/users/Kimel1/following{/other_user}","gists_url":"https://api.github.com/users/Kimel1/gists{/gist_id}","starred_url":"https://api.github.com/users/Kimel1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kimel1/subscriptions","organizations_url":"https://api.github.com/users/Kimel1/orgs","repos_url":"https://api.github.com/users/Kimel1/repos","events_url":"https://api.github.com/users/Kimel1/events{/privacy}","received_events_url":"https://api.github.com/users/Kimel1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/patriksimek/node-mssql/labels/discussion","name":"discussion","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-28T05:11:14Z","updated_at":"2016-09-04T05:44:18Z","closed_at":null,"body":"example \r\n```javascript\r\nrow.ShipName = '';\r\nreq.input('ShipName', sqlDb.NVarChar(255), row.ShipName);\r\n\r\n```\r\n\r\nAnd when I insert data into db \r\n```javascript \r\nreq.query('INSERT INTO Sales(ShipName) VALUES(@ShippedDate)')\r\n```\r\nI get error \r\n`{ RequestError: Cannot insert the value NULL into column 'ShipName', table 'db.dbo.tblSales'; column does not allow nulls. INSERT fails.`\r\n\r\n\r\nThis table don't allow null, it's clear, but\r\ncolumn type:\r\n```\r\n[ShipName] [nvarchar](255) NOT NULL\r\nALTER TABLE [dbo].[tblCommonSales] ADD  DEFAULT ('') FOR [ShipName]\r\nGO\r\n```\r\nand when I from studio execute this  query \r\n```javascript\r\nINSERT INTO tblCommonSales(ShipName) \r\nVALUES('')\r\n```\r\nit's work correctly\r\n(exactly when if I execute query this way: INSERT INTO tblCommonSales(ShipName) VALUES(null), I'll get same error)\r\nSo as I understand in JavaScript no difference between null and '' and this is the problem. I can't pass '' into the query because it's like a null.\r\n\r\nSorry for my English. \r\n\r\n   \r\n"},"comment":{"url":"https://api.github.com/repos/patriksimek/node-mssql/issues/comments/244585585","html_url":"https://github.com/patriksimek/node-mssql/issues/343#issuecomment-244585585","issue_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/343","id":244585585,"user":{"login":"Kimel1","id":6690999,"avatar_url":"https://avatars.githubusercontent.com/u/6690999?v=3","gravatar_id":"","url":"https://api.github.com/users/Kimel1","html_url":"https://github.com/Kimel1","followers_url":"https://api.github.com/users/Kimel1/followers","following_url":"https://api.github.com/users/Kimel1/following{/other_user}","gists_url":"https://api.github.com/users/Kimel1/gists{/gist_id}","starred_url":"https://api.github.com/users/Kimel1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kimel1/subscriptions","organizations_url":"https://api.github.com/users/Kimel1/orgs","repos_url":"https://api.github.com/users/Kimel1/repos","events_url":"https://api.github.com/users/Kimel1/events{/privacy}","received_events_url":"https://api.github.com/users/Kimel1/received_events","type":"User","site_admin":false},"created_at":"2016-09-04T05:44:18Z","updated_at":"2016-09-04T05:44:18Z","body":"No, this is an example, in my code I checked for typo, and the problem is that in JS '' === null, but in sql server '' <> null. I solved this problem by wrapping all nvarchar values  in ISNULL(SomeValue,'').\r\n"}}
{"actor":{"display_login":"Kimel1"}}