From 33365b92f3529ae353af64b90251e3f515adc0ea Mon Sep 17 00:00:00 2001 From: Joe Harvey Date: Mon, 8 Feb 2021 17:22:20 +0000 Subject: [PATCH] Bug Fix - Ensure DataQuery::exists() SQL is both valid MySQL and T-SQL The original SQL statement is not valid T-SQL for use with SQL Server --- src/ORM/DataQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ORM/DataQuery.php b/src/ORM/DataQuery.php index c15bb569d..4b836bfed 100644 --- a/src/ORM/DataQuery.php +++ b/src/ORM/DataQuery.php @@ -479,7 +479,7 @@ class DataQuery } // Wrap the whole thing in an "EXISTS" - $sql = 'SELECT EXISTS(' . $statement->sql($params) . ')'; + $sql = 'SELECT CASE WHEN EXISTS(' . $statement->sql($params) . ') THEN 1 ELSE 0 END'; $result = DB::prepared_query($sql, $params); $row = $result->first(); $result = reset($row);