Repository navigation
Zero times are NULL, and query keys have two or more parts - #52
Merged
Merged
Conversation
…e zero time So a nullable timestamp column round-trips a time.Time without a pointer. filesearch's tests now give objects a modtime, as its column is NOT NULL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n error So a one-word comment line, such as "-- change", isn't read as a key, which left the key before it without its statement. Closes #51. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coverage for this change: 90.7% |
There was a problem hiding this comment.
🟡 Changes recommended
Zero-time handling can cause existing index entries to be deleted during reindexing and applies NULL conversion inconsistently between time values and pointers.
2 open issues
What changed in this PR
Updates the shared value-conversion layer so nullable timestamps can use plain time.Time values without pointers or helpers.
Changes:
- Binds zero
time.Timevalues as SQLNULLand scansNULLinto zero times. - Adds conversion tests and supplies nonzero modification times in two filesearch test fixtures.
- Documents the new timestamp behavior.
| File | Description |
|---|---|
values/values_test.go |
Tests zero-time binding and NULL-to-time scanning. |
values/set.go |
Converts zero time.Time values to NULL. |
values/scan.go |
Allows NULL to scan into time.Time. |
README.md |
Documents nullable timestamp conversions. |
filesearch/schema/schema_test.go |
Supplies modification times required by NOT NULL constraints. |
Review effort: Balanced
…ch stores a zero modtime as text filesearch's modtime is NOT NULL, and an fs.FS can have no modification times, so it binds the time's text, which is matched when the object is marked, rather than NULL, which isn't, and would have it swept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Two fixes for the next release.
A zero time.Time is NULL, and NULL scans into a zero time.Time
A nullable timestamp column can now be read and written as a plain
time.Time, without a pointer or a helper.time.Timebinds asNULL, not0001-01-01T00:00:00Z.NULLinto atime.Timeis the zero time, not an error.NULLinto a*time.Timeis still nil, and into other non-pointer values, such as a string, is still an error.NOT NULLcolumn is now a constraint error. Before, it was stored as year 1. filesearch's tests inserted two objects without a modtime, so they now set one. Rows that already hold0001-01-01T00:00:00Zstill read back as the zero time.Saved query keys have two or more parts (closes #51)
x.y, or longer. A comment line of one word, such as-- change, is an ordinary comment. Before, it started a new key and left the previous key with an empty statement.NewQueries, so this can't fail silently again.-- credential, needs its keys renamed before upgrading. go-auth'scredential/pg/schema/objects.sqlhas one, but it uses go-pg, which has the same fix in go-pg #138.