mattn / mattn/go-sqlite3

Proposed PR: configurable time encoding

Open
#1,126 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
9.2k
Forks
1.2k
Avg merge
19m
Merged PRs (30d)
4

Description

Hi, and thank you for an excellent library that I've used for years!

This driver stores time.Time values as strings: https://github.com/mattn/go-sqlite3/blob/85436841b33e86c07dce0fa2e88c31a97c96a22f/sqlite3.go#L219 but for compactness and consistency I always prefer to use unix timestamps. This has meant always modifying my Go code to save an int version of whatever time I'm using.

I'd like to propose a new driver configuration parameter, _time_format, that would let one opt into different storage formats. This lets you use time.Time directly but get the encoding you want. I've built a version that allows unix and unix_ms formats, and it is a small (~dozen LOC) change: kalafut/go-sqlite3.

Other formats could be added in the future too, which might be useful (e.g. I noticed https://github.com/mattn/go-sqlite3/issues/951#issuecomment-985078746). Note that this is completely opt-in and only affects the way values are written. Reading/parsing is unchanged.

Is this of any interest? If so I can prepare a proper PR with better, consolidated tests, and some docs.

Thanks for taking a look.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sqlite3.go around the time.Time handling linked in the issue, then compare the proposed implementation in the referenced fork. Add consolidated tests for the unix and unix_ms formats and document the _time_format option, while preserving the existing reading behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sqlite
Domain
database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.