From e7b5b55f6718b25a437a891a06a26c21384b6818 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Wed, 18 Jan 2023 20:15:12 +0100 Subject: Add format column to post tables --- src/post/draft_post.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/post/draft_post.go') diff --git a/src/post/draft_post.go b/src/post/draft_post.go index 0cb2ee1..1c0e075 100644 --- a/src/post/draft_post.go +++ b/src/post/draft_post.go @@ -49,22 +49,24 @@ func (s *draftStore) Set(post Post) error { _, err = s.db.db.Exec( `INSERT INTO post_drafts ( - id, title, description, tags, series, body + id, title, description, tags, series, body, format ) VALUES - (?, ?, ?, ?, ?, ?) + (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (id) DO UPDATE SET title=excluded.title, description=excluded.description, tags=excluded.tags, series=excluded.series, - body=excluded.body`, + body=excluded.body, + format=excluded.format`, post.ID, post.Title, &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, + post.Format, ) if err != nil { @@ -86,7 +88,7 @@ func (s *draftStore) get( query := ` SELECT - p.id, p.title, p.description, p.tags, p.series, p.body + p.id, p.title, p.description, p.tags, p.series, p.body, p.format FROM post_drafts p ` + where + ` ORDER BY p.id ASC` @@ -118,7 +120,7 @@ func (s *draftStore) get( err := rows.Scan( &post.ID, &post.Title, &description, &tags, &series, - &post.Body, + &post.Body, &post.Format, ) if err != nil { -- cgit v1.2.3