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

fix: postgresql protocol in database connection string assumes MongoDB database #7688

Closed
wants to merge 7 commits into from

Conversation

pmmlo
Copy link

@pmmlo pmmlo commented Nov 10, 2021

New Pull Request Checklist

  • [x ] I am not disclosing a vulnerability.
  • [x ] I am creating this PR in reference to an issue.

Issue Description

This allows developers to use both valid PostgreSQL URI prefixes: "postgresql://" or "postgres://".

Reference: PostgreSQL Connection String Documentation

Related issue: #7687

Approach

I added a switch case for postgresql protocol to get the PostgresStorageAdapter.

TODOs before merging

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK
  • A changelog entry is created automatically using the pull request title (do not manually add a changelog entry)

- This should allow developers to designate either postgres:// or postgresql:// prefixed URIs for PostgreSQL.
@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 10, 2021

Thanks for opening this pull request!

  • ❌ Please edit your post and use the provided template when creating a new pull request. This helps everyone to understand your post better and asks for essential information to quicker review the pull request.

@pmmlo pmmlo changed the title Add postgresql protocol case to getDatabaseAdapter Fix: Add postgresql protocol case to getDatabaseAdapter Nov 10, 2021
@pmmlo pmmlo changed the title Fix: Add postgresql protocol case to getDatabaseAdapter fix: add postgresql protocol case to getDatabaseAdapter Nov 10, 2021
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test for that protocol?

@@ -232,6 +232,12 @@ export function getDatabaseAdapter(databaseURI, collectionPrefix, databaseOption
collectionPrefix,
databaseOptions,
});
case 'postgresql:':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use fall-through behavior instead of duplicating code

@mtrezza mtrezza changed the title fix: add postgresql protocol case to getDatabaseAdapter fix: postgresql protocol in database connection string assumes MongoDB database Nov 10, 2021
@codecov
Copy link

codecov bot commented Nov 12, 2021

Codecov Report

Merging #7688 (5ceffc0) into alpha (826aa79) will decrease coverage by 0.10%.
The diff coverage is 0.00%.

❗ Current head 5ceffc0 differs from pull request most recent head 683369e. Consider uploading reports for the commit 683369e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##            alpha    #7688      +/-   ##
==========================================
- Coverage   93.98%   93.87%   -0.11%     
==========================================
  Files         183      183              
  Lines       13655    13625      -30     
==========================================
- Hits        12833    12791      -42     
- Misses        822      834      +12     
Impacted Files Coverage Δ
src/Controllers/index.js 96.70% <0.00%> (-1.05%) ⬇️
src/GraphQL/transformers/query.js 82.95% <0.00%> (-6.82%) ⬇️
src/batch.js 91.37% <0.00%> (-3.36%) ⬇️
src/GraphQL/transformers/mutation.js 94.33% <0.00%> (-2.84%) ⬇️
src/Utils.js 95.74% <0.00%> (-2.01%) ⬇️
src/ParseServerRESTController.js 97.01% <0.00%> (-1.47%) ⬇️
src/Adapters/Files/GridFSBucketAdapter.js 79.50% <0.00%> (-0.82%) ⬇️
src/Controllers/DatabaseController.js 93.78% <0.00%> (-0.08%) ⬇️
src/Adapters/Auth/gcenter.js 98.21% <0.00%> (-0.04%) ⬇️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 95.45% <0.00%> (-0.02%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 826aa79...683369e. Read the comment docs.

@pmmlo pmmlo closed this Jan 17, 2022
@mtrezza
Copy link
Member

mtrezza commented Jan 17, 2022

Closed because already fixed as #7757

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.

2 participants