mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2025-02-28 03:42:46 +01:00
Fix SQLStorage not using the table prefix
This commit is contained in:
parent
02121a61f9
commit
0f13f155cb
@ -69,19 +69,23 @@ public abstract class SQLStorage implements Storage {
|
||||
}
|
||||
}
|
||||
|
||||
protected String tablePrefix() {
|
||||
return discordSRV.connectionConfig().storage.sqlTablePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
useConnection((CheckedConsumer<Connection>) connection -> createTables(
|
||||
connection,
|
||||
discordSRV.connectionConfig().storage.sqlTablePrefix,
|
||||
discordSRV.linkProvider() instanceof StorageLinker)
|
||||
);
|
||||
discordSRV.linkProvider() instanceof StorageLinker
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Long getUserId(@NotNull UUID player) {
|
||||
return useConnection(connection -> {
|
||||
try (PreparedStatement statement = connection.prepareStatement("select USER_ID from LINKED_ACCOUNTS where PLAYER_UUID = ?;")) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("select USER_ID from " + tablePrefix() + "LINKED_ACCOUNTS where PLAYER_UUID = ?;")) {
|
||||
statement.setString(1, player.toString());
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
if (resultSet.next()) {
|
||||
@ -96,7 +100,7 @@ public abstract class SQLStorage implements Storage {
|
||||
@Override
|
||||
public @Nullable UUID getPlayerUUID(long userId) {
|
||||
return useConnection(connection -> {
|
||||
try (PreparedStatement statement = connection.prepareStatement("select PLAYER_UUID from LINKED_ACCOUNTS where USER_ID = ?;")) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("select PLAYER_UUID from " + tablePrefix() + "LINKED_ACCOUNTS where USER_ID = ?;")) {
|
||||
statement.setLong(1, userId);
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
if (resultSet.next()) {
|
||||
@ -115,7 +119,7 @@ public abstract class SQLStorage implements Storage {
|
||||
@Override
|
||||
public void createLink(@NotNull UUID player, long userId) {
|
||||
useConnection(connection -> {
|
||||
try (PreparedStatement statement = connection.prepareStatement("insert into LINKED_ACCOUNTS (PLAYER_UUID, USER_ID) values (?, ?);")) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("insert into " + tablePrefix() + "LINKED_ACCOUNTS (PLAYER_UUID, USER_ID) values (?, ?);")) {
|
||||
statement.setString(1, player.toString());
|
||||
statement.setLong(2, userId);
|
||||
|
||||
@ -128,7 +132,7 @@ public abstract class SQLStorage implements Storage {
|
||||
public int getLinkedAccountCount() {
|
||||
return useConnection(connection -> {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
try (ResultSet resultSet = statement.executeQuery("select count(*) from LINKED_ACCOUNTS;")) {
|
||||
try (ResultSet resultSet = statement.executeQuery("select count(*) from " + tablePrefix() + "LINKED_ACCOUNTS;")) {
|
||||
if (resultSet.next()) {
|
||||
return resultSet.getInt(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user