volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.56k stars 533 forks source link

feature: set custom table name for insertion #1375

Open c9s opened 3 months ago

c9s commented 3 months ago

@stephenafamo please take a look,, thanks!

stephenafamo commented 1 month ago

What is the use case for this?

c9s commented 1 month ago

What is the use case for this?

for database sharding, for large datasets we need to move these data in different tables with the same schema

c9s commented 1 month ago

this is the related ticket (discussion) https://github.com/volatiletech/sqlboiler/discussions/1378

stephenafamo commented 1 month ago

for database sharding, for large datasets we need to move these data in different tables with the same schema

Instead of making this change to SQLBoiler, did you consider having extra templates to add an extra method to the models?
https://github.com/volatiletech/sqlboiler?tab=readme-ov-file#templates

c9s commented 1 month ago

for database sharding, for large datasets we need to move these data in different tables with the same schema

Instead of making this change to SQLBoiler, did you consider having extra templates to add an extra method to the models? https://github.com/volatiletech/sqlboiler?tab=readme-ov-file#templates

Hi @stephenafamo

Thank you for the suggestion. I have considered the template approach, but it seems overly complex for this particular need. Given SQLBoiler's status as a modern ORM tool, I believe incorporating native support for database sharding would significantly enhance its utility for projects requiring robust scalability. This feature would not only simplify development but also align SQLBoiler with the evolving demands of large-scale applications.

If SQLBoiler is unable to support this functionality, I may need to explore other solutions that offer built-in sharding capabilities to meet the scalability requirements of my project. I hope we can keep SQLBoiler as our primary ORM tool and avoid the need to switch.

c9s commented 1 month ago

Or maybe you prefer other API design? maybe we can discuss?

stephenafamo commented 1 month ago

The API looks good.

For now, since this is not a very common usecase, I would suggest putting it behind a generation flag.

If you can do that, I'll be happy to merge.

c9s commented 1 month ago

The API looks good.

For now, since this is not a very common usecase, I would suggest putting it behind a generation flag.

If you can do that, I'll be happy to merge.

Sure! I am willing to do that

Thanks!