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

pg_namespace to disambiguate repeated field name #149

Merged
merged 3 commits into from Feb 13, 2022

Conversation

mbeynon
Copy link
Contributor

@mbeynon mbeynon commented Feb 5, 2022

This change fixes the TABLE_COLUMNS_QUERY to work as intended, but using pg_catalog.pg_namespace to disambiguate a case where the same name is used for a custom enum type in more than one schema (namespace) in the database.

Unfixed, this can result in pg_datanymizer building a list of columns with duplicate column names each time the name appears across all the namespaces. The COPY command is rejected by postgres, and the run is aborted.

See issue #148 for more details.

Testable example: (enum event_type defined in 3 namespaces)
schema.dump.txt
test2.yaml.txt

✓ Checklist:

  • This PR has been added to CHANGELOG.md (at the top of the list);
  • ??? Tests for the changes have been added (for bug fixes / features); UNCLEAR HOW THIS CAN BE TESTED in the code, since it depends on the DB representation.
  • Docs have been added / updated (for bug fixes / features).

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2022

Codecov Report

Merging #149 (fd38cdf) into main (f679e34) will decrease coverage by 0.51%.
The diff coverage is n/a.

❗ Current head fd38cdf differs from pull request most recent head 5d2abed. Consider uploading reports for the commit 5d2abed to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #149      +/-   ##
==========================================
- Coverage   86.45%   85.94%   -0.52%     
==========================================
  Files          52       52              
  Lines        3344     3187     -157     
==========================================
- Hits         2891     2739     -152     
+ Misses        453      448       -5     
Impacted Files Coverage Δ
...atanymizer_dumper/src/postgres/schema_inspector.rs 88.40% <ø> (ø)
datanymizer_engine/src/transformers/datetime.rs 74.07% <0.00%> (-8.86%) ⬇️
datanymizer_dumper/src/postgres/dumper.rs 36.72% <0.00%> (-4.70%) ⬇️
datanymizer_engine/src/settings/filter.rs 96.27% <0.00%> (-2.60%) ⬇️
datanymizer_dumper/src/lib.rs 58.82% <0.00%> (-1.79%) ⬇️
datanymizer_dumper/src/postgres/table.rs 95.36% <0.00%> (+0.05%) ⬆️
datanymizer_engine/src/settings/table.rs 84.37% <0.00%> (+12.50%) ⬆️

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 f679e34...5d2abed. Read the comment docs.

@evgeniy-r
Copy link
Member

Hello! Thank you for your contribution. I will take a look.
About testing: we have integration tests, but I can then add a test myself for this case (this may take some time).

@evgeniy-r evgeniy-r linked an issue Feb 5, 2022 that may be closed by this pull request
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.

Malformed query repeats one field multiple times
3 participants