neosync icon indicating copy to clipboard operation
neosync copied to clipboard

Default transformer to generate value from Enums

Open jasondamour opened this issue 1 year ago • 3 comments

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!

jasondamour avatar Nov 14 '24 20:11 jasondamour

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?

evisdrenova avatar Nov 14 '24 20:11 evisdrenova

@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

jasondamour avatar Nov 14 '24 20:11 jasondamour

@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.

evisdrenova avatar Nov 14 '24 21:11 evisdrenova