Skip to content

Column alias with data type #139

@zero88

Description

@zero88

Describe the bug

Add field mapper

15:09:24.048 [main] DEBUG io.github.zero88.jooqx.datatype.DataTypeMapperRegistry - Adding field mapper by [all_data_types.f_udt_address::io.github.zero88.sample.model.pgsql.udt.records.FullAddressRecord]...

When executing query directly

final AllDataTypes table = schema().ALL_DATA_TYPES;
jooqx.execute(dsl -> dsl.selectFrom(table).where(table.ID.eq(41)).limit(1), DSLAdapter.fetchOne(table))
     .onSuccess(record -> {
             final FullAddressRecord address = record.getFUdtAddress();
        });

The record field is converted successfully.

However, executing by shortcut

final AllDataTypes table = schema().ALL_DATA_TYPES;
jooqx.fetchOne(dsl -> dsl.selectFrom(table).where(table.ID.eq(41)).limit(1))
     .onSuccess(record -> {
                 final FullAddressRecord address = record.getFUdtAddress();
         });

Exception is raised

java.lang.ClassCastException: class java.lang.String cannot be cast to class io.github.zero88.sample.model.pgsql.udt.records.FullAddressRecord (java.lang.String is in module java.base of loader 'bootstrap'; io.github.zero88.sample.model.pgsql.udt.records.FullAddressRecord is in unnamed module of loader 'app')

	at io.github.zero88.sample.model.pgsql.tables.records.AllDataTypesRecord.getFUdtAddress(AllDataTypesRecord.java:467)

Version
V2.0.0

Additional context

Need to re-check

  • DSLAdapter with Select.asTable() introduce table alias then the mapper is unable to look up the field
  • Cover alias in DataTypeMapper and DataTypeMapperRegistry

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions