{"action":"opened","issue":{"url":"https://api.github.com/repos/JetBrains/Exposed/issues/345","repository_url":"https://api.github.com/repos/JetBrains/Exposed","labels_url":"https://api.github.com/repos/JetBrains/Exposed/issues/345/labels{/name}","comments_url":"https://api.github.com/repos/JetBrains/Exposed/issues/345/comments","events_url":"https://api.github.com/repos/JetBrains/Exposed/issues/345/events","html_url":"https://github.com/JetBrains/Exposed/issues/345","id":342695827,"node_id":"MDU6SXNzdWUzNDI2OTU4Mjc=","number":345,"title":"Incorrect behavior on nullable fields with default value","user":{"login":"maxim5","id":2580604,"node_id":"MDQ6VXNlcjI1ODA2MDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2580604?v=4","gravatar_id":"","url":"https://api.github.com/users/maxim5","html_url":"https://github.com/maxim5","followers_url":"https://api.github.com/users/maxim5/followers","following_url":"https://api.github.com/users/maxim5/following{/other_user}","gists_url":"https://api.github.com/users/maxim5/gists{/gist_id}","starred_url":"https://api.github.com/users/maxim5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxim5/subscriptions","organizations_url":"https://api.github.com/users/maxim5/orgs","repos_url":"https://api.github.com/users/maxim5/repos","events_url":"https://api.github.com/users/maxim5/events{/privacy}","received_events_url":"https://api.github.com/users/maxim5/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-19T11:51:13Z","updated_at":"2018-07-19T11:51:13Z","closed_at":null,"author_association":"NONE","body":"The field is defined as\r\n```\r\nobject Profile : EntityTable(...) {\r\n    ...\r\n    val notAMember = bool(\"notAMember\").default(false).nullable()\r\n    ...\r\n}\r\n```\r\n\r\nInserted into DB as\r\n```\r\nEProfile.new {\r\n    ...\r\n    this.notAMember = notAMember ?: false  // I.e. never null\r\n    ...\r\n}\r\n```\r\n\r\n**Observed behavior**\r\n\r\nThe DB row is created with `notAMember == null`.\r\n\r\n**Bonus**\r\n\r\nThe query:\r\n\r\n```\r\n...\r\nAndOp(op, DB.Profile.notAMember neq true)\r\n...\r\n```\r\n\r\nis translated to `Profile.notAMember <> true` in SQL which **does not** match NULL values in MySQL ([discussion](https://stackoverflow.com/questions/42148150/not-equal-query-excludes-null-values)). Since Exposed is aware of nullability, it could insert `OR ... IS NULL` automatically."}}
{"actor":{"display_login":"maxim5"}}