-
Notifications
You must be signed in to change notification settings - Fork 902
fix(scripts): append database URLs instead of sed replacement #334
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,11 +68,15 @@ else | |||||||||||||||||||||||||||||
| POOLED_URL=$(neonctl connection-string "$BRANCH_ID" --project-id "$NEON_PROJECT_ID" --pooled) | ||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Copy root .env and override with branch-specific values | ||||||||||||||||||||||||||||||
| # Copy root .env and append branch-specific values | ||||||||||||||||||||||||||||||
| cp "$SUPERSET_ROOT_PATH/.env" .env | ||||||||||||||||||||||||||||||
| sed -i '' "s|^DATABASE_URL=.*|DATABASE_URL=$POOLED_URL|" .env | ||||||||||||||||||||||||||||||
| sed -i '' "s|^DATABASE_URL_UNPOOLED=.*|DATABASE_URL_UNPOOLED=$DIRECT_URL|" .env | ||||||||||||||||||||||||||||||
| echo "NEON_BRANCH_ID=$BRANCH_ID" >> .env | ||||||||||||||||||||||||||||||
| cat >> .env << EOF | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Workspace Database (Neon Branch) | ||||||||||||||||||||||||||||||
| NEON_BRANCH_ID=$BRANCH_ID | ||||||||||||||||||||||||||||||
| DATABASE_URL=$POOLED_URL | ||||||||||||||||||||||||||||||
| DATABASE_URL_UNPOOLED=$DIRECT_URL | ||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||
|
Comment on lines
+73
to
+79
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider quoting/escaping At minimum, consider: -DATABASE_URL=$POOLED_URL
-DATABASE_URL_UNPOOLED=$DIRECT_URL
+DATABASE_URL="${POOLED_URL}"
+DATABASE_URL_UNPOOLED="${DIRECT_URL}"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| success "Neon branch created: $WORKSPACE_NAME" | ||||||||||||||||||||||||||||||
| echo "✨ Done!" | ||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“Append” may not actually override: duplicated keys in
.envare parsed inconsistently across dotenv loaders.This change intentionally avoids
sed-replacement, but now relies on whatever reads.envto pick the last occurrence ofDATABASE_URL/DATABASE_URL_UNPOOLED/NEON_BRANCH_ID. Some consumers treat first definition as authoritative, which would silently ignore the appended block.If you want “append without depending on exact formatting” and deterministic override, consider filtering those keys out before appending:
📝 Committable suggestion
🤖 Prompt for AI Agents