Skip to content

Using a database cast in a subquery using query beans #3479

Open
@PassXml

Description

@PassXml

Expected behavior

In some database, the comparison of field types is strict and must be explicitly converted. I have two models, Model A has a field of type UUID, and Model B also has a logical primary key (sourceId) stored as varchar. When generating SQL, they cannot be directly compared, and their field types must be converted. So, when using the select method, can I add conversion functions or specify the type? Moreover, when I specify it as a string, it throws the following error.

  new QClass().select("source_id::string")
property [source_id::string] not found on xxxEntity for query - excluding it.

The automatically generated SQL looks like this:

select *
from a
where a.source_id = (select id
                     from b)

select *
from a
where a.source_id = (select id::string
                     from b)

```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions