go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

COALESCE missing in MySQL #158

Closed kblomster closed 2 years ago

kblomster commented 2 years ago

Describe the bug The postgres dialect exports COALESCE in postgres/functions.go, but the MySQL dialect lacks it. It's a pretty ubiquitous function, so I believe this is probably a bug.

Code snippet

q := Film.SELECT(
    Film.Title,
    IntExp(COALESCE(Film.Length, Int(0))).AS("length_not_null")
)

Expected behavior I expect COALESCE to be available the MySQL dialect.

As a minor feature request, I think it'd be pretty nice to have the functions listed somewhere on the wiki. Some of them are already on the "Expressions" page, and to be fair a lot of them are just the exact same keywords as in SQL, but when you're new to the library it really helps to just know for sure that they do exist (and especially so when it comes to Jet-specific variants like SUMf() - it shows up in examples, but again, a reference would be nice).

Having typed this out I now realize that in the time it took I could just have submitted a PR instead. :/

go-jet commented 2 years ago

Hi @kblomster . Yeah, it seems those functions are missing for MySQL. Wiki update PR also welcomed.

go-jet commented 2 years ago

Hmm, it looks like they are missing for SQLite as well.

go-jet commented 2 years ago

Fixed with 2.9.0 release.