Title: Interpret None as NULL in inserts · Issue #467 · datajoint/datajoint-python · GitHub
Open Graph Title: Interpret None as NULL in inserts · Issue #467 · datajoint/datajoint-python
X Title: Interpret None as NULL in inserts · Issue #467 · datajoint/datajoint-python
Description: In tables with NULL default values, insert behavior is inconsistent: If a dictionary-style insert is performed using a dictionary without a key corresponding to the default-null field, the operation proceeds. In the case of a dictionary-...
Open Graph Description: In tables with NULL default values, insert behavior is inconsistent: If a dictionary-style insert is performed using a dictionary without a key corresponding to the default-null field, the operatio...
X Description: In tables with NULL default values, insert behavior is inconsistent: If a dictionary-style insert is performed using a dictionary without a key corresponding to the default-null field, the operatio...
Opengraph URL: https://github.com/datajoint/datajoint-python/issues/467
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Interpret None as NULL in inserts","articleBody":"In tables with `NULL` default values, insert behavior is inconsistent:\r\n\r\nIf a dictionary-style insert is performed using a dictionary without a key corresponding to the default-null field, the operation proceeds. In the case of a dictionary-style insert where the default-null field is present and set to `None`, or in the case of a list-style insert with an appropriately given positional `None`, the operation fails. \r\n\r\nHowever, on the fetch side, records are returned with `None` as a present and populated value.\r\n\r\n```\r\n\u003e\u003e\u003e print(OtherNull.definition)\r\n\r\n otherid: integer\r\n ---\r\n otherthing=NULL: varchar(255)\r\n \r\n\u003e\u003e\u003e OtherNull().insert1({'otherid': 1})\r\n\u003e\u003e\u003e OtherNull().insert1({'otherid': 2, 'otherthing': None})\r\nTraceback (most recent call last):\r\n File \"\u003cconsole\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/datajoint/base_relation.py\", line 137, in insert1\r\n self.insert((row,), **kwargs)\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/datajoint/base_relation.py\", line 278, in insert\r\n itertools.chain.from_iterable((v for v in r['values'] if v is not None) for r in rows)))\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/datajoint/connection.py\", line 133, in query\r\n cur.execute(query, args)\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/pymysql/cursors.py\", line 163, in execute\r\n query = self.mogrify(query, args)\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/pymysql/cursors.py\", line 142, in mogrify\r\n query = query % self._escape_args(args, conn)\r\nTypeError: not enough arguments for format string\r\n\u003e\u003e\u003e OtherNull().insert1((2, None,))\r\nTraceback (most recent call last):\r\n File \"\u003cconsole\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/datajoint/base_relation.py\", line 137, in insert1\r\n self.insert((row,), **kwargs)\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/datajoint/base_relation.py\", line 278, in insert\r\n itertools.chain.from_iterable((v for v in r['values'] if v is not None) for r in rows)))\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/datajoint/connection.py\", line 133, in query\r\n cur.execute(query, args)\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/pymysql/cursors.py\", line 163, in execute\r\n query = self.mogrify(query, args)\r\n File \"/Users/chris/Workspace/mlims-pipeline.ve/lib/python3.6/site-packages/pymysql/cursors.py\", line 142, in mogrify\r\n query = query % self._escape_args(args, conn)\r\nTypeError: not enough arguments for format string\r\n```\r\non the fetch side, None is used as a substitute:\r\n```\r\n\u003e\u003e\u003e OtherNull()\r\n*otherid otherthing \r\n+---------+ +------------+\r\n1 None \r\n (1 tuples)\r\n\r\n\u003e\u003e\u003e OtherNull().fetch()\r\narray([(1, None)], dtype=[('otherid', '\u003ci8'), ('otherthing', 'O')])\r\n\u003e\u003e\u003e OtherNull().fetch1()\r\nOrderedDict([('otherid', 1), ('otherthing', None)])\r\n```\r\n","author":{"url":"https://github.com/ixcat","@type":"Person","name":"ixcat"},"datePublished":"2018-04-25T02:37:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/467/datajoint-python/issues/467"}
| 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:71993e70-feae-053c-0176-022b820ad1b7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB84:5105D:20E887A:2D4635E:6A4ED4C5 |
| html-safe-nonce | 63b66f245768aa1d3e9169764e4d4ec179864257d4d2c83d8cddf03d5e87574c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjg0OjUxMDVEOjIwRTg4N0E6MkQ0NjM1RTo2QTRFRDRDNSIsInZpc2l0b3JfaWQiOiI5NjM2NDgwNzQzODY2OTEyNjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 93997b2121066f813d8e1fe5306fad0a666efe35db5da9e0ec1729d5b98927d2 |
| hovercard-subject-tag | issue:317459776 |
| 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/467/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c98463855b67568c7eacc786ab7b50f88cc3aa7ebe63a38d53be077ad5a23ff4/datajoint/datajoint-python/issues/467 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c98463855b67568c7eacc786ab7b50f88cc3aa7ebe63a38d53be077ad5a23ff4/datajoint/datajoint-python/issues/467 |
| og:image:alt | In tables with NULL default values, insert behavior is inconsistent: If a dictionary-style insert is performed using a dictionary without a key corresponding to the default-null field, the operatio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ixcat |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| 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 | c37fe3e3f5f306900bd5b6bee97463f66c938b2c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width