mirror of
				https://github.com/vran-dev/databasir.git
				synced 2025-10-31 20:49:22 +08:00 
			
		
		
		
	fix: mysql trigger save failed by time formate error (#159)
This commit is contained in:
		| @@ -12,10 +12,15 @@ import java.sql.SQLException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| @Slf4j | ||||
| public class MysqlTableTriggerMetaProvider implements TriggerMetaProvider { | ||||
|  | ||||
|     private static final Pattern DATE_TIME_PATTERN = | ||||
|             Pattern.compile("(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})(.*)"); | ||||
|  | ||||
|     @Override | ||||
|     public List<TriggerMeta> selectTriggers(Connection connection, TableCondition condition) { | ||||
|         String sql = "SELECT TRIGGER_CATALOG,\n" | ||||
| @@ -50,6 +55,12 @@ public class MysqlTableTriggerMetaProvider implements TriggerMetaProvider { | ||||
|                 String timing = results.getString("ACTION_TIMING"); | ||||
|                 String manipulation = results.getString("EVENT_MANIPULATION"); | ||||
|                 String created = results.getString("CREATED"); | ||||
|                 if (created != null) { | ||||
|                     Matcher matcher = DATE_TIME_PATTERN.matcher(created); | ||||
|                     if (matcher.matches()) { | ||||
|                         created = matcher.group(1); | ||||
|                     } | ||||
|                 } | ||||
|                 TriggerMeta meta = TriggerMeta.builder() | ||||
|                         .name(name) | ||||
|                         .manipulation(manipulation) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user