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

support dot in env variable names [e.g. POSTGRESQL.BASE.USER] #93

Merged

Conversation

flamewow
Copy link
Contributor

@flamewow flamewow commented Feb 20, 2023

Supporting dots in environment variable names, like

POSTGRESQL.BASE.USER=postgres
POSTGRESQL.MAIN.USER=${POSTGRESQL.BASE.USER}

lib/main.js Outdated Show resolved Hide resolved
Co-authored-by: Federico Zivolo <5382443+FezVrasta@users.noreply.github.com>
@flamewow
Copy link
Contributor Author

@motdotla hey, wondering if we can get that PR through

@tommelo
Copy link

tommelo commented Nov 24, 2023

@motdotla hey, wondering if we can get that PR through

I just ran into a situation where we got variables containing . and - as well.
Appreciate if this PR could be merged, I can submit another PR to add support to variables containing -.

@motdotla
Copy link
Owner

motdotla commented Feb 6, 2024

for sanity we are not going to support this. the dotenv lib does not nor do other popular dotenv implementations like python's.

https://dotenvx.com/docs/env-file#variable-names

why not just replace the . with a _. do you not have control over the variable name? you certainly do inside your .env file. do you not when going to production?

@motdotla motdotla closed this Feb 6, 2024
@flamewow
Copy link
Contributor Author

flamewow commented Feb 7, 2024

@motdotla
In a big project, a change like that (going from "." to "_") is going to require a cascade of updates.
And it a pain in the ass to get those name changed.

btw, dotenv lib loads such env variables no propblem

@motdotla
Copy link
Owner

motdotla commented Feb 7, 2024

btw, dotenv lib loads such env variables no propblem

you're right. what was i thinking. it can be accessed via process.env['POSTGRESQL.BASE.USER']

let me dig deeper into what other implementations are supporting.

also, can someone give some more color on why you are naming your variables this way.

@motdotla motdotla reopened this Feb 7, 2024
@motdotla
Copy link
Owner

motdotla commented Feb 7, 2024

i think i'm wrong here and @flamewow and others are correct. following the principle of least surprise, this should just work. merging.

@motdotla motdotla merged commit 3cc9bee into motdotla:master Feb 7, 2024
1 check passed
@flamewow
Copy link
Contributor Author

flamewow commented Feb 7, 2024

btw, dotenv lib loads such env variables no propblem

you're right. what was i thinking. it can be accessed via process.env['POSTGRESQL.BASE.USER']

let me dig deeper into what other implementations are supporting.

also, can someone give some more color on why you are naming your variables this way.

Legacy code, otherwise I'd changed them to a format that works.

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

Successfully merging this pull request may close these issues.

None yet

4 participants