From 7f98d45ae150521f6f9bdb1c1eaa37a54e4e90a5 Mon Sep 17 00:00:00 2001 From: Patrick DeVivo Date: Sat, 12 Dec 2020 21:29:55 -0500 Subject: [PATCH] if a datetime is a zero value, return null --- pkg/ghqlite/pull_requests_vtab.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/ghqlite/pull_requests_vtab.go b/pkg/ghqlite/pull_requests_vtab.go index 0ece843a..40986e3d 100644 --- a/pkg/ghqlite/pull_requests_vtab.go +++ b/pkg/ghqlite/pull_requests_vtab.go @@ -142,13 +142,33 @@ func (vc *pullRequestsCursor) Column(c *sqlite3.SQLiteContext, col int) error { case 11: c.ResultText(pr.GetActiveLockReason()) case 12: - c.ResultText(pr.GetCreatedAt().Format(time.RFC3339Nano)) + t := pr.GetCreatedAt() + if t.IsZero() { + c.ResultNull() + } else { + c.ResultText(t.Format(time.RFC3339Nano)) + } case 13: - c.ResultText(pr.GetUpdatedAt().Format(time.RFC3339Nano)) + t := pr.GetUpdatedAt() + if t.IsZero() { + c.ResultNull() + } else { + c.ResultText(t.Format(time.RFC3339Nano)) + } case 14: - c.ResultText(pr.GetClosedAt().Format(time.RFC3339Nano)) + t := pr.GetClosedAt() + if t.IsZero() { + c.ResultNull() + } else { + c.ResultText(t.Format(time.RFC3339Nano)) + } case 15: - c.ResultText(pr.GetMergedAt().Format(time.RFC3339Nano)) + t := pr.GetMergedAt() + if t.IsZero() { + c.ResultNull() + } else { + c.ResultText(t.Format(time.RFC3339Nano)) + } case 16: c.ResultText(pr.GetMergeCommitSHA()) case 17: