Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolcs-horvath committed Dec 22, 2024
1 parent 86dd679 commit 7dde058
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: sudo apt-get install sqlite3

- name: Install go dependencies
run: make go-deps
run: make install-go-deps

- name: Build
run: make build
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ GOLANG_MIGRATE_VERSION ?= v4.18.1
HTMX_VERSION ?= 2.0.3
BOOTSTRAP_VERSION ?= 5.3.3
GOCOVERDIR ?= coverage
CGO_ENABLED=1 # Required for sqlite3 driver

go-deps:
go install github.com/sqlc-dev/sqlc/cmd/sqlc@$(SQLC_VERSION)
go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@$(GOLANG_MIGRATE_VERSION)
install-go-deps:
go install -v github.com/sqlc-dev/sqlc/cmd/sqlc@$(SQLC_VERSION)
go install -v -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@$(GOLANG_MIGRATE_VERSION)

init-db: migrate-up
sqlite3 $(SQLITE_DB_FILE) < sqlite/seed.sql
Expand Down
4 changes: 2 additions & 2 deletions repository/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func ListItems(ctx context.Context) ([]*Item, error) {
result := make([]*Item, len(list))
for i, n := range list {
result[i] = convertItem(&n.ItemSqlc)
if &n.UserSqlc != nil {
result[i].Owner = convertUser(UserSqlcWrapper{n.UserSqlc})
if &n.ItemsUsersView != nil {
result[i].Owner = convertUser(ItemsUsersViewWrapper{n.ItemsUsersView})
}
result[i].Language = convertLanguage(LanguageSqlcWrapper{n.LanguageSqlc})
result[i].DefaultPortion = convertPortion(&n.PortionSqlc)
Expand Down
4 changes: 2 additions & 2 deletions sqlite/queries/item_queries.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- name: ListItems :many
SELECT sqlc.embed(items), sqlc.embed(users), sqlc.embed(languages), sqlc.embed(portions)
SELECT sqlc.embed(items), sqlc.embed(items_users_view), sqlc.embed(languages), sqlc.embed(portions)
FROM items
LEFT JOIN users ON items.owner_id = users.id
LEFT JOIN items_users_view ON items.owner_id = items_users_view.id
JOIN languages ON items.language_id = languages.id
JOIN portions ON items.default_portion_id = portions.id;

Expand Down

0 comments on commit 7dde058

Please sign in to comment.