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/draft_post.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/post/draft_post.go') diff --git a/src/post/draft_post.go b/src/post/draft_post.go index 61283c3..0cb2ee1 100644 --- a/src/post/draft_post.go +++ b/src/post/draft_post.go @@ -61,7 +61,7 @@ func (s *draftStore) Set(post Post) error { body=excluded.body`, post.ID, post.Title, - post.Description, + &sql.NullString{String: post.Description, Valid: len(post.Description) > 0}, &sql.NullString{String: string(tagsJSON), Valid: len(post.Tags) > 0}, &sql.NullString{String: post.Series, Valid: post.Series != ""}, post.Body, @@ -112,12 +112,12 @@ func (s *draftStore) get( for rows.Next() { var ( - post Post - tags, series sql.NullString + post Post + description, tags, series sql.NullString ) err := rows.Scan( - &post.ID, &post.Title, &post.Description, &tags, &series, + &post.ID, &post.Title, &description, &tags, &series, &post.Body, ) @@ -125,6 +125,7 @@ func (s *draftStore) get( return nil, fmt.Errorf("scanning row: %w", err) } + post.Description = description.String post.Series = series.String if tags.String != "" { -- cgit v1.2.3