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

Help with case + notnull. #1220

Open
nrathi opened this issue Nov 16, 2024 · 1 comment
Open

Help with case + notnull. #1220

nrathi opened this issue Nov 16, 2024 · 1 comment
Labels
api Related to library's API question Further information is requested typescript Related to Typescript

Comments

@nrathi
Copy link

nrathi commented Nov 16, 2024

Help with this would be appreciated! I'm trying to access the "type" key but TS is complaining because it thinks it may be null. I tried to narrow the type but it's still not working. Thanks in advance.

    const queryWithNotNull = baseQuery
      .where("metadata", "is not", null)
      .$narrowType<{ metadata: NotNull }>();

      return queryWithNotNull.select((eb) =>
        eb.fn
          .sum(
            eb
              .case()
              .when(eb.ref("metadata", "->>").key("type"), "=", "some-type")
              .then(10)
              .else(0)
              .end(),
          )
          .as("some-name")
@igalklebanov
Copy link
Member

Hey 👋

For people to help you on the internet, it's best to provide a reproduction or enough info for one.
You did neither.

Please share a kyse.link.

@igalklebanov igalklebanov added question Further information is requested api Related to library's API typescript Related to Typescript labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API question Further information is requested typescript Related to Typescript
Projects
None yet
Development

No branches or pull requests

2 participants