Skip to content

fix: Walmart order failed to load with an order_date Scan error - #116

Merged
eshaffer321 merged 2 commits into
mainfrom
fix/sqlite-unnamed-zone-timestamps
Nov 17, 2026
Merged

eshaffer321 merged 2 commits into
mainfrom
fix/sqlite-unnamed-zone-timestamps

Conversation

@eshaffer321

Copy link
Copy Markdown
Owner

Problem

Every sync reported Walmart order 02796073446817290005 as an error, even though it had already been processed successfully:

load processing record: sql: Scan error on column index 4, name "order_date": unsupported Scan, storing driver.Value type string into type *time.Time

Cause

By default modernc.org/sqlite writes a time.Time using time.Time.String(). This order's timestamp had offset -07:00 while the local zone was MDT (-06:00), so Go gave it an unnamed fixed zone, and String() rendered it as 2026-10-31 19:11:53 -0700 -0700. The driver can't parse that back into a time, so it returned a string and the scan into time.Time failed. The driver still behaves this way in v1.61.1.

Fix

  • NewStorage opens the DB with _time_format=sqlite, so times are written as 2006-01-02 15:04:05.999999999-07:00. The driver always parses this format, and SQLite's date functions understand it.
  • Migration 00011_repair_unnamed_zone_timestamps.sql rewrites existing ... -0700 -0700 values in every timestamp column to that form. The instant stays the same.

Side effect: the item search's date(order_date) used to return an empty date for every row, because SQLite couldn't read the old format. It now returns a UTC date for new and repaired rows.

Tests

  • TestStorage_SaveRecord_UnnamedFixedZoneRoundTrips and TestMigrations_RepairUnnamedZoneTimestamps failed with the production error before the fix and pass after it.
  • go test ./... -race passes, and golangci-lint v2.14.0 reports 0 issues.
  • Ran against a copy of a real database: the affected order now loads.

Logged in docs/bug-fixes.md.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.91%. Comparing base (c65affa) to head (8ef59d7).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
+ Coverage   66.88%   66.91%   +0.03%     
==========================================
  Files          53       53              
  Lines        7453     7460       +7     
==========================================
+ Hits         4985     4992       +7     
  Misses       2111     2111              
  Partials      357      357              
Flag Coverage Δ
unittests 66.91% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/infrastructure/storage/sqlite.go 76.40% <100.00%> (+0.12%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

modernc.org/sqlite writes time.Time with time.Time.String by default. For
a time in an unnamed fixed zone (an offset that differs from the local
zone's), that renders as "-0700 -0700", which the driver cannot parse back,
so GetRecord failed on every sync for that order.

Open the DB with _time_format=sqlite so times are written in SQLite's ISO
form, and add migration 00011 to rewrite existing broken values.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@eshaffer321
eshaffer321 force-pushed the fix/sqlite-unnamed-zone-timestamps branch from 50b7ce9 to 34d5375 Compare November 17, 2026 14:26
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@eshaffer321
eshaffer321 merged commit 248a031 into main Nov 17, 2026
14 checks passed
@eshaffer321
eshaffer321 deleted the fix/sqlite-unnamed-zone-timestamps branch November 17, 2026 14:32
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.

1 participant