@@ -334,12 +334,12 @@ type Row struct {
334334// Get(Columnindex)
335335// TODO Get(ColumnName)
336336func (r * Row ) Get (a interface {}) interface {} {
337- value := reflect .NewValue (a )
338- switch f := value .( type ) {
339- case * reflect.IntValue :
340- return r .Data [f .Get ()]
341- case * reflect.UintValue :
342- return r .Data [f .Get ()]
337+ value := reflect .ValueOf (a )
338+ switch f := value ; f . Kind ( ) {
339+ case reflect .Int , reflect . Int8 , reflect . Int16 , reflect . Int32 , reflect . Int64 :
340+ return r .Data [f .Int ()]
341+ case reflect .Uint , reflect . Uint8 , reflect . Uint16 , reflect . Uint32 , reflect . Uint64 , reflect . Uintptr :
342+ return r .Data [f .Uint ()]
343343 // case *reflect.StringValue:
344344 // i := r.Meta[f.Get()]
345345 // return r.Data[i]
@@ -349,42 +349,42 @@ func (r *Row) Get(a interface{}) interface{} {
349349
350350func (r * Row ) GetInt (a interface {}) (ret int64 ) {
351351 v := r .Get (a )
352- value := reflect .NewValue (v )
353- switch f := value .( type ) {
354- case * reflect.IntValue :
355- ret = int64 (f .Get ())
356- case * reflect.UintValue :
357- ret = int64 (f .Get ())
352+ value := reflect .ValueOf (v )
353+ switch f := value ; f . Kind ( ) {
354+ case reflect .Int , reflect . Int8 , reflect . Int16 , reflect . Int32 , reflect . Int64 :
355+ ret = int64 (f .Int ())
356+ case reflect .Uint , reflect . Uint8 , reflect . Uint16 , reflect . Uint32 , reflect . Uint64 , reflect . Uintptr :
357+ ret = int64 (f .Uint ())
358358 }
359359 return
360360}
361361
362362func (r * Row ) GetFloat (a interface {}) (ret float64 ) {
363363 v := r .Get (a )
364- value := reflect .NewValue (v )
365- switch f := value .( type ) {
366- case * reflect.FloatValue :
367- ret = float64 (f .Get ())
364+ value := reflect .ValueOf (v )
365+ switch f := value ; f . Kind ( ) {
366+ case reflect .Float32 , reflect . Float64 :
367+ ret = float64 (f .Float ())
368368 }
369369 return
370370}
371371
372- func (r * Row ) GetComplex (a interface {}) (ret complex ) {
372+ func (r * Row ) GetComplex64 (a interface {}) (ret complex64 ) {
373373 v := r .Get (a )
374- value := reflect .NewValue (v )
375- switch f := value .( type ) {
376- case * reflect.ComplexValue :
377- ret = complex (f .Get ())
374+ value := reflect .ValueOf (v )
375+ switch f := value ; f . Kind ( ) {
376+ case reflect .Complex64 , reflect . Complex128 :
377+ ret = complex64 (f .Complex ())
378378 }
379379 return
380380}
381381
382382func (r * Row ) GetString (a interface {}) (ret string ) {
383383 v := r .Get (a )
384- value := reflect .NewValue (v )
385- switch f := value .( type ) {
386- case * reflect.StringValue :
387- ret = f .Get ()
384+ value := reflect .ValueOf (v )
385+ switch f := value ; f . Kind ( ) {
386+ case reflect .String :
387+ ret = f .String ()
388388 }
389389 return
390390}
@@ -500,7 +500,7 @@ func (stmt *Statement) BindParam(index int, param interface{}) *ODBCError {
500500 var ParameterValuePtr C.SQLPOINTER
501501 var BufferLength C.SQLLEN
502502 var StrLen_or_IndPt C.SQLLEN
503- v := reflect .NewValue (param )
503+ v := reflect .ValueOf (param )
504504 if param == nil {
505505 ft , _ , _ , _ , err := stmt .GetParamType (index )
506506 if err != nil {
@@ -514,50 +514,50 @@ func (stmt *Statement) BindParam(index int, param interface{}) *ODBCError {
514514 StrLen_or_IndPt = C .SQL_NULL_DATA
515515 ColumnSize = 1
516516 } else {
517- switch v := v .( type ) {
518- case * reflect.BoolValue :
517+ switch v . Kind ( ) {
518+ case reflect .Bool :
519519 ParameterType = C .SQL_BIT
520520 ValueType = C .SQL_C_BIT
521521 var b [1 ]byte
522- if v .Get () {
522+ if v .Bool () {
523523 b [0 ] = 1
524524 } else {
525525 b [0 ] = 0
526526 }
527527 ParameterValuePtr = C .SQLPOINTER (unsafe .Pointer (& b [0 ]))
528528 BufferLength = 1
529529 StrLen_or_IndPt = 0
530- case * reflect.IntValue :
530+ case reflect .Int , reflect . Int8 , reflect . Int16 , reflect . Int32 , reflect . Int64 :
531531 switch v .Type ().Kind () {
532532 case reflect .Int :
533533 case reflect .Int8 , reflect .Int16 , reflect .Int32 :
534534 ParameterType = C .SQL_INTEGER
535535 ValueType = C .SQL_C_LONG
536- var l C.long = C .long (v .Get ())
536+ var l C.long = C .long (v .Int ())
537537 ParameterValuePtr = C .SQLPOINTER (unsafe .Pointer (& l ))
538538 BufferLength = 4
539539 StrLen_or_IndPt = 0
540540 case reflect .Int64 :
541541 ParameterType = C .SQL_BIGINT
542542 ValueType = C .SQL_C_SBIGINT
543- var ll C.longlong = C .longlong (v .Get ())
543+ var ll C.longlong = C .longlong (v .Int ())
544544 ParameterValuePtr = C .SQLPOINTER (unsafe .Pointer (& ll ))
545545 BufferLength = 8
546546 StrLen_or_IndPt = 0
547547 }
548- case * reflect.FloatValue :
548+ case reflect .Float32 , reflect . Float64 :
549549 ParameterType = C .SQL_DOUBLE
550550 ValueType = C .SQL_C_DOUBLE
551- var d C.double = C .double (v .Get ())
551+ var d C.double = C .double (v .Float ())
552552 ParameterValuePtr = C .SQLPOINTER (unsafe .Pointer (& d ))
553553 BufferLength = 8
554554 StrLen_or_IndPt = 0
555- case * reflect.ComplexValue :
556- case * reflect.StringValue :
557- var slen C.SQLUINTEGER = C .SQLUINTEGER (len (v .Get ()))
555+ case reflect .Complex64 , reflect . Complex128 :
556+ case reflect .String :
557+ var slen C.SQLUINTEGER = C .SQLUINTEGER (len (v .String ()))
558558 ParameterType = C .SQL_VARCHAR
559559 ValueType = C .SQL_C_CHAR
560- s := []byte (v .Get ())
560+ s := []byte (v .String ())
561561 ParameterValuePtr = C .SQLPOINTER (unsafe .Pointer (& s [0 ]))
562562 ColumnSize = slen
563563 BufferLength = C .SQLINTEGER (slen + 1 )
0 commit comments