mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 16:14:26 +08:00
Fixed order by related exception with some mysql versions
This commit is contained in:
parent
0dd5d41955
commit
624ed50054
@ -206,7 +206,7 @@ public class UserInfoQueries {
|
|||||||
FROM + UserInfoTable.TABLE_NAME +
|
FROM + UserInfoTable.TABLE_NAME +
|
||||||
") q1" +
|
") q1" +
|
||||||
GROUP_BY + "address" +
|
GROUP_BY + "address" +
|
||||||
ORDER_BY + "address DESC";
|
ORDER_BY + "address ASC";
|
||||||
|
|
||||||
return new QueryStatement<Map<String, Integer>>(sql, 100) {
|
return new QueryStatement<Map<String, Integer>>(sql, 100) {
|
||||||
@Override
|
@Override
|
||||||
@ -232,7 +232,7 @@ public class UserInfoQueries {
|
|||||||
FROM + UserInfoTable.TABLE_NAME +
|
FROM + UserInfoTable.TABLE_NAME +
|
||||||
WHERE + UserInfoTable.SERVER_UUID + "=?" +
|
WHERE + UserInfoTable.SERVER_UUID + "=?" +
|
||||||
GROUP_BY + "address" +
|
GROUP_BY + "address" +
|
||||||
ORDER_BY + "address DESC";
|
ORDER_BY + "address ASC";
|
||||||
|
|
||||||
return new QueryStatement<Map<String, Integer>>(sql, 100) {
|
return new QueryStatement<Map<String, Integer>>(sql, 100) {
|
||||||
@Override
|
@Override
|
||||||
@ -255,7 +255,7 @@ public class UserInfoQueries {
|
|||||||
public static Query<List<String>> uniqueJoinAddresses() {
|
public static Query<List<String>> uniqueJoinAddresses() {
|
||||||
String sql = SELECT + DISTINCT + "LOWER(COALESCE(" + UserInfoTable.JOIN_ADDRESS + ", ?)) as address" +
|
String sql = SELECT + DISTINCT + "LOWER(COALESCE(" + UserInfoTable.JOIN_ADDRESS + ", ?)) as address" +
|
||||||
FROM + UserInfoTable.TABLE_NAME +
|
FROM + UserInfoTable.TABLE_NAME +
|
||||||
ORDER_BY + UserInfoTable.JOIN_ADDRESS + " DESC";
|
ORDER_BY + "address ASC";
|
||||||
return new QueryStatement<List<String>>(sql, 100) {
|
return new QueryStatement<List<String>>(sql, 100) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
|
@ -310,6 +310,31 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer {
|
|||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
default void joinAddressFilterOptionsAreFetched() {
|
||||||
|
joinAddressIsUpdatedUponSecondLogin();
|
||||||
|
|
||||||
|
List<String> expected = Collections.singletonList(TestConstants.GET_PLAYER_HOSTNAME.get().toLowerCase());
|
||||||
|
List<String> result = db().query(UserInfoQueries.uniqueJoinAddresses());
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
default void joinAddressFilterOptionsAreFetchedWhenThereAreMultiple() {
|
||||||
|
joinAddressIsUpdatedUponSecondLogin();
|
||||||
|
|
||||||
|
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), () -> TestConstants.GET_PLAYER_HOSTNAME.get() + "_b"));
|
||||||
|
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, TestConstants.SERVER_TWO_UUID, () -> TestConstants.GET_PLAYER_HOSTNAME.get() + "_a"));
|
||||||
|
|
||||||
|
List<String> expected = Arrays.asList(
|
||||||
|
TestConstants.GET_PLAYER_HOSTNAME.get().toLowerCase() + "_a",
|
||||||
|
TestConstants.GET_PLAYER_HOSTNAME.get().toLowerCase() + "_b"
|
||||||
|
);
|
||||||
|
List<String> result = db().query(UserInfoQueries.uniqueJoinAddresses());
|
||||||
|
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
default void joinAddressFilterUUIDsAreFetched() {
|
default void joinAddressFilterUUIDsAreFetched() {
|
||||||
joinAddressIsUpdatedUponSecondLogin();
|
joinAddressIsUpdatedUponSecondLogin();
|
||||||
|
Loading…
Reference in New Issue
Block a user