Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type cast error #1468

Merged
merged 3 commits into from
Nov 8, 2023
Merged

fix: type cast error #1468

merged 3 commits into from
Nov 8, 2023

Conversation

ljvv7
Copy link
Contributor

@ljvv7 ljvv7 commented Nov 5, 2023

No description provided.

@@ -495,8 +495,12 @@ private static Object convert(Object value, String newDataType) {
value = convertNumber(value, s -> new BigDecimal(s).longValue());
break;
case "DATE":
DateTime dateTime = AnyTimeToDateTime.toDateTime(value);
value = dateTime.toDate();
if (value instanceof String) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要补充单元测试

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

@ply0011 ply0011 closed this Nov 6, 2023
@ply0011 ply0011 reopened this Nov 6, 2023
@ljvv7 ljvv7 requested a review from ply0011 November 7, 2023 01:38
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空字符串会有什么表现?

* Example input: {"value": "DateTime nano 0 seconds 1327149189 timeZone null", "newDateType": "Date"}
* Expected output: IllegalArgumentException(DateTime constructor illegal dateStr: value)
*/
@Test(expected = RuntimeException.class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

期望与注释不一致

} else {
DateTime dateTime = AnyTimeToDateTime.toDateTime(value);
value = dateTime.toDate();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提供更好的异常信息,例如:日期类型转换失败,字段名:xxx,原始类型: String,原始值:xxx

@ljvv7 ljvv7 requested a review from ply0011 November 7, 2023 08:40
@jackin-code jackin-code merged commit 8015727 into develop Nov 8, 2023
@jackin-code jackin-code deleted the fix-casttype-error branch November 8, 2023 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants