From 792f89a8571cf054c02daecc9341a634d567d557 Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Fri, 3 Jun 2022 16:11:24 +0200 Subject: [PATCH] mysql: export some conditional functions COALESCE, NULLIF, GREATEST and LEAST already existed and were available in the postgres dialect, but not in MySQL. --- mysql/functions.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql/functions.go b/mysql/functions.go index 2a8e2278..24cd73cb 100644 --- a/mysql/functions.go +++ b/mysql/functions.go @@ -261,10 +261,22 @@ func UNIX_TIMESTAMP(str StringExpression) TimestampExpression { return jet.NewTimestampFunc("UNIX_TIMESTAMP", str) } -//----------- Comparison operators ---------------// +// --------------- Conditional Expressions Functions -------------// // EXISTS checks for existence of the rows in subQuery var EXISTS = jet.EXISTS // CASE create CASE operator with optional list of expressions var CASE = jet.CASE + +// COALESCE function returns the first of its arguments that is not null. +var COALESCE = jet.COALESCE + +// NULLIF function returns a null value if value1 equals value2; otherwise it returns value1. +var NULLIF = jet.NULLIF + +// GREATEST selects the largest value from a list of expressions, or null if any of the expressions is null. +var GREATEST = jet.GREATEST + +// LEAST selects the smallest value from a list of expressions, or null if any of the expressions is null. +var LEAST = jet.LEAST