Scanning of timestamps not working when using "with time zone"
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 9.2k
- Forks
- 1.2k
- Avg merge
- 19m
- Merged PRs (30d)
- 4
Description
With a column of type "timestamp with time zone", like in the following table, sqlite3 doesn't convert it into a time.Time and scanning such a row into a time.Time field therefore fails.
create table snippets(
id binary(16) primary key,
content text not null,
created_at timestamp with time zone not null default CURRENT_TIMESTAMP
);
I traced this to SQLiteRows.nextSyncLocked() where you check whether rc.decltype[i] is any of date, datetime or timestamp but in my case it's timestamp with time zone causing the value to not be converted from a string.
go version: go version go1.21.3 darwin/arm64
Code
type Snippet struct {
Id string
Content string
CreatedAt time.Time `db:"created_at"`
}
snippet := Snippet{
Id: id.String(),
Content: content,
}
if err = s.db.GetContext(ctx, &snippet, "insert into snippets(id, content) values ($1, $2) returning created_at", binaryId, content); err != nil {
return nil, fmt.Errorf("inserting snippet: %w", err)
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading SQLiteRows.nextSyncLocked() and the handling of rc.decltype[i], then reproduce the provided table schema and returning query. Done means a timestamp with time zone column is converted so scanning the returned value into the Snippet.CreatedAt time.Time field succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100