Skip to content

Commit

Permalink
Add more interfaces for DataSet typeAdded : RowsColumnTypeDatabaseTyp…
Browse files Browse the repository at this point in the history
…eName, RowsColumnTypeLength and RowsColumnTypeNullable interface
  • Loading branch information
simulot committed Nov 23, 2020
1 parent 6c8482b commit c8af732
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
29 changes: 29 additions & 0 deletions data_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ import (
"github.com/sijms/go-ora/network"
)

// Compile time Sentinels for implemented Interfaces.
var _ = driver.Rows((*DataSet)(nil))
var _ = driver.RowsColumnTypeDatabaseTypeName((*DataSet)(nil))
var _ = driver.RowsColumnTypeLength((*DataSet)(nil))
var _ = driver.RowsColumnTypeNullable((*DataSet)(nil))

// var _ = driver.RowsColumnTypePrecisionScale((*DataSet)(nil))
// var _ = driver.RowsColumnTypeScanType((*DataSet)(nil))
// var _ = driver.RowsNextResultSet((*DataSet)(nil))

type Row []driver.Value

type DataSet struct {
Expand Down Expand Up @@ -139,3 +149,22 @@ func (dataSet DataSet) Trace(t trace.Tracer) {
}
}
}

func (dataSet DataSet) ColumnTypeDatabaseTypeName(index int) string {
return dataSet.Cols[index].DataType.String()
}

func (dataSet DataSet) ColumnTypeLength(index int) (length int64, ok bool) {
switch dataSet.Cols[index].DataType {
case NCHAR, CHAR:
return int64(dataSet.Cols[index].MaxCharLen), true
case NUMBER:
return int64(dataSet.Cols[index].Precision), true
}
return int64(0), false

}

func (dataSet DataSet) ColumnTypeNullable(index int) (nullable, ok bool) {
return dataSet.Cols[index].AllowNull, true
}
6 changes: 5 additions & 1 deletion parameter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package go_ora

import (
"github.com/sijms/go-ora/network"
"math"
"strings"

"github.com/sijms/go-ora/network"
)

type OracleType int
Expand All @@ -22,6 +23,9 @@ const (
//Input = 32,
//InputOutput = 48,
//}

//go:generate stringer -type=OracleType

const (
NCHAR OracleType = 1
NUMBER OracleType = 2
Expand Down

0 comments on commit c8af732

Please sign in to comment.