Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support selecting tuples (and array of tuples) #35

Open
schurhammer opened this issue Oct 16, 2024 · 1 comment
Open

Support selecting tuples (and array of tuples) #35

schurhammer opened this issue Oct 16, 2024 · 1 comment
Labels
enhancement New feature or request type request A request to add support for a PG type

Comments

@schurhammer
Copy link

I like to use arrays of tuples to get related items in a single query

e.g. something like

select
  id,
  name,
  array(select (child_id, dob) from children where cats.id = children.parent_id) as children
from cats

Minimal query:

select array(
    select (1, 'a') union
    select (2, 'b') union
    select (3, 'c')
) as tuple_array;

p.s. I'm willing to help implement if you point me in the right direction 🐱

@giacomocavalieri
Copy link
Owner

giacomocavalieri commented Oct 18, 2024

(Oops I misclicked and sent a message written halfway through closing the issue)
Hello! It sounds interesting, I'm not really sure how that would work myself! Usually the way I do it is I first start writing the sql query and see what kind of error squirrel returns; from there I try to work out what is the unsupported type and how I could turn it into a Gleam type by looking at the pg_type table.

I have a hunch this might not be possible in PG but it might be worth looking into!

@giacomocavalieri giacomocavalieri added enhancement New feature or request type request A request to add support for a PG type labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request type request A request to add support for a PG type
Projects
None yet
Development

No branches or pull requests

2 participants