|
|
@@ -185,22 +185,23 @@ class TDengineServiceTest {
|
|
185
|
185
|
@Test
|
|
186
|
186
|
@DisplayName("getColumnTypeForDDL: BOOL/BIGINT/DOUBLE/TIMESTAMP 直接返回")
|
|
187
|
187
|
void getColumnTypeForDDL_directTypes() throws Exception {
|
|
188
|
|
- Method method = TdEngineService.class.getDeclaredMethod("getColumnTypeForDDL", String.class, String.class);
|
|
|
188
|
+ Method method = TdEngineService.class.getDeclaredMethod("getColumnTypeForDDL", String.class, Integer.class);
|
|
189
|
189
|
method.setAccessible(true);
|
|
190
|
190
|
|
|
191
|
|
- assertThat(method.invoke(tdengineService, "BOOL", "col")).isEqualTo("BOOL");
|
|
192
|
|
- assertThat(method.invoke(tdengineService, "BIGINT", "col")).isEqualTo("BIGINT");
|
|
193
|
|
- assertThat(method.invoke(tdengineService, "DOUBLE", "col")).isEqualTo("DOUBLE");
|
|
194
|
|
- assertThat(method.invoke(tdengineService, "TIMESTAMP", "col")).isEqualTo("TIMESTAMP");
|
|
|
191
|
+ assertThat(method.invoke(tdengineService, "BOOL", null)).isEqualTo("BOOL");
|
|
|
192
|
+ assertThat(method.invoke(tdengineService, "BIGINT", null)).isEqualTo("BIGINT");
|
|
|
193
|
+ assertThat(method.invoke(tdengineService, "DOUBLE", null)).isEqualTo("DOUBLE");
|
|
|
194
|
+ assertThat(method.invoke(tdengineService, "TIMESTAMP", null)).isEqualTo("TIMESTAMP");
|
|
195
|
195
|
}
|
|
196
|
196
|
|
|
197
|
197
|
@Test
|
|
198
|
|
- @DisplayName("getColumnTypeForDDL: VARCHAR 返回 VARCHAR(255)")
|
|
|
198
|
+ @DisplayName("getColumnTypeForDDL: VARCHAR 返回带长度")
|
|
199
|
199
|
void getColumnTypeForDDL_varchar_returnsWithLength() throws Exception {
|
|
200
|
|
- Method method = TdEngineService.class.getDeclaredMethod("getColumnTypeForDDL", String.class, String.class);
|
|
|
200
|
+ Method method = TdEngineService.class.getDeclaredMethod("getColumnTypeForDDL", String.class, Integer.class);
|
|
201
|
201
|
method.setAccessible(true);
|
|
202
|
202
|
|
|
203
|
|
- assertThat(method.invoke(tdengineService, "VARCHAR", "col")).isEqualTo("VARCHAR(255)");
|
|
|
203
|
+ assertThat(method.invoke(tdengineService, "VARCHAR", 250)).isEqualTo("VARCHAR(255)");
|
|
|
204
|
+ assertThat(method.invoke(tdengineService, "VARCHAR", null)).isEqualTo("VARCHAR(16)");
|
|
204
|
205
|
}
|
|
205
|
206
|
|
|
206
|
207
|
@Test
|
|
|
@@ -241,14 +242,14 @@ class TDengineServiceTest {
|
|
241
|
242
|
}
|
|
242
|
243
|
|
|
243
|
244
|
@Test
|
|
244
|
|
- @DisplayName("formatValue: VARCHAR 类型超长时截断存储")
|
|
245
|
|
- void formatValue_varchar_exceedsLength_truncates() throws Exception {
|
|
|
245
|
+ @DisplayName("formatValue: VARCHAR 类型不截断,完整返回")
|
|
|
246
|
+ void formatValue_varchar_noTruncation() throws Exception {
|
|
246
|
247
|
Method method = TdEngineService.class.getDeclaredMethod("formatValue", Object.class, String.class, String.class);
|
|
247
|
248
|
method.setAccessible(true);
|
|
248
|
249
|
|
|
249
|
250
|
String longStr = "a".repeat(300);
|
|
250
|
251
|
assertThat(method.invoke(tdengineService, longStr, "col", "VARCHAR"))
|
|
251
|
|
- .isEqualTo("'" + "a".repeat(255) + "'");
|
|
|
252
|
+ .isEqualTo("'" + "a".repeat(300) + "'");
|
|
252
|
253
|
}
|
|
253
|
254
|
|
|
254
|
255
|
@Test
|
|
|
@@ -281,15 +282,15 @@ class TDengineServiceTest {
|
|
281
|
282
|
}
|
|
282
|
283
|
|
|
283
|
284
|
@Test
|
|
284
|
|
- @DisplayName("isReservedColumn: ts 和 surfacename 返回 true")
|
|
|
285
|
+ @DisplayName("isReservedColumn: ts 和 controller_id 返回 true")
|
|
285
|
286
|
void isReservedColumn_reservedNames() throws Exception {
|
|
286
|
287
|
Method method = TdEngineService.class.getDeclaredMethod("isReservedColumn", String.class);
|
|
287
|
288
|
method.setAccessible(true);
|
|
288
|
289
|
|
|
289
|
290
|
assertThat(method.invoke(tdengineService, "ts")).isEqualTo(true);
|
|
290
|
291
|
assertThat(method.invoke(tdengineService, "TS")).isEqualTo(true);
|
|
291
|
|
- assertThat(method.invoke(tdengineService, "surfacename")).isEqualTo(true);
|
|
292
|
|
- assertThat(method.invoke(tdengineService, "Surfacename")).isEqualTo(true);
|
|
|
292
|
+ assertThat(method.invoke(tdengineService, "controller_id")).isEqualTo(true);
|
|
|
293
|
+ assertThat(method.invoke(tdengineService, "CONTROLLER_ID")).isEqualTo(true);
|
|
293
|
294
|
}
|
|
294
|
295
|
|
|
295
|
296
|
@Test
|