Title: Bug: fetch in DJ2.0 behaves differently compared to DJ. 0.14 · Issue #1381 · datajoint/datajoint-python · GitHub
Open Graph Title: Bug: fetch in DJ2.0 behaves differently compared to DJ. 0.14 · Issue #1381 · datajoint/datajoint-python
X Title: Bug: fetch in DJ2.0 behaves differently compared to DJ. 0.14 · Issue #1381 · datajoint/datajoint-python
Description: Bug Report Description Now that fetch has returned for backwards compatibility. I see 3 differences which might still lead to issues: fetch seems not to be classmethod anymore fetch defaults to as_dict=True in dj.2.0 but was as_dict=Fals...
Open Graph Description: Bug Report Description Now that fetch has returned for backwards compatibility. I see 3 differences which might still lead to issues: fetch seems not to be classmethod anymore fetch defaults to as_...
X Description: Bug Report Description Now that fetch has returned for backwards compatibility. I see 3 differences which might still lead to issues: fetch seems not to be classmethod anymore fetch defaults to as_...
Opengraph URL: https://github.com/datajoint/datajoint-python/issues/1381
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: fetch in DJ2.0 behaves differently compared to DJ. 0.14","articleBody":"## Bug Report\n\n### Description\nNow that fetch has returned for backwards compatibility. I see 3 differences which might still lead to issues:\n\n1. fetch seems not to be classmethod anymore\n2. fetch defaults to as_dict=True in dj.2.0 but was as_dict=False in dj.0.14\n3. fetch('KEY') doesnt work \n\n### Reproducibility\n\n```\nimport numpy as np\nimport datajoint as dj\n\ndj.conn() # using datajoint.json\nschema = dj.Schema(\"TEST\")\n\n@schema\nclass RandomLookup(dj.Lookup):\n definition = \"\"\"\n idx: int32\n ---\n values1: float32\n \"\"\"\n contents = [(0, 0.0), (1, 1.0), (2, 2.0), (3, 3.0), (4, 4.0)]\n```\n\n1. \n`\nRandomLookup.fetch('values1') # works in dj.014\n `\n```\n---------------------------------------------------------------------------\nAttributeError Traceback (most recent call last)\nCell In[38], line 1\n----\u003e 1 RandomLookup.fetch('values1')\n\nFile ~/datajoint-python/src/datajoint/expression.py:654, in QueryExpression.fetch(self, offset, limit, order_by, format, as_dict, squeeze, *attrs)\n 651 return self.to_dicts(order_by=order_by, limit=limit, offset=offset, squeeze=squeeze)\n 653 # Default: return structured array (legacy behavior)\n--\u003e 654 return self.to_arrays(order_by=order_by, limit=limit, offset=offset, squeeze=squeeze)\n\nAttributeError: 'str' object has no attribute 'to_arrays'\n```\n2.\n`\nprint(isinstance(RandomLookup().fetch('values1')[0],dict)) # True \n`\n\n`\nprint(isinstance(RandomLookup().fetch('values1',as_dict=False)[0],dict)) # False \n`\n\n3.\n\n`RandomNumbers().fetch('KEY')`\n\n```\n---------------------------------------------------------------------------\nDataJointError Traceback (most recent call last)\nCell In[41], line 1\n----\u003e 1 RandomNumbers().fetch('KEY')\n\nFile ~/datajoint-python/src/datajoint/expression.py:644, in QueryExpression.fetch(self, offset, limit, order_by, format, as_dict, squeeze, *attrs)\n 641 if attrs:\n 642 if as_dict or as_dict is None:\n 643 # fetch('col1', 'col2', as_dict=True) or fetch('col1', 'col2')\n--\u003e 644 return self.proj(*attrs).to_dicts(order_by=order_by, limit=limit, offset=offset, squeeze=squeeze)\n 645 else:\n 646 # fetch('col1', 'col2', as_dict=False) -\u003e tuple of arrays\n 647 return self.to_arrays(*attrs, order_by=order_by, limit=limit, offset=offset, squeeze=squeeze)\n\nFile ~/datajoint-python/src/datajoint/expression.py:498, in QueryExpression.proj(self, *attributes, **named_attributes)\n 496 # check that all attributes exist in heading\n 497 try:\n--\u003e 498 raise DataJointError(\"Attribute `%s` not found.\" % next(a for a in attributes if a not in self.heading.names))\n 499 except StopIteration:\n 500 pass # all ok\n\nDataJointError: Attribute `KEY` not found.\n```","author":{"url":"https://github.com/arturoptophys","@type":"Person","name":"arturoptophys"},"datePublished":"2026-02-05T14:07:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1381/datajoint-python/issues/1381"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2cd81ac7-087f-6572-43b1-95333da191ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A57A:34CFAA:119FB14:17E7C65:6A4D671E |
| html-safe-nonce | 562a238fa8a4de7cda58d8f08caec5c2bf7cfe4499d97877d86ef4d26bc240f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTdBOjM0Q0ZBQToxMTlGQjE0OjE3RTdDNjU6NkE0RDY3MUUiLCJ2aXNpdG9yX2lkIjoiOTMyNTc4Mjc2NjcyMzY2MzY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 747fa5ea6bf360b1204b0e2dd40f22464a306ba816e32fec73873dc5b561abc3 |
| hovercard-subject-tag | issue:3901772884 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/datajoint/datajoint-python/1381/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5c26371c1e6fb75bb3ab35a5a3195cf0c3661daf9e67ea77470df464f53fe311/datajoint/datajoint-python/issues/1381 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5c26371c1e6fb75bb3ab35a5a3195cf0c3661daf9e67ea77470df464f53fe311/datajoint/datajoint-python/issues/1381 |
| og:image:alt | Bug Report Description Now that fetch has returned for backwards compatibility. I see 3 differences which might still lead to issues: fetch seems not to be classmethod anymore fetch defaults to as_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | arturoptophys |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7db3950e3f59095e20a9789440c3dd554efc62d434882ead06ae05b5815605b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/datajoint/datajoint-python git https://github.com/datajoint/datajoint-python.git |
| octolytics-dimension-user_id | 2375501 |
| octolytics-dimension-user_login | datajoint |
| octolytics-dimension-repository_id | 5866704 |
| octolytics-dimension-repository_nwo | datajoint/datajoint-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 5866704 |
| octolytics-dimension-repository_network_root_nwo | datajoint/datajoint-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cd8f6a71db61d6012a0cbb134be844fdbe9b8a45 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width