From cc445627b0b3dcc5bcad3b91db8ef88ffacbd27a Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Fri, 20 Jun 2014 10:46:47 -0500 Subject: [PATCH] Expose DataRowReader FieldDescriptions --- conn.go | 12 ++++++------ data_row_reader.go | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/conn.go b/conn.go index d220db2f..63c2f7f7 100644 --- a/conn.go +++ b/conn.go @@ -410,8 +410,8 @@ func (c *Conn) SelectValue(sql string, arguments ...interface{}) (interface{}, e var v interface{} onDataRow := func(r *DataRowReader) error { - if len(r.fields) != 1 { - return UnexpectedColumnCountError{ExpectedCount: 1, ActualCount: int16(len(r.fields))} + if len(r.FieldDescriptions) != 1 { + return UnexpectedColumnCountError{ExpectedCount: 1, ActualCount: int16(len(r.FieldDescriptions))} } numRowsFound++ @@ -559,8 +559,8 @@ func (c *Conn) SelectValues(sql string, arguments ...interface{}) ([]interface{} values := make([]interface{}, 0, 8) onDataRow := func(r *DataRowReader) error { - if len(r.fields) != 1 { - return UnexpectedColumnCountError{ExpectedCount: 1, ActualCount: int16(len(r.fields))} + if len(r.FieldDescriptions) != 1 { + return UnexpectedColumnCountError{ExpectedCount: 1, ActualCount: int16(len(r.FieldDescriptions))} } values = append(values, r.ReadValue()) @@ -1079,11 +1079,11 @@ func (c *Conn) rxParameterDescription(r *MessageReader) (parameters []Oid) { } func (c *Conn) rxDataRow(r *DataRowReader) (row map[string]interface{}) { - fieldCount := len(r.fields) + fieldCount := len(r.FieldDescriptions) row = make(map[string]interface{}, fieldCount) for i := 0; i < fieldCount; i++ { - row[r.fields[i].Name] = r.ReadValue() + row[r.FieldDescriptions[i].Name] = r.ReadValue() } return } diff --git a/data_row_reader.go b/data_row_reader.go index 32cbcbc3..c5f8d19d 100644 --- a/data_row_reader.go +++ b/data_row_reader.go @@ -6,15 +6,15 @@ import ( // DataRowReader is used by SelectFunc to process incoming rows. type DataRowReader struct { - mr *MessageReader - fields []FieldDescription - currentFieldIdx int + mr *MessageReader + FieldDescriptions []FieldDescription + currentFieldIdx int } func newDataRowReader(mr *MessageReader, fields []FieldDescription) (r *DataRowReader, err error) { r = new(DataRowReader) r.mr = mr - r.fields = fields + r.FieldDescriptions = fields fieldCount := int(mr.ReadInt16()) if fieldCount != len(fields) { @@ -26,7 +26,7 @@ func newDataRowReader(mr *MessageReader, fields []FieldDescription) (r *DataRowR // ReadValue returns the next value from the current row. func (r *DataRowReader) ReadValue() interface{} { - fieldDescription := r.fields[r.currentFieldIdx] + fieldDescription := r.FieldDescriptions[r.currentFieldIdx] r.currentFieldIdx++ size := r.mr.ReadInt32()