Fixed Mysql date conversion sql

This commit is contained in:
Rsl1122 2019-08-13 09:55:24 +03:00
parent 09c8955096
commit e51e6f4194
4 changed files with 10 additions and 29 deletions

View File

@ -56,12 +56,12 @@ public interface Sql {
@Override @Override
public String dateFromEpochSecond(String sql) { public String dateFromEpochSecond(String sql) {
return "FROM UNIXTIME(" + sql + ')'; return "FROM_UNIXTIME(" + sql + ')';
} }
@Override @Override
public String epochSecondFromDate(String sql) { public String epochSecondFromDate(String sql) {
return "UNIX TIMESTAMP(" + sql + ')'; return "UNIX_TIMESTAMP(" + sql + ')';
} }
@Override @Override

View File

@ -25,21 +25,15 @@ import com.djrapitops.plan.db.access.transactions.init.CreateTablesTransaction;
import com.djrapitops.plan.db.patches.KillsOptimizationPatch; import com.djrapitops.plan.db.patches.KillsOptimizationPatch;
import com.djrapitops.plan.db.patches.Patch; import com.djrapitops.plan.db.patches.Patch;
import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
import com.google.common.util.concurrent.MoreExecutors;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.io.TempDir;
import org.junit.platform.runner.JUnitPlatform; import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import utilities.CIProperties; import utilities.*;
import utilities.OptionalAssert;
import utilities.RandomData;
import utilities.TestConstants;
import utilities.mocks.PluginMockComponent; import utilities.mocks.PluginMockComponent;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue;
@ -74,10 +68,8 @@ class DBPatchMySQLRegressionTest extends DBPatchRegressionTest {
private MySQLDB underTest; private MySQLDB underTest;
@BeforeAll @BeforeAll
static void ensureCIServiceInUse(@TempDir Path tempDir) { static void ensureMySQLAvailable(@TempDir Path tempDir) {
boolean isCI = Boolean.parseBoolean(System.getenv(CIProperties.IS_CI_SERVICE)); assumeTrue(System.getenv(CIProperties.MYSQL_DATABASE) != null);
assumeTrue(isCI);
component = new PluginMockComponent(tempDir); component = new PluginMockComponent(tempDir);
} }
@ -100,19 +92,10 @@ class DBPatchMySQLRegressionTest extends DBPatchRegressionTest {
@BeforeEach @BeforeEach
void setUpDBWithOldSchema() throws Exception { void setUpDBWithOldSchema() throws Exception {
PlanSystem system = component.getPlanSystem(); PlanSystem system = component.getPlanSystem();
PlanConfig config = system.getConfigSystem().getConfig(); Optional<Database> db = new DBPreparer(system, TEST_PORT_NUMBER).prepareMySQL();
config.set(DatabaseSettings.MYSQL_DATABASE, "Plan"); assumeTrue(db.isPresent());
config.set(DatabaseSettings.MYSQL_USER, "travis");
config.set(DatabaseSettings.MYSQL_PASS, "");
config.set(DatabaseSettings.MYSQL_HOST, "127.0.0.1");
config.set(DatabaseSettings.TYPE, "MySQL");
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
system.enable(); underTest = (MySQLDB) db.get();
underTest = (MySQLDB) system.getDatabaseSystem().getActiveDatabaseByName(DBType.MYSQL.getName());
underTest.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
underTest.init();
dropAllTables(); dropAllTables();

View File

@ -68,7 +68,7 @@ public class SeleniumExtension implements ParameterResolver, BeforeAllCallback,
} }
private WebDriver getChromeWebDriver() { private WebDriver getChromeWebDriver() {
if (Boolean.parseBoolean(System.getenv(CIProperties.IS_CI_SERVICE))) { if (System.getenv(CIProperties.CHROME_DRIVER) != null) {
ChromeOptions chromeOptions = new ChromeOptions(); ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("/usr/bin/google-chrome-stable"); chromeOptions.setBinary("/usr/bin/google-chrome-stable");
chromeOptions.setHeadless(true); chromeOptions.setHeadless(true);

View File

@ -23,8 +23,6 @@ package utilities;
*/ */
public class CIProperties { public class CIProperties {
@Deprecated
public static final String IS_CI_SERVICE = "TRAVIS";
public static final String MYSQL_DATABASE = "MYSQL_DB"; public static final String MYSQL_DATABASE = "MYSQL_DB";
// Notice to CI configurer: This user should only have local access. // Notice to CI configurer: This user should only have local access.
// (To prevent outside connections with CI user) // (To prevent outside connections with CI user)