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]: When using database url to connect to postgresql (supabase), the url breaks if there unencoded entities in the password. #4010

Open
1 task done
ferran9908 opened this issue Jan 26, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@ferran9908
Copy link

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.38.3

What version of drizzle-kit are you using?

0.30.1

Other packages

No response

Describe the Bug

What is the undesired behavior?
Connection to supabase fails after replacing password in the connection url.

For example if the password contains “#”, it has to be converted to “%23”.

What is the desired result?
The desired result is that the encoding happens automatically under the hood.

@ferran9908 ferran9908 added the bug Something isn't working label Jan 26, 2025
@eyalkutz
Copy link

I just tried this with postgres://user:a#@localhost:5432/postgres as the url and drizzle gives the following error:

 ⨯ [TypeError: Invalid URL] {
  code: 'ERR_INVALID_URL',
  input: 'postgres://user:a#@localhost:5432/postgres',
  base: 'postgres://base',
  digest: '1004449815'
}

however the browser encodeURI() function seems to think there is nothing wrong with it although the URL constructor does error:

const uri = 'postgres://user:a#@localhost:5432/postgres';
undefined
encodeURI(uri)
'postgres://user:a#@localhost:5432/postgres'
new URL(uri)
VM1009:1 Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at <anonymous>:1:1

The only way I could find to get the browser APIs to encode this URL is:

const url=new URL('postgres://user@localhost:5432/postgres')
undefined
url.password='a#'
'a#'
url.toString()
'postgres://user:a%23@localhost:5432/postgres'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants