rusackas opened a new pull request, #34514:
URL: https://github.com/apache/superset/pull/34514
### SUMMARY
This PR fixes an issue where datetime values outside JavaScript's safe date
range were returning "0NaN-NaN-NaN" in charts when using Microsoft SQL Server.
The root cause was that MSSQL supports a much wider datetime range
(1753-9999) than JavaScript's Date object can handle (approximately 1938-2286).
When dates outside this range were converted to epoch milliseconds, they would
overflow JavaScript's Number type, resulting in NaN values that displayed as
"0NaN-NaN-NaN" in charts.
**Changes:**
- Added constants defining JavaScript's safe date range in
`superset/utils/dates.py`
- Modified `json_int_dttm_ser` to return ISO strings for dates outside the
safe range
- Added comprehensive tests for edge cases
- Maintains backward compatibility for dates within the normal range
Fixes #27790
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** Charts display "0NaN-NaN-NaN" for datetime values outside
JavaScript's safe range
**After:** Charts display the actual datetime values correctly as ISO strings
### TESTING INSTRUCTIONS
1. Connect to a Microsoft SQL Server database
2. Create a query with datetime values outside JavaScript's safe range:
```sql
SELECT
CAST('1938-04-24 22:13:20.002' AS DATETIME) AS early_date,
CAST('2286-11-20 17:46:39.998' AS DATETIME) AS late_date,
CAST('2000-01-01 12:00:00' AS DATETIME) AS normal_date
```
3. Create a chart using these datetime columns
4. Verify that:
- Early and late dates display as proper datetime strings (not
"0NaN-NaN-NaN")
- Normal dates continue to work as before
- No JavaScript console errors appear
### ADDITIONAL INFORMATION
- [x] Has associated issue: #27790
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.ai/code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]