Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Inverse of Get/Select? #912

Open
zond opened this issue Feb 10, 2024 · 4 comments
Open

[Question] Inverse of Get/Select? #912

zond opened this issue Feb 10, 2024 · 4 comments

Comments

@zond
Copy link

zond commented Feb 10, 2024

I find it amazingly useful to just call Get or Select instead of having to recursively loop through my struct fields and assign to them myself.

But it's equally annoying to loop through them to build an INSERT or UPDATE.

Is it feasible to create functions that does this in sqlx? If you think so, please give me advice about how you think it ought to work and I'll give it a shot.

Another useful thing along the same lines would be something that created a CREATE TABLE statement for a struct, possibly with CREATE INDEX statements where needed. Would that be feasible and valuable?

@TinyLittleWheatley
Copy link

TinyLittleWheatley commented Feb 28, 2024

Implicit field names for insert statements sounds nice, but creating tables from structs sounds like an ORM feature.

Also creating such function(that creates CREATE TABLE statements) requires some way of setting all the field properties that user wants per field or just setting some defaults and expect users to modify the statement, or expect them to modify table fields in another query(ALTER TABLE or st).

It all seems like a lot of trouble to automate something that people usually need to customize for themselves in my opinion.

ps: Have you seen gorm? it has both these features and works great if you like the model first approach.

@zond
Copy link
Author

zond commented Feb 28, 2024 via email

@TinyLittleWheatley
Copy link

TinyLittleWheatley commented Feb 28, 2024

@zond not a maintainer just wanted to weigh in...

@zond
Copy link
Author

zond commented Feb 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants