The codegen now can properly lookup array types.
Array type lookup failed previously because the typemapping class was not yet receiving the list of types from the database. Fix was to pass this data
This commit is contained in:
parent
287073afdc
commit
be0064f730
8 changed files with 34 additions and 20 deletions
|
|
@ -10,17 +10,18 @@
|
|||
// };
|
||||
//}
|
||||
|
||||
TypeMappings::TypeMappings() = default;
|
||||
TypeMappings::TypeMappings(std::shared_ptr<const PgTypeContainer> types)
|
||||
: m_types(types)
|
||||
{}
|
||||
|
||||
TypeMappings::TypeMappings(std::initializer_list<Mapping> mappings)
|
||||
TypeMappings::TypeMappings(std::shared_ptr<const PgTypeContainer> types, std::initializer_list<Mapping> mappings)
|
||||
: TypeMappings(types)
|
||||
{
|
||||
m_typeMap.insert(mappings.begin(), mappings.end());
|
||||
}
|
||||
|
||||
QString TypeMappings::getTypeForOid(Oid oid) const
|
||||
{
|
||||
// TODO use the catalog to determine if someting is an array or vector type.
|
||||
// If it is lookup its element type and use the std container
|
||||
auto res = m_typeMap.find(oid);
|
||||
if (res != m_typeMap.end()) {
|
||||
return res->second;
|
||||
|
|
@ -28,7 +29,11 @@ QString TypeMappings::getTypeForOid(Oid oid) const
|
|||
|
||||
if (m_types) {
|
||||
PgType type = m_types->getByKey(oid);
|
||||
// Found a valid type? elem is set? then it is array type
|
||||
if (type.oid != InvalidOid && type.elem != InvalidOid) {
|
||||
// Lookup what the element type is and wrap the mapping for that in the standard container type
|
||||
// for the language config. If that isn't right the end user should create a specific mapping for
|
||||
// that array type.
|
||||
res = m_typeMap.find(type.elem);
|
||||
QString type_string;
|
||||
if (res == m_typeMap.end()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue