sijms / go-ora

Pure go oracle client
MIT License
767 stars 168 forks source link

2.8.8 drop JSON support? ORA-40569: Unimplemented JSON feature. #540

Closed viplifes closed 2 months ago

viplifes commented 3 months ago

Version 2.8.7 work fine!

Versions 2.8.8 - 2.8.11 have error: ORA-40569: Unimplemented JSON feature.

package main

import (
    "database/sql"
    "fmt"

    go_ora "github.com/sijms/go-ora/v2"
)

func main() {

    connOra, err := sql.Open("oracle", go_ora.BuildUrl("127.0.0.1", 1521, "ORCLPDB1", "SYS", "dbpaSS1#", nil))
    if err != nil {
        panic(err)
    }
    defer connOra.Close()
    run(connOra)
    // print
    // OCIBlobLocator OCIBlobLocator
}

func run(conn *sql.DB) {
    conn.Exec(`GRANT CREATE SESSION TO SYS`)
    conn.Exec(`DROP TABLE IF EXISTS types_test`)
    conn.Exec(`CREATE TABLE types_test (myblob BLOB NULL, myjson JSON NULL)`)
    conn.Exec(`INSERT INTO types_test (myblob, myjson)VALUES(UTL_RAW.CAST_TO_RAW('blobval - not json'), json('{"foo": "bar"}'))`)

    rows, err := conn.Query(`SELECT * FROM types_test`)
    if err != nil {
        panic(err)
    }
    cTypes, _ := rows.ColumnTypes()
    fmt.Println(cTypes[0].DatabaseTypeName(), cTypes[1].DatabaseTypeName())
}
sijms commented 2 months ago

HI @viplifes I run the code with multiple version of go-ora (latest, v2.8.7, 2.7.21) and all failed at this stmt:

INSERT INTO types_test (myblob, myjson)VALUES(UTL_RAW.CAST_TO_RAW('blobval - not json'), json('{"foo": "bar"}'))

with this error

ORA-40445: unsupported JSON operation

to confirm I run same statement on SQL Developer and get same error my database version is 19c

sijms commented 2 months ago

when I change the insert statement and remove json keywords everything is ok

INSERT INTO types_test (myblob, myjson)VALUES(UTL_RAW.CAST_TO_RAW('blobval - not json'), '{"foo": "bar"}'); 
viplifes commented 2 months ago

I use docker image hub.docker.com/gvenzl/oracle-free:23-slim

https://hub.docker.com/r/gvenzl/oracle-free

sijms commented 2 months ago

fixed in next release

sijms commented 2 months ago

fixed v2.8.13