Skip to content

It is very non-obvious how to apply limit/offset/order conditionally #491

Open
@neongreen

Description

@neongreen

I want to apply limit_ conditionally, like this:

select_ $
  if limitNeeded then limit_ 10 else id $
  all_ someTable

This fails with cannot construct the infinite type: s ~ QNested s. I get that limit_ changes the type and id doesn't, but I can't figure out what I can use instead of id. I thought subselect_ could work, but I'm getting ugly nested queries when limitNeeded is false:

SELECT `t0`.`res0` AS `res0`, `t0`.`res1` AS `res1` FROM
  (SELECT `t0`.`email` AS `res0`, `t0`.`enabled` AS `res1` FROM `table` AS `t0`)

Any advice?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions