From 983d4b57713688e37705e26afa4c5bf4c14d3099 Mon Sep 17 00:00:00 2001 From: Axel Cocat Date: Fri, 21 May 2021 01:13:49 +0200 Subject: [PATCH] fix(Core/Database): fix wrong Field::IsNull() return value on null binary fields (#5975) --- src/server/database/Database/Field.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/server/database/Database/Field.h b/src/server/database/Database/Field.h index e4055652b..bcc73ec04 100644 --- a/src/server/database/Database/Field.h +++ b/src/server/database/Database/Field.h @@ -242,6 +242,10 @@ public: [[nodiscard]] bool IsNull() const { + if (IsBinary() && data.length == 0) + { + return true; + } return data.value == nullptr; } @@ -351,6 +355,18 @@ protected: data.type == MYSQL_TYPE_LONGLONG ); } + [[nodiscard]] bool IsBinary() const + { + return ( + data.type == MYSQL_TYPE_TINY_BLOB || + data.type == MYSQL_TYPE_MEDIUM_BLOB || + data.type == MYSQL_TYPE_LONG_BLOB || + data.type == MYSQL_TYPE_BLOB || + data.type == MYSQL_TYPE_VAR_STRING || + data.type == MYSQL_TYPE_STRING + ); + } + void GetBinarySizeChecked(uint8* buf, size_t size) const; private: