gocqlx icon indicating copy to clipboard operation
gocqlx copied to clipboard

schemagen: generate go structs for tables

Open mmatczuk opened this issue 4 years ago • 6 comments

This is a followup to #201. We can now generate the table model but still the structs need to written by hand.

Gocqlx supports UDTs automatically by embedding a special marker interface. Plain fields should be simple to generate.

Overall the tool should gain ability to generate the table structs.

mmatczuk avatar Nov 19 '21 09:11 mmatczuk

@Bobochka maybe you would be interested in this one.

mmatczuk avatar Nov 19 '21 09:11 mmatczuk

Hey @mmatczuk, I would like to work on this. I already started doing something, can you take a look? https://github.com/pavle995/gocqlx/tree/structs-tables

pavle995 avatar Dec 10 '21 08:12 pavle995

Nice work, keep it up, it needs some testing. It will be required to change from gocql.UUID to a different UUID type.

mmatczuk avatar Dec 10 '21 11:12 mmatczuk

Thanks for guidelines. I've added test for map_types.go and updated existing test for schemagen.go. I've also added example in test_examples.go. I've changed from gocql.UUID to [16]byte. This may be a silly question, but why we can't use gocql.UUID?

pavle995 avatar Dec 12 '21 08:12 pavle995

There are so many uuid types, we allow for flexibility. I think the point here is to be able to configure the tool to provide a custom import path for UUID. Please send a PR if you think this is ready.

mmatczuk avatar Dec 20 '21 12:12 mmatczuk

Any update on this issue?

Sumit2202 avatar Nov 16 '22 02:11 Sumit2202