Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement FromSql for tuples up to length 4#626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
benesch wants to merge1 commit intorust-postgres:master
base:master
Choose a base branch
Loading
frombenesch:tuple-from-sql

Conversation

benesch
Copy link
Contributor

This makes it very ergonomic to decode the results of a query like

SELECT (1, 'a')

where (1, 'a') is returned as an anonymous record type.

The big downside to this approach is that only built-in OIDs are
supported, as there is no way to know ahead of time what OIDs will be
returned, and so we'll only have metadata for the built-in OIDs lying
around.

Fix#310. Also related to#366 and#565.

skreborn, WGH-, aobatact, and myypo reacted with thumbs up emoji
This makes it very ergonomic to decode the results of a query like    SELECT (1, 'a')where (1, 'a') is returned as an anonymous record type.The big downside to this approach is that only built-in OIDs aresupported, as there is no way to know ahead of time what OIDs will bereturned, and so we'll only have metadata for the built-in OIDs lyingaround.
@AtsukiTak
Copy link

Looks great! I'm very interested in this feature!
It would be nice for me if it is also implemented for tuples more than 5 items under some feature gate just likediesel's32-column-tables,64-column-tables and128-column-tables features. 😄

I hope this PR will be merged!

@skreborn
Copy link

@sfackler Is there anything - other than a rebase - that prevents this from being merged? I agree thatat least 8 tuple items should be supported, but adding huge numbers seems excessive for a first implementation. We can always add more (behind feature flags) later, building on this PR.

Right now, we're forced to implement this ourselves, and it would help tremendously to have built-in support for tuples.

@WGH-
Copy link

This is a useful feature.

Maybe not so on its own: who writesSELECT (foo, bar) ... instead ofSELECT foo, bar, after all?

But if you do things likeSELECT t1, array_agg((t2.foo, t2.bar)) FROM t1 NATURAL JOIN t2 GROUP BY t1.id, support for therecord type suddenly becomes much more useful. This example would also require support for therecord[] type, but that would be the next step.

wquark added a commit to cubexch/rust-postgres that referenced this pull requestJul 21, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

FromSql for a type Record
4 participants
@benesch@AtsukiTak@skreborn@WGH-

[8]ページ先頭

©2009-2025 Movatter.jp