nucleuscloud / neosync

Open source data anonymization and synthetic data orchestration for developers. Create high fidelity synthetic data and sync it across your environments.
https://www.neosync.dev
Other
3.41k stars 125 forks source link

Default transformer to generate value from Enums #2943

Open jasondamour opened 1 week ago

jasondamour commented 1 week ago

Describe the solution you'd like

Offer a built-in transformer for Enums, which selects a random valid enum value.

Describe alternatives you've considered

Defining a custom transformer to select a random value from enum

Requires lots of code duplication

Additional context

Thank you for your feature request – we love each and every one!

evisdrenova commented 1 week ago

hey @jasondamour have you checked out our [GenerateCategorical(https://docs.neosync.dev/transformers/system#generate-categorical) Transformer? This transformer randomly selects a value from a list of comma separated values that the user providers.

Or where you were looking for something different?

jasondamour commented 1 week ago

@evisdrenova I am sadly just getting familiar with MySQL, but could the list of values come from the table schema itself?

I'm trying to avoid code duplication, maintaining a list of values both in our schema and in neosync seems avoidable

evisdrenova commented 1 week ago

@jasondamour That makes sense, unfortunately we don't support that today (hence the enhancement :)). We can certainly look into it and add it to the roadmap. Today, you can use the GenerateCategorial or write a custom javascript transformer using the Generate (Transform) Javascript transformer. Otherwise, if you're not concerned with anonymizing it, you can just pass the value through from the source -> destination using the Passthrough Transformer.