{"action":"created","issue":{"url":"https://api.github.com/repos/Deepwalker/aldjemy/issues/40","repository_url":"https://api.github.com/repos/Deepwalker/aldjemy","labels_url":"https://api.github.com/repos/Deepwalker/aldjemy/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/Deepwalker/aldjemy/issues/40/comments","events_url":"https://api.github.com/repos/Deepwalker/aldjemy/issues/40/events","html_url":"https://github.com/Deepwalker/aldjemy/issues/40","id":164971957,"number":40,"title":"Issue with mapping when using UUID fields","user":{"login":"fearofcode","id":30261,"avatar_url":"https://avatars.githubusercontent.com/u/30261?v=3","gravatar_id":"","url":"https://api.github.com/users/fearofcode","html_url":"https://github.com/fearofcode","followers_url":"https://api.github.com/users/fearofcode/followers","following_url":"https://api.github.com/users/fearofcode/following{/other_user}","gists_url":"https://api.github.com/users/fearofcode/gists{/gist_id}","starred_url":"https://api.github.com/users/fearofcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fearofcode/subscriptions","organizations_url":"https://api.github.com/users/fearofcode/orgs","repos_url":"https://api.github.com/users/fearofcode/repos","events_url":"https://api.github.com/users/fearofcode/events{/privacy}","received_events_url":"https://api.github.com/users/fearofcode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-12T00:58:28Z","updated_at":"2016-07-12T01:28:27Z","closed_at":null,"body":"I have a Django 1.9 model called `Property` (I know it clashes with the Python keyword `property`, but it doesn't effect the issue I'm having).\r\n\r\nWhen I put `aldjemy` in Django's app list and tried to open up the Django shell, I got this stack trace:\r\n\r\n```\r\n$ ./bin/manage shell_plus\r\nTraceback (most recent call last):\r\n  File \"/app/manage.py\", line 10, in <module>\r\n    execute_from_command_line(sys.argv)\r\n  File \"/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py\", line 353, in execute_from_command_line\r\n    utility.execute()\r\n  File \"/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py\", line 327, in execute\r\n    django.setup()\r\n  File \"/usr/local/lib/python3.5/site-packages/django/__init__.py\", line 18, in setup\r\n    apps.populate(settings.INSTALLED_APPS)\r\n  File \"/usr/local/lib/python3.5/site-packages/django/apps/registry.py\", line 115, in populate\r\n    app_config.ready()\r\n  File \"/usr/local/lib/python3.5/site-packages/aldjemy/apps.py\", line 17, in ready\r\n    prepare_models()\r\n  File \"/usr/local/lib/python3.5/site-packages/aldjemy/orm.py\", line 114, in prepare_models\r\n    orm.mapper(sa_models[name], table, attrs)\r\n  File \"<string>\", line 2, in mapper\r\n  File \"/usr/local/lib/python3.5/site-packages/sqlalchemy/orm/mapper.py\", line 629, in __init__\r\n    self._configure_pks()\r\n  File \"/usr/local/lib/python3.5/site-packages/sqlalchemy/orm/mapper.py\", line 1223, in _configure_pks\r\n    (self, self.mapped_table.description))\r\nsqlalchemy.exc.ArgumentError: Mapper Mapper|Property|core_property could not assemble any primary key columns for mapped table 'core_property'\r\n```\r\n\r\n`core` is our Django application name and `core_property` is the table of the model in question.\r\n\r\nI believe this UUID field is causing the issue:\r\n\r\n```Python\r\nid = models.UUIDField(primary_key=True, default=uuid.uuid4)\r\n```\r\n\r\nCommenting this line allows the shell to load successfully.\r\n\r\nSo is there something about UUID fields or non-auto primary key fields that would make aldjemy error out this way?\r\n\r\nIs there anything we can do besides not use a UUID primary key field?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/Deepwalker/aldjemy/issues/comments/231913163","html_url":"https://github.com/Deepwalker/aldjemy/issues/40#issuecomment-231913163","issue_url":"https://api.github.com/repos/Deepwalker/aldjemy/issues/40","id":231913163,"user":{"login":"fearofcode","id":30261,"avatar_url":"https://avatars.githubusercontent.com/u/30261?v=3","gravatar_id":"","url":"https://api.github.com/users/fearofcode","html_url":"https://github.com/fearofcode","followers_url":"https://api.github.com/users/fearofcode/followers","following_url":"https://api.github.com/users/fearofcode/following{/other_user}","gists_url":"https://api.github.com/users/fearofcode/gists{/gist_id}","starred_url":"https://api.github.com/users/fearofcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fearofcode/subscriptions","organizations_url":"https://api.github.com/users/fearofcode/orgs","repos_url":"https://api.github.com/users/fearofcode/repos","events_url":"https://api.github.com/users/fearofcode/events{/privacy}","received_events_url":"https://api.github.com/users/fearofcode/received_events","type":"User","site_admin":false},"created_at":"2016-07-12T01:28:27Z","updated_at":"2016-07-12T01:28:27Z","body":"I think I've fixed it. All I had to do was overwrite `ALDJEMY_DATA_TYPES`:\r\n\r\n```Python\r\nfrom sqlalchemy.dialects.postgresql import UUID\r\n\r\nALDJEMY_DATA_TYPES = {\r\n    'UUIDField': lambda field: UUID()\r\n}\r\n```"}}
{"actor":{"display_login":"fearofcode"}}