Skip to content

PostgreSQL: Blog module throws ERROR 42803 (column must appear in GROUP BY) on edit #282

Description

@HAMSTER1618

Describe the bug
When trying to edit an existing Blog post using the PostgreSQL data provider (tested on PostgreSQL 18), the application crashes with a database error regarding a missing column in the GROUP BY clause.

To Reproduce

  1. Set up mojoPortal with PostgreSQL.
  2. Add a Blog module to a page.
  3. Create a new blog post (this works fine).
  4. Click "Edit" on the created post.
  5. The application throws a YSOD.

Error Details / Stack Trace
Npgsql.NpgsqlException: ERROR: 42803: column "b.itemid" must appear in the GROUP BY clause or be used in an aggregate function

at mojoPortal.Data.DBBlog.GetSingleBlog(Int32 itemId, DateTime currentTime)
at mojoPortal.Business.Blog..ctor(Int32 itemId)
at mojoPortal.Web.BlogUI.BlogEdit.LoadSettings()

Proposed Solution
Modern versions of PostgreSQL strictly enforce GROUP BY rules. The SQL query inside mojoPortal.Data.pgsql for DBBlog.GetSingleBlog selects b.itemid (and possibly other columns) but fails to include them in the GROUP BY clause. Adding the missing columns to the GROUP BY statement in the Npgsql data provider will resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions