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

feat: add support to specify tables in list of columns #13

Merged
merged 4 commits into from
Jan 3, 2022

Conversation

imreACTmd
Copy link
Collaborator

Now you can replace columns in a specifiic table instead of all tables that have the same column name. You can also specify different replacements for the same column name in different table.

also fixed a bug where a static word replacement was overridden by faker.random.word.

Merry Christmas!

@imreACTmd
Copy link
Collaborator Author

Any comments @rap2hpoutre ?

Copy link
Owner

@rap2hpoutre rap2hpoutre left a comment

Choose a reason for hiding this comment

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

Thank you (again) for your help and to keep this lib alive thanks to your work 🙏

Just before I approve this PR, I want to be sure / is the "correct" character to specify tables names. In another (super similar) library I created for mongodb, I choose to separate the collection from fields with dots: https://github.com/rap2hpoutre/mongodb-anonymizer#specify-list-of-fields-to-anonymize

users.email,products.price

So in our case it could be just:

public.user.email,public.product.description

And for a more complicated case using faker it could be:

public.user.firstName:faker.name.firstName

I would eventually prefer using this syntax because:

What do you think?

README.md Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@imreACTmd
Copy link
Collaborator Author

I thought that dots would be allowed in column names, but I reviewed the postgresql docs and they are not allowed, so I support switching from / to . and will do the change.

@imreACTmd
Copy link
Collaborator Author

OK updated based on your comments.

@rap2hpoutre rap2hpoutre self-requested a review January 2, 2022 10:35
Copy link
Owner

@rap2hpoutre rap2hpoutre left a comment

Choose a reason for hiding this comment

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

🎉 Thank you, you can merge it! I will release it on NPM right after (in the meanwhile, I guess I will add semantic release in order to automate the release process that should not rely only on my will).

EDIT: I just added an issue here: #14

@rap2hpoutre rap2hpoutre changed the title add support to specify tables in list of columns feat: add support to specify tables in list of columns Jan 2, 2022
@imreACTmd
Copy link
Collaborator Author

Let me look at issue #14 and add those. I have two more things I'd like to add - load the replacement list from a file, and send the output to stdout. Should I add that to this PR, or start a new one?

@rap2hpoutre
Copy link
Owner

I suggest we open one PR for each subject. I guess this PR is mergeable as-is then. Feel free to merge it now! (I can also merge it myself if you prefer!)

This was referenced Jan 2, 2022
@imreACTmd imreACTmd merged commit bc6638d into rap2hpoutre:main Jan 3, 2022
github-actions bot pushed a commit that referenced this pull request Mar 13, 2022
# [0.5.0](v0.4.0...v0.5.0) (2022-03-13)

### Features

* add support to specify tables in list of columns ([#13](#13)) ([bc6638d](bc6638d))
* new option to read replacements from a file ([#18](#18)) ([a7c6441](a7c6441))
* output can be stdout so you can pipe it to other commands ([#19](#19)) ([11e46ce](11e46ce))
* table name to extension functions ([#8](#8)) ([9f0a8f8](9f0a8f8))
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