{"action":"created","issue":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/20402","repository_url":"https://api.github.com/repos/cockroachdb/cockroach","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/20402/labels{/name}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/20402/comments","events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/20402/events","html_url":"https://github.com/cockroachdb/cockroach/issues/20402","id":278573463,"number":20402,"title":"sql: supporting better errors or type-casting for DEFAULT expressions (like now())","user":{"login":"lego","id":1161183,"avatar_url":"https://avatars0.githubusercontent.com/u/1161183?v=4","gravatar_id":"","url":"https://api.github.com/users/lego","html_url":"https://github.com/lego","followers_url":"https://api.github.com/users/lego/followers","following_url":"https://api.github.com/users/lego/following{/other_user}","gists_url":"https://api.github.com/users/lego/gists{/gist_id}","starred_url":"https://api.github.com/users/lego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lego/subscriptions","organizations_url":"https://api.github.com/users/lego/orgs","repos_url":"https://api.github.com/users/lego/repos","events_url":"https://api.github.com/users/lego/events{/privacy}","received_events_url":"https://api.github.com/users/lego/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-12-01T19:37:48Z","updated_at":"2018-03-12T21:24:28Z","closed_at":null,"author_association":"COLLABORATOR","body":"While trying to run ActiveRecord tests, a [schema definition](https://github.com/rails/rails/blob/master/activerecord/test/schema/postgresql_specific_schema.rb#L21) I've run across generates:\r\n\r\n```sql\r\nCREATE TABLE ... (<col> data DEFAULT now())\r\n``` \r\n\r\nThis does not work because `now()` has to be explicitly cast to `date`. This is annoying because:\r\n- Some ORMs/libraries may auto-generate the `now` statement. This may only be the case for `timestamp` columns, I'd need a citation on this point.\r\n- Any existing code snippets like this will just not work.\r\n- The error raised is rather confusing, `pq: unknown signature: now() (desired <date>)`.\r\n\r\n\r\nWhile doing type-casts here may be out of the question[1], a few solutions may be:\r\n- Define the built-in `now()` with different return type signatures for all sane types `timestamp` can be cast to.\r\n- Spew out a more reasonable error, suggesting the user use `::<TYPE>` to resolve the problem.\r\n\r\n(let's try the first solution, and if it doesn't work possibly give the second a shot)\r\n\r\n[1]: Doing implicit type-casts is a separate long discussion on its own and is large in scope."},"comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments/372467647","html_url":"https://github.com/cockroachdb/cockroach/issues/20402#issuecomment-372467647","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/20402","id":372467647,"user":{"login":"jviksne","id":22882672,"avatar_url":"https://avatars1.githubusercontent.com/u/22882672?v=4","gravatar_id":"","url":"https://api.github.com/users/jviksne","html_url":"https://github.com/jviksne","followers_url":"https://api.github.com/users/jviksne/followers","following_url":"https://api.github.com/users/jviksne/following{/other_user}","gists_url":"https://api.github.com/users/jviksne/gists{/gist_id}","starred_url":"https://api.github.com/users/jviksne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jviksne/subscriptions","organizations_url":"https://api.github.com/users/jviksne/orgs","repos_url":"https://api.github.com/users/jviksne/repos","events_url":"https://api.github.com/users/jviksne/events{/privacy}","received_events_url":"https://api.github.com/users/jviksne/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T21:24:28Z","updated_at":"2018-03-12T21:24:28Z","author_association":"NONE","body":"Great, thanks!"}}
{"actor":{"display_login":"jviksne"}}