Skip to content

Conversation

@dmalykh-devexpress
Copy link
Contributor

…a date handling and filter operations for better type safety and performance

…a date handling and filter operations for better type safety and performance
Copilot AI review requested due to automatic review settings October 22, 2025 07:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors OData date handling and filter operations to improve type safety and code readability. The changes focus on modernizing JavaScript patterns, adding TypeScript type annotations, and simplifying conditional logic.

Key changes:

  • Modernized date formatting utilities by replacing manual string padding with native padStart/padEnd methods
  • Added null safety checks and improved error handling in OData date parsing
  • Enhanced type annotations across OData utility functions for better type safety

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
m_filter_custom_operations.ts Replaced logical AND operator with optional chaining and improved conditional formatting
m_columns_controller.ts Added blank line for code formatting consistency
m_utils.ts Replaced chained if-else with early returns using optional chaining for cleaner control flow
m_utils.ts (OData) Refactored date utilities with TypeScript types, replaced manual padding with native methods, added null check in date parsing, and improved V2 serialization
m_request_dispatcher.ts Added nullish coalescing operator for default value assignment

// OData v4 format
} else if (ISO8601_DATE_REGEX.test(value)) {
obj[key] = new Date(parseISO8601(obj[key]).valueOf());
obj[key] = new Date(parseISO8601(obj[key])!.valueOf());
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Non-null assertion operator is unsafe here. If parseISO8601 returns null (which can happen when date regex fails), this will throw a runtime error. Use optional chaining with a fallback or proper null check instead: const parsed = parseISO8601(obj[key]); if (parsed) { obj[key] = new Date(parsed.valueOf()); }

Suggested change
obj[key] = new Date(parseISO8601(obj[key])!.valueOf());
const parsed = parseISO8601(obj[key]);
if (parsed) {
obj[key] = new Date(parsed.valueOf());
}

Copilot uses AI. Check for mistakes.
Comment on lines 446 to 448
if (typeof value === 'string' && ISO8601_DATE_REGEX.test(value)) {
return formatISO8601(new Date(value), false, false);
}
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

This new check in serializeValueV2 may create unintended side effects. Any string matching ISO8601 format will be re-formatted, potentially changing values that were intentionally formatted differently. Consider if this behavior is desired or if it should only apply to Date objects.

Suggested change
if (typeof value === 'string' && ISO8601_DATE_REGEX.test(value)) {
return formatISO8601(new Date(value), false, false);
}
// Removed ISO8601 string re-formatting to avoid unintended side effects.

Copilot uses AI. Check for mistakes.
- Updated `fieldTypes` and `keyType` in `data.d.ts` to include 'DateTime' and 'DateTimeOffset'.
- Improved `keyConverters` in `m_utils.ts` to handle DateTime conversion from string and number types, with error handling for invalid values.
@dmalykh-devexpress dmalykh-devexpress requested a review from a team as a code owner October 24, 2025 07:02
@dmalykh-devexpress dmalykh-devexpress changed the title Update tasks.json for improved build and test commands; refactor ODat… refactor ODat… Oct 24, 2025
@dmalykh-devexpress dmalykh-devexpress changed the title refactor ODat… refactor OData date handling and filter operations for better type safety and performance Oct 24, 2025
Copilot AI review requested due to automatic review settings October 24, 2025 07:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@dmalykh-devexpress dmalykh-devexpress force-pushed the 1204-odatastore-think-about-customizing-datetime-parsing branch from 6533e7a to 959572a Compare October 27, 2025 08:47
Copilot AI review requested due to automatic review settings October 27, 2025 10:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings October 30, 2025 12:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

// If string, try to convert to Date
if (typeof value === 'string') {
const date = new Date(value);
if (isNaN(date.getTime())) {
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Use Number.isNaN() instead of the global isNaN() function. Number.isNaN() is more reliable as it doesn't perform type coercion and only returns true for actual NaN values. The global isNaN() can produce unexpected results with non-numeric inputs.

Suggested change
if (isNaN(date.getTime())) {
if (Number.isNaN(date.getTime())) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants