Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanning of timestamps not working when using "with time zone" #1214

Open
coma64 opened this issue Feb 3, 2024 · 0 comments
Open

Scanning of timestamps not working when using "with time zone" #1214

coma64 opened this issue Feb 3, 2024 · 0 comments

Comments

@coma64
Copy link

coma64 commented Feb 3, 2024

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)
}
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

No branches or pull requests

1 participant