rwnx / pynonymizer

A universal tool for translating sensitive production database dumps into anonymized copies.
https://pypi.org/project/pynonymizer/
MIT License
102 stars 38 forks source link

set column to NULL instead of '' (Empty) #81

Closed msatlow closed 3 years ago

msatlow commented 3 years ago

Currently I can only set a Column to '' (Empty String) with UpdateColumnStrategyTypes.EMPTY.

For my hibernate Application, I would need to set a column to NULL since NULL is different than '' in hibernate Validation.

It would be great, if an additional Column Update stategy could be implemented. e.g. UpdateColumnStrategyTypes.NULL?

Regards, M.

rwnx commented 3 years ago

Hi!

You could use a literal( https://github.com/jerometwell/pynonymizer/blob/master/doc/strategyfiles.md#column-strategy-literal) value, shorthand is a value surrounded by parentheses, e.g. (NULL) and this should get what you need.

table_name:
  columns:
    column_name: (NULL)

I was actually thinking of going the other way and deprecating UpdateColumnStrategyTypes.EMPTY since it's use is quite domain-specific (as you're experiencing 😇)

msatlow commented 3 years ago

Great! Thanks a lot. This solves my problem. Probably this could be added to the documentation? I've search the documentation for the word "NULL" but without success.

rwnx commented 3 years ago

Yeah! I think we should add some more examples the the literal section. If you want to submit a PR for this I'd be more than grateful!