Ignore table prefixes during generation #427
-
This is the same issue as in sqlc. I know I can use aliases to rename tables, but this is very cumbersome, especially in the case of relationships. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
To achieve this, you'll have to roll your own tool instead of using one of the prebuilt generation tools, but that is not too complicated, you can copy bobgen-mysql/main.go as a starting point, it is less than 100 lines including comments. There are several ways to achieve this: Building a dynamic configWith your tool, you can pass your config directly instead of relying on a Using PluginsYou can use a Plugin (documentation pending...) plugin to achieve a similar thing:
|
Beta Was this translation helpful? Give feedback.
To achieve this, you'll have to roll your own tool instead of using one of the prebuilt generation tools, but that is not too complicated, you can copy bobgen-mysql/main.go as a starting point, it is less than 100 lines including comments.
There are several ways to achieve this:
Building a dynamic config
With your tool, you can pass your config directly instead of relying on a
bobgen.yaml
file. So you can programatically build the config to include the aliases for each table.Using Plugins
You can use a Plugin (documentation pending...) plugin to achieve a similar thing:
StatePlugin
and programatically add the alias configuration to your config.Temp…