mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
trim keys from database to remove null terminator padding
This commit is contained in:
1 file changed
+4
-2
@@ -22,6 +22,7 @@ package net.draycia.carbon.common.users.db;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.intellij.lang.annotations.Subst;
|
import org.intellij.lang.annotations.Subst;
|
||||||
import org.jdbi.v3.core.mapper.ColumnMapper;
|
import org.jdbi.v3.core.mapper.ColumnMapper;
|
||||||
import org.jdbi.v3.core.statement.StatementContext;
|
import org.jdbi.v3.core.statement.StatementContext;
|
||||||
@@ -30,10 +31,11 @@ public class KeyColumnMapper implements ColumnMapper<Key> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Key map(final ResultSet rs, final int columnNumber, final StatementContext ctx) throws SQLException {
|
public Key map(final ResultSet rs, final int columnNumber, final StatementContext ctx) throws SQLException {
|
||||||
final @Subst("key:value") String keyValue = rs.getString(columnNumber);
|
final @Nullable String keyValue = rs.getString(columnNumber);
|
||||||
|
final @Nullable @Subst("key:value") String trimmed = keyValue == null ? null : keyValue.trim();
|
||||||
|
|
||||||
if (keyValue != null) {
|
if (keyValue != null) {
|
||||||
return Key.key(keyValue);
|
return Key.key(trimmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in new issue
Block a user