Skip to content

Commit

Permalink
Expose internal jet.Rows type
Browse files Browse the repository at this point in the history
  • Loading branch information
go-jet committed Apr 17, 2023
1 parent c049675 commit a428981
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/jet/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Statement interface {
Rows(ctx context.Context, db qrm.Queryable) (*Rows, error)
}

// Rows wraps sql.Rows type to add query result mapping for Scan method
// Rows wraps sql.Rows type with a support for query result mapping
type Rows struct {
*sql.Rows

Expand Down
3 changes: 3 additions & 0 deletions mysql/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "github.com/go-jet/jet/v2/internal/jet"
// Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
type Statement = jet.Statement

// Rows wraps sql.Rows type with a support for query result mapping
type Rows = jet.Rows

// Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
type Projection = jet.Projection

Expand Down
3 changes: 3 additions & 0 deletions postgres/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "github.com/go-jet/jet/v2/internal/jet"
// Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
type Statement = jet.Statement

// Rows wraps sql.Rows type with a support for query result mapping
type Rows = jet.Rows

// Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
type Projection = jet.Projection

Expand Down
3 changes: 3 additions & 0 deletions sqlite/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import "github.com/go-jet/jet/v2/internal/jet"
// Statement is common interface for all statements(SELECT, INSERT, UPDATE, DELETE, LOCK)
type Statement = jet.Statement

// Rows wraps sql.Rows type with a support for query result mapping
type Rows = jet.Rows

// Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
type Projection = jet.Projection

Expand Down
5 changes: 4 additions & 1 deletion tests/mysql/raw_statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ func TestRawStatementRows(t *testing.T) {
FROM dvds.actor
ORDER BY actor.actor_id`)

rows, err := stmt.Rows(context.Background(), db)
var rows *Rows
var err error

rows, err = stmt.Rows(context.Background(), db)
require.NoError(t, err)

for rows.Next() {
Expand Down
5 changes: 4 additions & 1 deletion tests/postgres/raw_statements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ func TestRawStatementRows(t *testing.T) {
FROM dvds.actor
ORDER BY actor.actor_id`)

rows, err := stmt.Rows(context.Background(), db)
var rows *Rows
var err error

rows, err = stmt.Rows(context.Background(), db)
require.NoError(t, err)

for rows.Next() {
Expand Down
5 changes: 4 additions & 1 deletion tests/sqlite/raw_statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ func TestRawStatementRows(t *testing.T) {
FROM actor
ORDER BY actor.actor_id`)

rows, err := stmt.Rows(context.Background(), db)
var rows *Rows
var err error

rows, err = stmt.Rows(context.Background(), db)
require.NoError(t, err)

for rows.Next() {
Expand Down

0 comments on commit a428981

Please sign in to comment.