Skip to content

Commit

Permalink
expose client.DB
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzuo committed Aug 5, 2024
1 parent 1d62b5a commit c09ae53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build: fmt
go build -ldflags "-X github.com/swiftcarrot/queryx/cmd/queryx/action.Version=`git rev-parse HEAD`" -o bin/queryx cmd/queryx/main.go

install: build
install bin/queryx /usr/local/bin
sudo install bin/queryx /usr/local/bin

clean:
rm bin/queryx
Expand All @@ -21,9 +21,9 @@ test-postgresql: install
cd internal/integration && queryx db:migrate --schema postgresql.hcl
cd internal/integration && queryx db:migrate --schema postgresql.hcl
cd internal/integration && queryx generate --schema postgresql.hcl
cd internal/integration && yarn tsc
cd internal/integration && yarn test
# cd internal/integration && go test ./...
# cd internal/integration && yarn tsc
# cd internal/integration && yarn test
cd internal/integration && go test ./...
# cd internal/integration && queryx db:drop --schema postgresql.hcl

test-mysql: install
Expand Down
8 changes: 4 additions & 4 deletions generator/client/golang/templates/queryx.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Queries interface {
}

type QXClient struct {
db *sql.DB
DB *sql.DB
config *queryx.Config
logger queryx.Logger
*queryx.Adapter
Expand Down Expand Up @@ -52,12 +52,12 @@ func NewClientWithEnv(env string) (*QXClient, error) {
}

client := &QXClient{
db: db,
DB: db,
config: config,
Adapter: queryx.NewAdapter(db),
Schema : queryx.NewSchema(),
}
client.setDefaultLogger()
client.setDefaultLogger()

return client, nil
}
Expand Down Expand Up @@ -102,7 +102,7 @@ type Tx struct {

func (c *QXClient) Tx() (*Tx, error) {
ctx := context.Background()
tx, err := c.db.BeginTx(ctx, nil)
tx, err := c.DB.BeginTx(ctx, nil)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c09ae53

Please sign in to comment.