mirror of
https://github.com/writefreely/writefreely
synced 2025-02-26 11:47:15 +00:00
Insert missing default values on post creation
- view_count This closes #7
This commit is contained in:
parent
426fa01fb4
commit
a0ac7bbbcd
1 changed files with 2 additions and 2 deletions
|
@ -557,7 +557,7 @@ func (db *datastore) CreatePost(userID, collID int64, post *SubmittedPost) (*Pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = db.Exec("INSERT INTO posts (id, slug, title, content, text_appearance, language, rtl, owner_id, collection_id, updated) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", friendlyID, slug, post.Title, post.Content, appearance, post.Language, post.IsRTL, ownerID, ownerCollID)
|
_, err = db.Exec("INSERT INTO posts (id, slug, title, content, text_appearance, language, rtl, owner_id, collection_id, updated, view_count) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)", friendlyID, slug, post.Title, post.Content, appearance, post.Language, post.IsRTL, ownerID, ownerCollID, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if mysqlErr, ok := err.(*mysql.MySQLError); ok {
|
if mysqlErr, ok := err.(*mysql.MySQLError); ok {
|
||||||
if mysqlErr.Number == mySQLErrDuplicateKey {
|
if mysqlErr.Number == mySQLErrDuplicateKey {
|
||||||
|
@ -565,7 +565,7 @@ func (db *datastore) CreatePost(userID, collID int64, post *SubmittedPost) (*Pos
|
||||||
// TODO: make this a little more robust
|
// TODO: make this a little more robust
|
||||||
// TODO: reuse exact same db.Exec statement as above
|
// TODO: reuse exact same db.Exec statement as above
|
||||||
slug = sql.NullString{id.GenSafeUniqueSlug(slug.String), true}
|
slug = sql.NullString{id.GenSafeUniqueSlug(slug.String), true}
|
||||||
_, err = db.Exec("INSERT INTO posts (id, slug, title, content, text_appearance, language, rtl, owner_id, collection_id, updated) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())", friendlyID, slug, post.Title, post.Content, appearance, post.Language, post.IsRTL, ownerID, ownerCollID)
|
_, err = db.Exec("INSERT INTO posts (id, slug, title, content, text_appearance, language, rtl, owner_id, collection_id, updated, view_count) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)", friendlyID, slug, post.Title, post.Content, appearance, post.Language, post.IsRTL, ownerID, ownerCollID, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, handleFailedPostInsert(fmt.Errorf("Retried slug generation, still failed: %v", err))
|
return nil, handleFailedPostInsert(fmt.Errorf("Retried slug generation, still failed: %v", err))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue