Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit 118ff38

Browse files
committed
iter: expose columns
1 parent 89905d2 commit 118ff38

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

query.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/scylladb/scylla-go-driver/frame"
8+
"github.com/scylladb/scylla-go-driver/frame/response"
89
"github.com/scylladb/scylla-go-driver/transport"
910
)
1011

@@ -309,8 +310,9 @@ func (q *Query) Iter(ctx context.Context) Iter {
309310
requestCh: make(chan struct{}, 1),
310311
nextCh: make(chan transport.QueryResult),
311312
errCh: make(chan error, 1),
312-
}
313313

314+
prepared: stmt.Prepared,
315+
}
314316
info, err := q.info()
315317
if err != nil {
316318
it.errCh <- err
@@ -337,9 +339,10 @@ func (q *Query) Iter(ctx context.Context) Iter {
337339
}
338340

339341
type Iter struct {
340-
result transport.QueryResult
341-
pos int
342-
rowCnt int
342+
result transport.QueryResult
343+
prepared *response.PreparedResult
344+
pos int
345+
rowCnt int
343346

344347
requestCh chan struct{}
345348
nextCh chan transport.QueryResult
@@ -352,6 +355,14 @@ var (
352355
ErrNoMoreRows = fmt.Errorf("no more rows left")
353356
)
354357

358+
func (it *Iter) Columns() []frame.ColumnSpec {
359+
if it.prepared == nil {
360+
return it.result.ColSpec
361+
}
362+
363+
return it.prepared.ResultMetadata.Columns
364+
}
365+
355366
func (it *Iter) PageState() []byte {
356367
return it.result.PagingState
357368
}

0 commit comments

Comments
 (0)