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
- Set up mojoPortal with PostgreSQL.
- Add a Blog module to a page.
- Create a new blog post (this works fine).
- Click "Edit" on the created post.
- 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.
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 BYclause.To Reproduce
Error Details / Stack Trace
Npgsql.NpgsqlException: ERROR: 42803: column "b.itemid" must appear in the GROUP BY clause or be used in an aggregate functionProposed 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.