@Test public void buildUndoSQL() { String sql = executor.buildUndoSQL().toLowerCase(); Assertions.assertNotNull(sql); Assertions.assertTrue(sql.contains("delete")); Assertions.assertTrue(sql.contains("id")); }
@Override protected String buildUndoSQL() { KeywordChecker keywordChecker = KeywordCheckerFactory.getKeywordChecker(JdbcConstants.MYSQL); TableRecords afterImage = sqlUndoLog.getAfterImage(); List<Row> afterImageRows = afterImage.getRows(); if (afterImageRows == null || afterImageRows.size() == 0) { throw new ShouldNeverHappenException("Invalid UNDO LOG"); } Row row = afterImageRows.get(0); Field pkField = row.primaryKeys().get(0); return String.format(DELETE_SQL_TEMPLATE, keywordChecker.checkAndReplace(sqlUndoLog.getTableName()), keywordChecker.checkAndReplace(pkField.getName())); }
MySQLUndoInsertExecutor extends AbstractUndoExecutor { @Override protected String buildUndoSQL() { KeywordChecker keywordChecker = KeywordCheckerFactory.getKeywordChecker(JdbcConstants.MYSQL); TableRecords afterImage = sqlUndoLog.getAfterImage(); List<Row> afterImageRows = afterImage.getRows(); if (afterImageRows == null || afterImageRows.size() == 0) { throw new ShouldNeverHappenException("Invalid UNDO LOG"); } Row row = afterImageRows.get(0); Field pkField = row.primaryKeys().get(0); return String.format(DELETE_SQL_TEMPLATE, keywordChecker.checkAndReplace(sqlUndoLog.getTableName()), keywordChecker.checkAndReplace(pkField.getName())); } }
MySQLUndoInsertExecutor extends AbstractUndoExecutor { @Override protected String buildUndoSQL() { KeywordChecker keywordChecker = KeywordCheckerFactory.getKeywordChecker(JdbcConstants.MYSQL); TableRecords afterImage = sqlUndoLog.getAfterImage(); List<Row> afterImageRows = afterImage.getRows(); if (afterImageRows == null || afterImageRows.size() == 0) { throw new ShouldNeverHappenException("Invalid UNDO LOG"); } Row row = afterImageRows.get(0); Field pkField = row.primaryKeys().get(0); return String.format(DELETE_SQL_TEMPLATE, keywordChecker.checkAndReplace(sqlUndoLog.getTableName()), keywordChecker.checkAndReplace(pkField.getName())); } MySQLUndoInsertExecutor(SQLUndoLog sqlUndoLog); }
MySQLUndoInsertExecutor extends AbstractUndoExecutor { @Override protected String buildUndoSQL() { KeywordChecker keywordChecker = KeywordCheckerFactory.getKeywordChecker(JdbcConstants.MYSQL); TableRecords afterImage = sqlUndoLog.getAfterImage(); List<Row> afterImageRows = afterImage.getRows(); if (afterImageRows == null || afterImageRows.size() == 0) { throw new ShouldNeverHappenException("Invalid UNDO LOG"); } Row row = afterImageRows.get(0); Field pkField = row.primaryKeys().get(0); return String.format(DELETE_SQL_TEMPLATE, keywordChecker.checkAndReplace(sqlUndoLog.getTableName()), keywordChecker.checkAndReplace(pkField.getName())); } MySQLUndoInsertExecutor(SQLUndoLog sqlUndoLog);  }
MySQLUndoInsertExecutor extends AbstractUndoExecutor { @Override protected String buildUndoSQL() { KeywordChecker keywordChecker = KeywordCheckerFactory.getKeywordChecker(JdbcConstants.MYSQL); TableRecords afterImage = sqlUndoLog.getAfterImage(); List<Row> afterImageRows = afterImage.getRows(); if (afterImageRows == null || afterImageRows.size() == 0) { throw new ShouldNeverHappenException("Invalid UNDO LOG"); } Row row = afterImageRows.get(0); Field pkField = row.primaryKeys().get(0); return String.format(DELETE_SQL_TEMPLATE, keywordChecker.checkAndReplace(sqlUndoLog.getTableName()), keywordChecker.checkAndReplace(pkField.getName())); } MySQLUndoInsertExecutor(SQLUndoLog sqlUndoLog);   }