Open zond opened 9 months ago
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.
So you might be interested in the insert statement feature?
Do you have any particular thoughts on that or should I just prepare a PR and send you?
On Wed, Feb 28, 2024, 06:51 TLW @.***> wrote:
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.
— Reply to this email directly, view it on GitHub https://github.com/jmoiron/sqlx/issues/912#issuecomment-1968282313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAB25MG7BAQPLD66NLWMFLYV3AVNAVCNFSM6AAAAABDCQS5BSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGI4DEMZRGM . You are receiving this because you authored the thread.Message ID: @.***>
@zond not a maintainer just wanted to weigh in...
Fair enough :)
On Wed, Feb 28, 2024, 12:23 TLW @.***> wrote:
So you might be interested in the insert statement feature? Do you have any particular thoughts on that or should I just prepare a PR and send you? … <#m-117507800482917100> On Wed, Feb 28, 2024, 06:51 TLW @.> wrote: 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. — Reply to this email directly, view it on GitHub <#912 (comment) https://github.com/jmoiron/sqlx/issues/912#issuecomment-1968282313>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAB25MG7BAQPLD66NLWMFLYV3AVNAVCNFSM6AAAAABDCQS5BSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGI4DEMZRGM https://github.com/notifications/unsubscribe-auth/AAAB25MG7BAQPLD66NLWMFLYV3AVNAVCNFSM6AAAAABDCQS5BSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYGI4DEMZRGM . You are receiving this because you authored the thread.Message ID: @.>
not a maintainer... just wanted to weigh in 🙃
— Reply to this email directly, view it on GitHub https://github.com/jmoiron/sqlx/issues/912#issuecomment-1968775058, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAB25PYBGFROU5TZBCDTX3YV4HSTAVCNFSM6AAAAABDCQS5BSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYG43TKMBVHA . You are receiving this because you authored the thread.Message ID: @.***>
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?