From d9570411134273d690e783748dd572696fc14c6f Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Wed, 12 Oct 2022 23:43:31 +0200 Subject: Make description an optional field --- src/post/post.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/post/post.go') diff --git a/src/post/post.go b/src/post/post.go index 03bce6c..1bdf03e 100644 --- a/src/post/post.go +++ b/src/post/post.go @@ -115,7 +115,7 @@ func (s *store) Set(post Post, now time.Time) (bool, error) { body=excluded.body`, post.ID, post.Title, - post.Description, + &sql.NullString{String: post.Description, Valid: len(post.Description) > 0}, &sql.NullString{String: post.Series, Valid: post.Series != ""}, nowSQL, post.Body, @@ -202,12 +202,12 @@ func (s *store) get( var ( post StoredPost - series, tag sql.NullString + description, tag, series sql.NullString publishedAt, lastUpdatedAt sql.NullInt64 ) err := rows.Scan( - &post.ID, &post.Title, &post.Description, &series, &tag, + &post.ID, &post.Title, &description, &series, &tag, &publishedAt, &lastUpdatedAt, &post.Body, ) @@ -216,6 +216,7 @@ func (s *store) get( return nil, fmt.Errorf("scanning row: %w", err) } + post.Description = description.String post.Series = series.String if tag.String != "" { -- cgit v1.2.3