From a428981a2dd444fecfbc44cbc3b9a411bb6be8d8 Mon Sep 17 00:00:00 2001 From: go-jet Date: Mon, 17 Apr 2023 12:01:01 +0200 Subject: [PATCH] Expose internal jet.Rows type --- internal/jet/statement.go | 2 +- mysql/types.go | 3 +++ postgres/types.go | 3 +++ sqlite/types.go | 3 +++ tests/mysql/raw_statement_test.go | 5 ++++- tests/postgres/raw_statements_test.go | 5 ++++- tests/sqlite/raw_statement_test.go | 5 ++++- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/internal/jet/statement.go b/internal/jet/statement.go index 58c3dfa..6703154 100644 --- a/internal/jet/statement.go +++ b/internal/jet/statement.go @@ -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 diff --git a/mysql/types.go b/mysql/types.go index 6e29b67..0947468 100644 --- a/mysql/types.go +++ b/mysql/types.go @@ -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 diff --git a/postgres/types.go b/postgres/types.go index 0f3ef70..e6ab36e 100644 --- a/postgres/types.go +++ b/postgres/types.go @@ -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 diff --git a/sqlite/types.go b/sqlite/types.go index e06a323..ea40837 100644 --- a/sqlite/types.go +++ b/sqlite/types.go @@ -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 diff --git a/tests/mysql/raw_statement_test.go b/tests/mysql/raw_statement_test.go index fd4531f..71ebbed 100644 --- a/tests/mysql/raw_statement_test.go +++ b/tests/mysql/raw_statement_test.go @@ -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() { diff --git a/tests/postgres/raw_statements_test.go b/tests/postgres/raw_statements_test.go index e201c75..b60a011 100644 --- a/tests/postgres/raw_statements_test.go +++ b/tests/postgres/raw_statements_test.go @@ -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() { diff --git a/tests/sqlite/raw_statement_test.go b/tests/sqlite/raw_statement_test.go index 974dfda..f79076b 100644 --- a/tests/sqlite/raw_statement_test.go +++ b/tests/sqlite/raw_statement_test.go @@ -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() {