From fab009477d6b5bc9cbd23cdb3870b8335cd091b3 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sat, 21 May 2022 16:34:30 +0200 Subject: [PATCH] Added new SQLTypes for binary data --- .../java/fr/pandacube/lib/core/db/SQLElement.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/fr/pandacube/lib/core/db/SQLElement.java b/Core/src/main/java/fr/pandacube/lib/core/db/SQLElement.java index 4c2f732..0c7f7eb 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/db/SQLElement.java +++ b/Core/src/main/java/fr/pandacube/lib/core/db/SQLElement.java @@ -479,6 +479,18 @@ public abstract class SQLElement> { public static final SQLType TEXT = new SQLType<>("TEXT", String.class); public static final SQLType STRING = TEXT; + public static final SQLType BINARY(int byteCount) { + if (byteCount <= 0) throw new IllegalArgumentException("byteCount must be positive."); + return new SQLType<>("BINARY(" + byteCount + ")", byte[].class); + } + + public static final SQLType VARBINARY(int byteCount) { + if (byteCount <= 0) throw new IllegalArgumentException("byteCount must be positive."); + return new SQLType<>("VARBINARY(" + byteCount + ")", byte[].class); + } + + public static final SQLType BLOB = new SQLType<>("BLOB", byte[].class); + public static final > SQLType ENUM(Class enumType) { if (enumType == null) throw new IllegalArgumentException("enumType can't be null."); String enumStr = "'"; @@ -495,6 +507,4 @@ public abstract class SQLElement> { } public static final SQLType CHAR36_UUID = new SQLCustomType<>(CHAR(36), UUID.class, UUID::fromString, UUID::toString); - - }