Closed mbezhanov closed 2 weeks ago
This is very nice! Exactly what was requested in #120
I'll take a deeper look, but overall looks great 👌🏾
Happy to hear that! I also included PostgreSQL support.
The tests are failing because the new output does not match the golden files....
You should run the generation tests locally with the -overwrite-golden
flag to fix this.
go test ./gen/bobgen-psql/driver -overwrite-golden
Can you also update the SQLite golden file?
Can you also update the SQLite golden file?
Yes, absolutely. I'll actually go ahead and directly implement the SQLite index retrieval logic in this PR. Coming up in a little bit :slightly_smiling_face:
Would you like me to squash everything up to this point into a single commit, or are you planning to squash when merging into main?
Would you like me to squash everything up to this point into a single commit, or are you planning to squash when merging into main?
Kindly squash and push.
I do not squash when merging into main, so the commit history can get a little messy if it is not done beforehand 😬
Pushing an updated version rebased on the latest main
. I've added index listing support to bobgen-mysql
, bobgen-psql
, and bobgen-sqlite
. I can do bobgen-atlas
and bobgen-prisma
in a separate PR, unless you prefer to have them included in this one.
I introduced a NamedColumnList
struct as discussed, but kept Index
and Constraint
as distinct types rather than aliases for better readability:
type Constraint NamedColumnList
type Index NamedColumnList
I found the aliases a bit confusing during debug sessions:
Type declarations seem to be a bit more clear:
However, if you insist on type aliases rather than type declarations, I'd be happy to change them.
Let me know if any further improvements are necessary.
Looks great! Thank you.
I've already merged this now, but I just thought that it would be nice to be able to tell apart different types of indexes (unique vs non-unique)
No problem. I'll add this and open another PR in the following days.
Hi, I am opening this in relation to https://github.com/stephenafamo/bob/issues/120.
This will allow users like @majiaxin110 to range over
.Table.Indexes
in their custom*.tpl
enabling the use of$index.Name
variables in a similar fashion:Sample output:
I only added MySQL support to keep the PR focused and get some early feedback on the implementation. If you approve of it, I'd happily add support for PostgreSQL and SQLite as well.