diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-10-12 23:43:31 +0200 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-10-12 23:43:31 +0200 |
commit | d9570411134273d690e783748dd572696fc14c6f (patch) | |
tree | ca9d0780bdc2708e190a2194b751966546935e39 /src/post/post.go | |
parent | d959985ed0d3509d1369c15bf0c87c35b47eb1db (diff) |
Make description an optional field
Diffstat (limited to 'src/post/post.go')
-rw-r--r-- | src/post/post.go | 7 |
1 files changed, 4 insertions, 3 deletions
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 != "" { |