Remove the posts.privacy column
This commit is contained in:
12
database.go
12
database.go
@@ -824,7 +824,7 @@ func (db *datastore) UpdateCollection(c *SubmittedCollection, alias string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
const postCols = "id, slug, text_appearance, language, rtl, privacy, owner_id, collection_id, pinned_position, created, updated, view_count, title, content"
|
||||
const postCols = "id, slug, text_appearance, language, rtl, owner_id, collection_id, pinned_position, created, updated, view_count, title, content"
|
||||
|
||||
// getEditablePost returns a PublicPost with the given ID only if the given
|
||||
// edit token is valid for the post.
|
||||
@@ -835,7 +835,7 @@ func (db *datastore) GetEditablePost(id, editToken string) (*PublicPost, error)
|
||||
p := &Post{}
|
||||
|
||||
row := db.QueryRow("SELECT "+postCols+", (SELECT username FROM users WHERE users.id = posts.owner_id) AS username FROM posts WHERE id = ? LIMIT 1", id)
|
||||
err := row.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.Privacy, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content, &ownerName)
|
||||
err := row.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content, &ownerName)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
return nil, ErrPostNotFound
|
||||
@@ -882,7 +882,7 @@ func (db *datastore) GetPost(id string, collectionID int64) (*PublicPost, error)
|
||||
where = "id = ?"
|
||||
}
|
||||
row = db.QueryRow("SELECT "+postCols+", (SELECT username FROM users WHERE users.id = posts.owner_id) AS username FROM posts WHERE "+where+" LIMIT 1", params...)
|
||||
err := row.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.Privacy, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content, &ownerName)
|
||||
err := row.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content, &ownerName)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
if collectionID > 0 {
|
||||
@@ -914,7 +914,7 @@ func (db *datastore) GetOwnedPost(id string, ownerID int64) (*PublicPost, error)
|
||||
where := "id = ? AND owner_id = ?"
|
||||
params := []interface{}{id, ownerID}
|
||||
row = db.QueryRow("SELECT "+postCols+" FROM posts WHERE "+where+" LIMIT 1", params...)
|
||||
err := row.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.Privacy, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content)
|
||||
err := row.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
return nil, ErrPostNotFound
|
||||
@@ -1019,7 +1019,7 @@ func (db *datastore) GetPosts(c *Collection, page int, includeFuture bool) (*[]P
|
||||
posts := []PublicPost{}
|
||||
for rows.Next() {
|
||||
p := &Post{}
|
||||
err = rows.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.Privacy, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content)
|
||||
err = rows.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content)
|
||||
if err != nil {
|
||||
log.Error("Failed scanning row: %v", err)
|
||||
break
|
||||
@@ -1076,7 +1076,7 @@ func (db *datastore) GetPostsTagged(c *Collection, tag string, page int, include
|
||||
posts := []PublicPost{}
|
||||
for rows.Next() {
|
||||
p := &Post{}
|
||||
err = rows.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.Privacy, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content)
|
||||
err = rows.Scan(&p.ID, &p.Slug, &p.Font, &p.Language, &p.RTL, &p.OwnerID, &p.CollectionID, &p.PinnedPosition, &p.Created, &p.Updated, &p.ViewCount, &p.Title, &p.Content)
|
||||
if err != nil {
|
||||
log.Error("Failed scanning row: %v", err)
|
||||
break
|
||||
|
Reference in New Issue
Block a user