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

order by result of a lateral join using the select interface? #160

Open
jcoveney-anchorzero opened this issue Oct 26, 2023 · 1 comment
Open

Comments

@jcoveney-anchorzero
Copy link

jcoveney-anchorzero commented Oct 26, 2023

let's say I have two tables

table_a, columns: the_id

and

table_b, columns: the_id, name

and there is a foreign key relationship between table_a and table_b, though that doesn't really affect the following query I suppose!

let's say I have a query as follows

zapatosDb
      .select('table_a', zapatosDb.all, {
        lateral: {
          table_b: zapatosDb.selectExactlyOne(
            'table_b',
            {
              the_id: zapatosDb.parent('the_id'),
            },
          ),
        },
      })
      .run(context.pool);

my goal is to sort this by table_b.name....as far as I know, it's not possible to do this, at least, I haven't figured out a syntax to do it. is this currently possible? or a limitation of the select API?

thank you very much

@jawj
Copy link
Owner

jawj commented Nov 7, 2023

Sorry for the slow reply.

This is a limitation of the API, which would be really good (but as far as I can see not at all easy) to fix.

There is a workaround, as discussed in #62, but it may not be fast enough for you.

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

No branches or pull requests

2 participants