Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when listing CLOB fields, it doesn't bring all the bytes. #511

Closed
fitlcarlos opened this issue Feb 2, 2024 · 4 comments
Closed
Labels

Comments

@fitlcarlos
Copy link
Contributor

fitlcarlos commented Feb 2, 2024

I have a query with several fields and these fields are of type string, date, int and clob and this query will return several rows.

I'm running a DB.query and returning the rows, but the CLob field is already returned to me as a string in the row and does not contain all the bytes of the CLb.

Note: I can't type my fields as go_ora.clob because of my logic.

The logic is as follows:

func Open(){
  
  var dataset []map[string]*any  
  
  rows, err = ds.Connection.DB.Query(query, ds.GetParams()...)
  
  fieldTypes, _ := rows.ColumnTypes()
  fields, _ := rows.Columns()
  
  for rows.Next() {
     columns := make([]any, len(fields))    

     for i := 0; i < len(columns); i++ {
       columns[i] = &columns[i]
     }
     
     err := rows.Scan(columns...)  // <--- Here the CLob column already has a string
     
     if err != nil {
       print(err)
     }
     
     line := make(map[string]*any)

     for i := 0; i < len(columns); i++ {
       line[strings.ToUpper(fields[i])] = columns[i]
     }
  
     dataset = append(dataset, line)
  }   
}

columns[0] <----- Here it already brings me the CLob column as a string because the field type is ANY.

Internally in go_ora, it cannot identify that the field is of type OCIClobLocator and perform the correct conversion bringing all the CLob bytes?

@sijms
Copy link
Owner

sijms commented Feb 11, 2024

Hi @fitlcarlos
sorry for late replay
according to this doc of scanner interface oracle types should by mapped to one of the following:

// int64
// float64
// bool
// []byte
// string
// time.Time
// nil - for NULL values

so these oracle types will be converted internally into the corresponding go types

oracle type go type
CLOB string
NCLOB string
BLOB []byte

if your data is larger than 32kb so you should use url option lob fetch=post it is not the default option because it slightly slow down the query. (note default will return clob as varchar2 and nclob as nvarchar2 and blob as raw)

@sijms sijms added the fixing now working on this issue to fix label Feb 12, 2024
@sijms
Copy link
Owner

sijms commented Feb 12, 2024

I am working on increase number of bytes received during lob prefetch from 32KB to 1 GB (same as official drivers)

@fitlcarlos
Copy link
Contributor Author

I am working on increase number of bytes received during lob prefetch from 32KB to 1 GB (same as official drivers)

Thank's

@sijms sijms added fixed and removed fixing now working on this issue to fix labels Feb 14, 2024
@sijms
Copy link
Owner

sijms commented Feb 14, 2024

fixed in v2.8.8

@sijms sijms closed this as completed Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants