Skip to content

Conversation

@eggplannt
Copy link

@eggplannt eggplannt commented May 27, 2025

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

Please include a description of the problem or feature this PR is addressing.

Description of Changes:

  • Adds sqlc as an advanced option
  • Edited and created templates accordingly
  • Edited linter to test sqlc
  • added Query to database.service for relevant drivers

closes #400

Checklist

name: Install Sqlc & gen code
run: |
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
/home/runner/go/bin/sqlc generate -f ${{ env.PROJECT_DIRECTORY }}/sqlc.yaml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this lead to breaking changes if the go bin is not in /hom/runne/go/bin?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this is the same way templ is installed, and unless the name of the runner user changes (which is highly unlikely) it should work fine

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use $(go env GOPATH)/bin/sqlc instead of /home/runner/go/bin/sqlc

}

steps := steps.InitSteps(flagFramework, flagDBDriver)
optionSteps := steps.InitSteps(flagFramework, flagDBDriver)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the rename here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I needed to use the 'steps' package later

cmd/create.go Outdated
Comment on lines 207 to 208
if project.DBDriver != flags.Postgres && project.DBDriver != flags.MySql && project.DBDriver != flags.Sqlite {
step.Options = slices.DeleteFunc(step.Options, func(s steps.Item) bool { return s.Flag == "Sqlc" })
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a cleaner way to do this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk this is the most seamless solution I could come up with for the UX. Although I agree the code is a bit jank, have any suggestions?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a cleaner solution

supportedDrivers := []flags.Database{flags.Postgres, flags.MySql, flags.Sqlite}

if !slices.Contains(supportedDrivers, project.DBDriver) {
    step.Options = slices.DeleteFunc(step.Options, func(s steps.Item) bool {
        return s.Flag == "Sqlc"
    })
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks I'll add that right now

@StevenACoffman
Copy link

@Melkeydev Just checking in, but are you able to merge this PR now after it addressed the feedback?

@vorosdev
Copy link

vorosdev commented Oct 8, 2025

@StevenACoffman @Melkeydev There’s still some documentation that needs to be updated with the recent changes. I’ve already opened a PR to the sqlc branch of @eggplannt with those updates, but it hasn’t been merged yet.

Update sqlc branch with latest main and add documentation
@OverchargedZebra
Copy link

Are there any updates on this pull request?

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

Successfully merging this pull request may close these issues.