CASE with subquery clause

How can I return the column value from the subquery in a CASE? With this example, Kysely thinks the second condition is
{ name: string }
:

eb.case()
.when('re.type', '=', 'company')
.then(eb.ref('cd.name'))
.else(
    eb
        .selectFrom('rise.companies_data as cd')
        .select(['cd.name'])
        .where(
            'cd.riseid',
            '=',
            eb.selectFrom('rise.rise_entities as re2')
                .select(['re2.parent_riseid'])
                .where('re2.type', '=', 'team')
                .whereRef('re2.riseid', '=', 're.riseid'),
            ),
    )
    .end()
    .as('company_name')
Was this page helpful?