@@ -365,6 +365,40 @@ cdef class BaseThinDbObjectTypeCache:
365365 errors._raise_err(errors.ERR_TDS_TYPE_NOT_SUPPORTED, num = attr_type)
366366 return DbType._from_ora_type_and_csfrm(ora_type_num, csfrm)
367367
368+ cdef int _create_attr(self , ThinDbObjectTypeImpl typ_impl, str name,
369+ str type_name, str type_owner,
370+ str type_package_name = None , bytes oid = None ,
371+ int8_t precision = 0 , int8_t scale = 0 ,
372+ uint32_t max_size = 0 ) except - 1 :
373+ """
374+ Creates an attribute from the supplied information and adds it to the
375+ list of attributes for the type.
376+ """
377+ cdef:
378+ ThinDbObjectTypeImpl attr_typ_impl
379+ ThinDbObjectAttrImpl attr_impl
380+ attr_impl = ThinDbObjectAttrImpl.__new__ (ThinDbObjectAttrImpl)
381+ attr_impl.name = name
382+ if type_owner is not None :
383+ attr_typ_impl = self .get_type_for_info(oid, type_owner,
384+ type_package_name,
385+ type_name)
386+ if attr_typ_impl.is_xml_type:
387+ attr_impl.dbtype = DB_TYPE_XMLTYPE
388+ else :
389+ attr_impl.dbtype = DB_TYPE_OBJECT
390+ attr_impl.objtype = attr_typ_impl
391+ else :
392+ attr_impl.dbtype = DbType._from_ora_name(type_name)
393+ attr_impl.max_size = max_size
394+ if precision != 0 or scale != 0 :
395+ attr_impl.precision = precision
396+ attr_impl.scale = scale
397+ attr_impl._preferred_num_type = \
398+ get_preferred_num_type(precision, scale)
399+ typ_impl.attrs.append(attr_impl)
400+ typ_impl.attrs_by_name[name] = attr_impl
401+
368402 cdef object _populate_type_info(self , str name, object attrs,
369403 ThinDbObjectTypeImpl typ_impl):
370404 """
@@ -389,48 +423,25 @@ cdef class BaseThinDbObjectTypeCache:
389423 if typ_impl.is_row_type:
390424 for name, data_type, data_type_owner, max_size, precision, \
391425 scale in attrs:
392- attr_impl = ThinDbObjectAttrImpl.__new__ (ThinDbObjectAttrImpl)
393- attr_impl.name = name
394- if data_type_owner is not None :
395- attr_impl.dbtype = DB_TYPE_OBJECT
396- attr_impl.objtype = self .get_type_for_info(None ,
397- data_type_owner,
398- None ,
399- data_type)
400- else :
426+ if data_type_owner is None :
401427 start_pos = data_type.find(" (" )
402428 if start_pos > 0 :
403429 end_pos = data_type.find(" )" )
404430 if end_pos > start_pos:
405431 data_type = data_type[:start_pos] + \
406432 data_type[end_pos + 1 :]
407- attr_impl.dbtype = DbType._from_ora_name(data_type)
408- attr_impl.max_size = max_size
409- attr_impl.precision = precision
410- attr_impl.scale = scale
411- typ_impl.attrs.append(attr_impl)
412- typ_impl.attrs_by_name[name] = attr_impl
433+ self ._create_attr(typ_impl, name, data_type, data_type_owner,
434+ None , None , precision, scale, max_size)
413435 else :
414436 for cursor_version, attr_name, attr_num, attr_type_name, \
415437 attr_type_owner, attr_type_package, attr_type_oid, \
416438 attr_instantiable, attr_super_type_owner, \
417439 attr_super_type_name in attrs:
418440 if attr_name is None :
419441 continue
420- attr_impl = ThinDbObjectAttrImpl.__new__ (ThinDbObjectAttrImpl)
421- attr_impl.name = attr_name
422- if attr_type_owner is not None :
423- attr_impl.dbtype = DB_TYPE_OBJECT
424- attr_impl.objtype = self .get_type_for_info(
425- attr_type_oid,
426- attr_type_owner,
427- attr_type_package,
428- attr_type_name
429- )
430- else :
431- attr_impl.dbtype = DbType._from_ora_name(attr_type_name)
432- typ_impl.attrs.append(attr_impl)
433- typ_impl.attrs_by_name[attr_name] = attr_impl
442+ self ._create_attr(typ_impl, attr_name, attr_type_name,
443+ attr_type_owner, attr_type_package,
444+ attr_type_oid)
434445 return self ._parse_tds(typ_impl, self .tds_var.getvalue())
435446
436447 cdef ThinDbObjectTypeImpl get_type_for_info(self , bytes oid, str schema,
0 commit comments