Skip to content

Function::Coalesce not support the coexistence of SimpleExpr and QueryStatement #516

@bingryan

Description

@bingryan

Test language=MySQL

Description

I found it difficult to handle the logic that Function::Coalesce supports the coexistence of SimpleExpr and QueryStatement

The following logic is correct

create table bakery (
	id bigint,
	name varchar(255),
	profit_margin	bigint
)


create table cake{
	id bigint,
	name varchar(255),
	price bigint,
	bakery_id bigint,
	gluten_free bigint,
	serial bigint
}

mysql query:

select
	name,
	bakery,
	EXISTS ( SELECT 1 FROM `cake` WHERE `id` = 1 ) AS `exist`,
	-- Coalesce not only support SimpleExpr, logic is correct
	COALESCE (
		-- QueryStatement
		( SELECT count(*) FROM `cake` WHERE `bakery_id` = 27 ), 
		-- SimpleExpr, select or const 
		(SELECT 0),
		0 
	) AS `count` 
from bakery
where id = 27

but the existing logic does not support the coexistence of SimpleExpr and QueryStatement

sea-query/src/func.rs

Lines 430 to 435 in 28cf151

pub fn coalesce<I>(args: I) -> FunctionCall
where
I: IntoIterator<Item = SimpleExpr>,
{
FunctionCall::new(Function::Coalesce).args(args)
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Triage

Relationships

None yet

Development

No branches or pull requests

Issue actions