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

[BUG]: Neon serverless driver accepts authToken as a promise, but the $withAuth does not #3597

Closed
1 task done
pffigueiredo opened this issue Nov 22, 2024 · 1 comment
Closed
1 task done
Assignees
Labels
bug Something isn't working priority Will be worked on next qb/crud

Comments

@pffigueiredo
Copy link
Contributor

pffigueiredo commented Nov 22, 2024

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.36.4

What version of drizzle-kit are you using?

0.27.1

Other packages

No response

Describe the Bug

Description

The @neondatabase/serverless driver allows to pass in authToken as functions, however, the recently introduced $withAuth only accepts string.

e.g.

Working example

 const db = drizzle(
        neon(process.env.NEXT_PUBLIC_DATABASE_AUTHENTICATED_URL!, {
              // returning a promise here works ✅
          authToken: () => Promise.resolve('my token'),
        }),
        { schema }
 );

Bugged example

      const db = drizzle(
        neon(process.env.NEXT_PUBLIC_DATABASE_AUTHENTICATED_URL!),
        { schema }
      );
      return db
      // only allows `string` ❌
        .$withAuth(() => Promise.resolve('my token'))
        .select()
        .from(schema.todos);

For this particular example, it doesn't seem too worrisome, but drizzle-orm should still use the same types as the Neon driver when possible, which seems like the case here 👀

@AndriiSherman
Copy link
Member

Fixed in drizzle-orm@0.37.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority Will be worked on next qb/crud
Projects
None yet
Development

No branches or pull requests

4 participants