{"action":"created","issue":{"url":"https://api.github.com/repos/coursera/courier/issues/21","repository_url":"https://api.github.com/repos/coursera/courier","labels_url":"https://api.github.com/repos/coursera/courier/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/coursera/courier/issues/21/comments","events_url":"https://api.github.com/repos/coursera/courier/issues/21/events","html_url":"https://github.com/coursera/courier/pull/21","id":150425369,"number":21,"title":"Importing a record without a namespace produces scala compile errors","user":{"login":"eboto","id":250233,"avatar_url":"https://avatars.githubusercontent.com/u/250233?v=3","gravatar_id":"","url":"https://api.github.com/users/eboto","html_url":"https://github.com/eboto","followers_url":"https://api.github.com/users/eboto/followers","following_url":"https://api.github.com/users/eboto/following{/other_user}","gists_url":"https://api.github.com/users/eboto/gists{/gist_id}","starred_url":"https://api.github.com/users/eboto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eboto/subscriptions","organizations_url":"https://api.github.com/users/eboto/orgs","repos_url":"https://api.github.com/users/eboto/repos","events_url":"https://api.github.com/users/eboto/events{/privacy}","received_events_url":"https://api.github.com/users/eboto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-22T17:17:11Z","updated_at":"2016-04-22T19:43:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/coursera/courier/pulls/21","html_url":"https://github.com/coursera/courier/pull/21","diff_url":"https://github.com/coursera/courier/pull/21.diff","patch_url":"https://github.com/coursera/courier/pull/21.patch"},"body":"# WORK IN PROGRESS DO NOT MERGE\r\n\r\nThis is an initial commit that demonstrates a bug. I'll push the fix shortly.\r\n\r\nIf any record imports a non-namespaced record, the generated scala is broken. It probably requires a `_root_.` import.\r\n\r\nI came across this error while trying to make a courier format for storage in ElasticSearch. ElasticSearch as of v2.0 does not support dot-notation in field names, which makes it impossible to store namespaced unions unless they are `flatTyped`, which isn't supported across all generators (most notably typescript-lite).\r\n\r\nMy fairly gross workaround was to put the unioned records in the global namespace (which will stop them from having dots), but then I came across this issue!\r\n\r\nAn example of the output:\r\n```bash\r\n[error] /Users/eboto/code/courier/scala/generator-test/target/scala-2.10/courier/org/coursera/records/WithNoNamespaceField.scala:54: not found: type WithoutNamespace\r\n[error]   lazy val blah: WithoutNamespace = obtainWrapped(WithNoNamespaceField.Fields.blah, classOf[WithoutNamespace])\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/coursera/courier/issues/comments/213565199","html_url":"https://github.com/coursera/courier/pull/21#issuecomment-213565199","issue_url":"https://api.github.com/repos/coursera/courier/issues/21","id":213565199,"user":{"login":"eboto","id":250233,"avatar_url":"https://avatars.githubusercontent.com/u/250233?v=3","gravatar_id":"","url":"https://api.github.com/users/eboto","html_url":"https://github.com/eboto","followers_url":"https://api.github.com/users/eboto/followers","following_url":"https://api.github.com/users/eboto/following{/other_user}","gists_url":"https://api.github.com/users/eboto/gists{/gist_id}","starred_url":"https://api.github.com/users/eboto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eboto/subscriptions","organizations_url":"https://api.github.com/users/eboto/orgs","repos_url":"https://api.github.com/users/eboto/repos","events_url":"https://api.github.com/users/eboto/events{/privacy}","received_events_url":"https://api.github.com/users/eboto/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T19:43:01Z","updated_at":"2016-04-22T19:43:01Z","body":"Dug into the behavior of root-level types a bit. I had forgotten that neither scala nor java can import types defined at the root level (outside of a package) from the context of other packages.\r\n\r\nSo the only solution is to generate these no-namespace types in some default package, rather than in the root namespace. Like: `org.coursera.courier.scalagen.rootnamespace`.\r\n\r\nAFAIK this will only apply to java or scala.\r\n\r\n@saeta do you have any opinions about this? Seems like this could bite anyone trying to model some existing API as a courier data schema.\r\n\r\nAlternatively is there some why to alter a union lookup key using annotations or some such?"}}