summaryrefslogtreecommitdiff
path: root/src/post/draft_post.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-10-12 23:43:31 +0200
committerBrian Picciano <mediocregopher@gmail.com>2022-10-12 23:43:31 +0200
commitd9570411134273d690e783748dd572696fc14c6f (patch)
treeca9d0780bdc2708e190a2194b751966546935e39 /src/post/draft_post.go
parentd959985ed0d3509d1369c15bf0c87c35b47eb1db (diff)
Make description an optional field
Diffstat (limited to 'src/post/draft_post.go')
-rw-r--r--src/post/draft_post.go9
1 files changed, 5 insertions, 4 deletions
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 != "" {