|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DB2Database | Line # 11 | 55 | 0% | 30 | 86 | 8.5% |
0.08510638
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(58) | |||
Result | |||
0.06382979
|
liquibase.database.core.DB2DatabaseTest.testGetDefaultDriver liquibase.database.core.DB2DatabaseTest.testGetDefaultDriver | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation liquibase.sqlgenerator.AbstractSqlGeneratorTest.isImplementation | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
0.021276595
|
liquibase.change.AbstractChangeTest.isSupported liquibase.change.AbstractChangeTest.isSupported | 1 PASS | |
0.021276595
|
liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid liquibase.sqlgenerator.AbstractSqlGeneratorTest.isValid | 1 PASS | |
1 | package liquibase.database.core; | |
2 | ||
3 | import java.text.ParseException; | |
4 | import java.text.SimpleDateFormat; | |
5 | ||
6 | import liquibase.database.AbstractDatabase; | |
7 | import liquibase.database.DatabaseConnection; | |
8 | import liquibase.exception.DatabaseException; | |
9 | import liquibase.exception.DateParseException; | |
10 | ||
11 | public class DB2Database extends AbstractDatabase { | |
12 | ||
13 | 0 | @Override |
14 | public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException { | |
15 | 0 | return conn.getDatabaseProductName().startsWith("DB2"); |
16 | } | |
17 | ||
18 | 2 | @Override |
19 | public String getDefaultDriver(String url) { | |
20 | 2 | if (url.startsWith("jdbc:db2")) { |
21 | 1 | return "com.ibm.db2.jcc.DB2Driver"; |
22 | } | |
23 | 1 | return null; |
24 | } | |
25 | ||
26 | 0 | @Override |
27 | public int getPriority() { | |
28 | 0 | return PRIORITY_DEFAULT; |
29 | } | |
30 | ||
31 | 57 | @Override |
32 | public String getTypeName() { | |
33 | 57 | return "db2"; |
34 | } | |
35 | ||
36 | 0 | @Override |
37 | protected String getDefaultDatabaseSchemaName() throws DatabaseException { // NOPMD | |
38 | 0 | return super.getDefaultDatabaseSchemaName().toUpperCase(); |
39 | } | |
40 | ||
41 | 0 | @Override |
42 | public boolean supportsInitiallyDeferrableColumns() { | |
43 | 0 | return false; |
44 | } | |
45 | ||
46 | 0 | @Override |
47 | public String getAutoIncrementClause() { | |
48 | 0 | return "GENERATED BY DEFAULT AS IDENTITY"; |
49 | } | |
50 | ||
51 | 0 | @Override |
52 | public String getCurrentDateTimeFunction() { | |
53 | 0 | if (currentDateTimeFunction != null) { |
54 | 0 | return currentDateTimeFunction; |
55 | } | |
56 | ||
57 | 0 | return "CURRENT TIMESTAMP"; |
58 | } | |
59 | ||
60 | /** | |
61 | * Return an DB2 date literal with the same value as a string formatted using ISO 8601. | |
62 | * <p/> | |
63 | * Convert an ISO8601 date string to one of the following results: to_date('1995-05-23', 'YYYY-MM-DD') | |
64 | * to_date('1995-05-23 09:23:59', 'YYYY-MM-DD HH24:MI:SS') | |
65 | * <p/> | |
66 | * Implementation restriction: Currently, only the following subsets of ISO8601 are supported: YYYY-MM-DD hh:mm:ss | |
67 | * YYYY-MM-DDThh:mm:ss | |
68 | */ | |
69 | 0 | @Override |
70 | public String getDateLiteral(String isoDate) { | |
71 | 0 | String normalLiteral = super.getDateLiteral(isoDate); |
72 | ||
73 | 0 | if (isDateOnly(isoDate)) { |
74 | 0 | StringBuffer val = new StringBuffer(); |
75 | 0 | val.append("DATE("); |
76 | 0 | val.append(normalLiteral); |
77 | 0 | val.append(')'); |
78 | 0 | return val.toString(); |
79 | 0 | } else if (isTimeOnly(isoDate)) { |
80 | 0 | StringBuffer val = new StringBuffer(); |
81 | 0 | val.append("TIME("); |
82 | 0 | val.append(normalLiteral); |
83 | 0 | val.append(')'); |
84 | 0 | return val.toString(); |
85 | 0 | } else if (isDateTime(isoDate)) { |
86 | 0 | StringBuffer val = new StringBuffer(); |
87 | 0 | val.append("TIMESTAMP("); |
88 | 0 | val.append(normalLiteral); |
89 | 0 | val.append(')'); |
90 | 0 | return val.toString(); |
91 | } else { | |
92 | 0 | return "UNSUPPORTED:" + isoDate; |
93 | } | |
94 | } | |
95 | ||
96 | 0 | @Override |
97 | public boolean shouldQuoteValue(String value) { | |
98 | 0 | return super.shouldQuoteValue(value) && !value.startsWith("\"SYSIBM\""); |
99 | } | |
100 | ||
101 | 0 | @Override |
102 | public boolean supportsTablespaces() { | |
103 | 0 | return true; |
104 | } | |
105 | ||
106 | 0 | @Override |
107 | public String getViewDefinition(String schemaName, String name) throws DatabaseException { | |
108 | 0 | return super.getViewDefinition(schemaName, name).replaceFirst("CREATE VIEW \\w+ AS ", ""); // db2 returns |
109 | // "create view....as | |
110 | // select | |
111 | } | |
112 | ||
113 | 0 | @Override |
114 | public java.util.Date parseDate(String dateAsString) throws DateParseException { | |
115 | 0 | try { |
116 | 0 | if (dateAsString.indexOf(' ') > 0) { |
117 | 0 | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateAsString); |
118 | 0 | } else if (dateAsString.indexOf('.') > 0 && dateAsString.indexOf('-') > 0) { |
119 | 0 | return new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSSSSS").parse(dateAsString); |
120 | ||
121 | } else { | |
122 | 0 | if (dateAsString.indexOf(':') > 0) { |
123 | 0 | return new SimpleDateFormat("HH:mm:ss").parse(dateAsString); |
124 | 0 | } else if (dateAsString.indexOf('.') > 0) { |
125 | 0 | return new SimpleDateFormat("HH.mm.ss").parse(dateAsString); |
126 | } else { | |
127 | 0 | return new SimpleDateFormat("yyyy-MM-dd").parse(dateAsString); |
128 | } | |
129 | } | |
130 | } catch (ParseException e) { | |
131 | 0 | throw new DateParseException(dateAsString); |
132 | } | |
133 | } | |
134 | ||
135 | 0 | @Override |
136 | public String convertRequestedSchemaToSchema(String requestedSchema) throws DatabaseException { | |
137 | 0 | if (requestedSchema == null) { |
138 | 0 | return getDefaultDatabaseSchemaName(); |
139 | } else { | |
140 | 0 | return requestedSchema.toUpperCase(); |
141 | } | |
142 | } | |
143 | ||
144 | 0 | @Override |
145 | public String convertRequestedSchemaToCatalog(String requestedSchema) throws DatabaseException { | |
146 | 0 | return null; |
147 | } | |
148 | ||
149 | 0 | @Override |
150 | public String generatePrimaryKeyName(String tableName) { | |
151 | 0 | String pkName = super.generatePrimaryKeyName(tableName); |
152 | 0 | if (pkName.length() > 18) { |
153 | 0 | pkName = pkName.substring(0, 17); |
154 | } | |
155 | 0 | return pkName; |
156 | } | |
157 | ||
158 | 0 | @Override |
159 | public String escapeIndexName(String schemaName, String indexName) { | |
160 | // does not support the schema name for the index - | |
161 | 0 | return super.escapeIndexName(null, indexName); |
162 | } | |
163 | ||
164 | } |
|