{"action":"opened","issue":{"url":"https://api.github.com/repos/nviennot/nobrainer/issues/118","labels_url":"https://api.github.com/repos/nviennot/nobrainer/issues/118/labels{/name}","comments_url":"https://api.github.com/repos/nviennot/nobrainer/issues/118/comments","events_url":"https://api.github.com/repos/nviennot/nobrainer/issues/118/events","html_url":"https://github.com/nviennot/nobrainer/issues/118","id":54262205,"number":118,"title":"Empty ids","user":{"login":"ajselvig","id":455594,"avatar_url":"https://avatars.githubusercontent.com/u/455594?v=3","gravatar_id":"","url":"https://api.github.com/users/ajselvig","html_url":"https://github.com/ajselvig","followers_url":"https://api.github.com/users/ajselvig/followers","following_url":"https://api.github.com/users/ajselvig/following{/other_user}","gists_url":"https://api.github.com/users/ajselvig/gists{/gist_id}","starred_url":"https://api.github.com/users/ajselvig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajselvig/subscriptions","organizations_url":"https://api.github.com/users/ajselvig/orgs","repos_url":"https://api.github.com/users/ajselvig/repos","events_url":"https://api.github.com/users/ajselvig/events{/privacy}","received_events_url":"https://api.github.com/users/ajselvig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-13T23:11:04Z","updated_at":"2015-01-13T23:11:04Z","closed_at":null,"body":"This has caught me twice and I know it's due to bugs in my code, but it would be nice to have an earlier warning. NoBrainer will happily save a document with id='' (empty string). This happens only once, of course, since the next time around it will fail the uniqueness requirement for ids. \r\n\r\nHowever, I cannot possibly think of an actual use for this behavior, and it would be helpful if an exception was raised (or error added for ?-suffix methods) when the document is saved. This will make it easier to detect the error in user code and fix it before there's a dangling document in the database.\r\n\r\nThoughts?\r\n\r\nObligatory example code:\r\n\r\n```ruby\r\nrequire 'nobrainer'\r\n\r\nNoBrainer.configure do |config|\r\n  config.rethinkdb_url          = 'rethinkdb://localhost/nobrainer_playground'\r\n  config.logger                 = Logger.new $stdout\r\nend\r\n\r\nclass Foo\r\n  include NoBrainer::Document\r\nend\r\n\r\nFoo.delete_all\r\n\r\nf = Foo.new id: ''\r\nf.save\r\nputs f.id # empty!\r\n```\r\n"}}