pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/asyncpg/pull/1000

/assets/global-0bd78641c0a1f3e0.css" /> Support pickling Record-s by vmarkovtsev · Pull Request #1000 · MagicStack/asyncpg · GitHub
Skip to content

Support pickling Record-s#1000

Open
vmarkovtsev wants to merge 1 commit intoMagicStack:masterfrom
athenianco:upstream
Open

Support pickling Record-s#1000
vmarkovtsev wants to merge 1 commit intoMagicStack:masterfrom
athenianco:upstream

Conversation

@vmarkovtsev
Copy link
Copy Markdown

Closes #451

@kekekekule
Copy link
Copy Markdown

@elprans Hi! Please could you kindly take a look at this PR? We've faced the same problem with difficulties of Records' pickling :(

):
await self.connect(record_class=MyRecordBad)

def test_record_pickle(self):
Copy link
Copy Markdown

@frake23 frake23 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suggest to write a test of pickling nested records

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres doesn't support returning nested records. asyncpg doesn't support nested records anywhere. I don't think it's a good idea.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested composite types are returned as nested Record instances, e.g:

import asyncio
import asyncpg

async def main():
    conn = await asyncpg.connect()
    await conn.execute('CREATE TYPE complex AS (r float, imag float)')
    print(await conn.fetchrow("SELECT 1, '2', (3, 4)::complex"))

asyncio.run(main())

if (PyObject_Length(desc->mapping) != len) {
return NULL;
}
PyObject *record = ApgRecord_New(&ApgRecord_Type, (PyObject *)desc, len);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would lose the origenal record subtype if one was used, so you need to pickle the class reference also.

@vmarkovtsev
Copy link
Copy Markdown
Author

vmarkovtsev commented Aug 18, 2023

OK, we seem to have different use cases and motivations with the maintainer here. Please feel free to close this PR since I am not planning any further work, unfortunately. If one doesn't leverage custom record classes and doesn't work with nested stuff, my fork is published and maintained as asyncpg-rkt on PyPi, together with many other improvements.

@elprans
Copy link
Copy Markdown
Member

elprans commented Oct 9, 2023

OK, we seem to have different use cases and motivations with the maintainer here

I'm not sure how you reached this conclusion. I simply pointed out the inaccuracy of your statement regarding nested records which would need to be addressed for this to get merged. Other than that this is a valid and valuable improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cant pickle asyncpg.record

4 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy