Skip to content

Commit

Permalink
fix: docker build not working with sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Jan 9, 2024
1 parent dc35d71 commit a8ed606
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test-docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docker

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
dockr_build:
runs-on: ubuntu-latest
name: Test Build

steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/holiman/uint256 v1.2.0
github.com/inconshreveable/log15 v0.0.0-20171019012758-0decfc6c20d9
github.com/mattn/go-isatty v0.0.3
github.com/mattn/go-sqlite3 v1.14.9
github.com/mattn/go-sqlite3 v1.14.19
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c
github.com/pkg/errors v0.8.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a h1:8TGB3DFRNl06DB1Q6zBX+I7FDoCUZY2fmMS9WGUIIpw=
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
33 changes: 19 additions & 14 deletions logdb/logdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,22 @@ FROM (%v) e
subQuery += ")"
}

if filter.Order == DESC {
subQuery += " ORDER BY seq DESC "
} else {
subQuery += " ORDER BY seq ASC "
}

if filter.Options != nil {
subQuery += " LIMIT ?, ?"
args = append(args, filter.Options.Offset, filter.Options.Limit)
}

subQuery = "SELECT e.* FROM (" + subQuery + ") s LEFT JOIN event e ON s.seq = e.seq"

return db.queryEvents(ctx, fmt.Sprintf(query, subQuery), args...)
eventQuery := fmt.Sprintf(query, subQuery)

if filter.Order == DESC {
eventQuery += "\nORDER BY seq DESC "
} else {
eventQuery += "\nORDER BY seq ASC "
}

return db.queryEvents(ctx, eventQuery, args...)
}

func (db *LogDB) FilterTransfers(ctx context.Context, filter *TransferFilter) ([]*Transfer, error) {
Expand Down Expand Up @@ -197,19 +199,22 @@ FROM (%v) t
subQuery += ")"
}

if filter.Order == DESC {
subQuery += " ORDER BY seq DESC"
} else {
subQuery += " ORDER BY seq ASC"
}

if filter.Options != nil {
subQuery += " LIMIT ?, ?"
args = append(args, filter.Options.Offset, filter.Options.Limit)
}

subQuery = "SELECT e.* FROM (" + subQuery + ") s LEFT JOIN transfer e ON s.seq = e.seq"
return db.queryTransfers(ctx, fmt.Sprintf(query, subQuery), args...)

transferQuery := fmt.Sprintf(query, subQuery)

if filter.Order == DESC {
transferQuery += "\nORDER BY seq DESC"
} else {
transferQuery += "\nORDER BY seq ASC"
}

return db.queryTransfers(ctx, transferQuery, args...)
}

func (db *LogDB) queryEvents(ctx context.Context, query string, args ...interface{}) ([]*Event, error) {
Expand Down

0 comments on commit a8ed606

Please sign in to comment.