ora
ora copied to clipboard
INTEGER column
if column have INTEGER
type, then in result set it has type ora.OCINum
But if column just NUMBER
, then result type float64
(as i understand this default behavior).
This expected behavior and how correct work with columns INTEGER
type?
Good question. float64 is just a compromise, and iff we can Scan ora.OCINum into both float64, int64 and string, then we could change the defaults. But that change would break a lot of old programs.
What does SELECT DUMP(myintcol) FROM mytablewithintcol WHERE ROWNUM < 2
say about that column?
I haven't met with "INTEGER" column yet, only NUMBER(...).
Typ=2 Len=3: 194,2,23
With NUMBER(38, 0)
also
INTEGER
like alias NUMBER(38, 0)
.
I write function-helper, but better, if column autoconvert to native golang type.
func intVal(v interface{}) (int, error) {
str := v.(ora.OCINum).String()
return strconv.Atoi(str)
}
You can set the wanted column type with using Ses.Sel or by ora.SetCfg(ora.Cfg().SetNumberBigInt(ora.I64))
.
Autoconvert is a tricky solution - what to autoconvert to? int, float has limited range, cockroachdb/apd could be used, or return an error? I don't know which solution is the desired at the moment.
Thanks.
I already use pre-settings.
I found it strange that all the other numeric types are converted to native go-types,
but number(38)
and integer
not.
The logic is at https://github.com/rana/ora/blob/v4.1.4/rsetCfg.go#L686 - for integers, if the column have less than 19 decimals, int64 is used, otherwise NumberBigInt.
mynoheart [email protected] ezt írta (időpont: 2017. márc. 16., Cs, 21:23):
Thanks.
I already use pre-settings. I found it strange that all the other numeric types are converted to native go-types, but number(38) and integer not.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/rana/ora/issues/173#issuecomment-287180039, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPoSgWoNgp9KkYlMHwQw9L3CLQC7Wn-ks5rmZpYgaJpZM4Mcmld .