Title: Return inet and cidr values as ipaddress objects by default · Issue #119 · PyGreSQL/PyGreSQL · GitHub
Open Graph Title: Return inet and cidr values as ipaddress objects by default · Issue #119 · PyGreSQL/PyGreSQL
X Title: Return inet and cidr values as ipaddress objects by default · Issue #119 · PyGreSQL/PyGreSQL
Description: Since #43 (6.3), objects of the ipaddress module can be passed as parameters everywhere in pg and pgdb, also inline and as elements of arrays and records. Addresses and interfaces are adapted as inet, networks as cidr, as in psycopg 3. 6...
Open Graph Description: Since #43 (6.3), objects of the ipaddress module can be passed as parameters everywhere in pg and pgdb, also inline and as elements of arrays and records. Addresses and interfaces are adapted as in...
X Description: Since #43 (6.3), objects of the ipaddress module can be passed as parameters everywhere in pg and pgdb, also inline and as elements of arrays and records. Addresses and interfaces are adapted as in...
Opengraph URL: https://github.com/PyGreSQL/PyGreSQL/issues/119
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Return inet and cidr values as ipaddress objects by default","articleBody":"Since #43 (6.3), objects of the `ipaddress` module can be passed as parameters everywhere in `pg` and `pgdb`, also inline and as elements of arrays and records. Addresses and interfaces are adapted as `inet`, networks as `cidr`, as in psycopg 3.\n\n6.3 also added the typecast functions `cast_inet()` and `cast_cidr()` in `pg.cast` and `pgdb.cast`. Like in psycopg 3, `cast_inet()` returns an `ip_interface()` for values with a prefix length and an `ip_address()` for other values, and `cast_cidr()` returns an `ip_network()`. They are not used by default, but can be set with:\n\n```python\nfrom pg.cast import cast_cidr, cast_inet # or from pgdb.cast\n\npg.set_typecast('inet', cast_inet) # or pgdb.set_typecast\npg.set_typecast('cidr', cast_cidr)\n```\n\nBy default, `inet` and `cidr` values are still returned as strings. Making these casts the default would be a breaking change for code that works with the returned strings: comparisons like `row.ip == '10.0.0.1'` would silently become false, and `json.dumps()` or string operations would fail. So I plan to change the default only in 7.0, by adding the two casts to the default typecasts of `pg` and `pgdb`.\n\nNotes:\n\n- `macaddr` and `macaddr8` have no type in the standard library and stay strings (also in psycopg 3).\n- IPv6 addresses with a scope id (`fe80::1%eth0`) are accepted by Python, but not by PostgreSQL, so they cannot occur in results.\n\n","author":{"url":"https://github.com/Cito","@type":"Person","name":"Cito"},"datePublished":"2026-11-22T15:59:50Z","url":"https://github.com/PyGreSQL/PyGreSQL/issues/119"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:2e1c4884-c77c-8e56-2561-89497f42c1ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC1C:259D98:330A3:46D2E:6B046167 |
| html-safe-nonce | 5b2d0c92ea727ede6960451c2f48af9306ff28be0d0b1223f0712af945795a29 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzFDOjI1OUQ5ODozMzBBMzo0NkQyRTo2QjA0NjE2NyIsInZpc2l0b3JfaWQiOiIxNzUzMDkyMDExNDgyOTY0MzI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e2f7c9e3c4e8f137716078d2cb57c020d607ceb9e4a93fbc8850f095379cbebb |
| hovercard-subject-tag | issue:6544518288 |
| 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/PyGreSQL/PyGreSQL/119/issue_layout |
| twitter:image | https://opengraph.githubassets.com/06e8a85bfea7da1c3a1342c0458d83f16b2fed560c56985be3b49d52ba2d9315/PyGreSQL/PyGreSQL/issues/119 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/06e8a85bfea7da1c3a1342c0458d83f16b2fed560c56985be3b49d52ba2d9315/PyGreSQL/PyGreSQL/issues/119 |
| og:image:alt | Since #43 (6.3), objects of the ipaddress module can be passed as parameters everywhere in pg and pgdb, also inline and as elements of arrays and records. Addresses and interfaces are adapted as in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Cito |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/PyGreSQL/PyGreSQL git https://github.com/PyGreSQL/PyGreSQL.git |
| octolytics-dimension-user_id | 60857770 |
| octolytics-dimension-user_login | PyGreSQL |
| octolytics-dimension-repository_id | 51212044 |
| octolytics-dimension-repository_nwo | PyGreSQL/PyGreSQL |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 51212044 |
| octolytics-dimension-repository_network_root_nwo | PyGreSQL/PyGreSQL |
| 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 | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width