Skip to content

fix: Ensure cross-database compatibility for unread message count query - #216

Merged
Fishbowler merged 1 commit into
igniterealtime:mainfrom
dessanhemrayev:fix_unread_messages
Sep 25, 2026
Merged

Fishbowler merged 1 commit into
igniterealtime:mainfrom
dessanhemrayev:fix_unread_messages

Conversation

@dessanhemrayev

@dessanhemrayev dessanhemrayev commented Oct 10, 2025 •

Copy link
Copy Markdown

In the "ofpresence" table, the "offlineDate" field has the data type "VARCHAR/CHAR" depending on the database, and in the query we are trying to compare this field with the "sentDate" field, which has the data type "BIGINT/INTEGER". This results in the following error:

ERROR: operator does not exist: bigint > character varying
LINE 3: JOIN ofPresence p ON (a.sentDate > p.offlineDate)
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

This change replaces implicit comparison with explicit, database-specific CAST expressions. The correct CAST is selected at runtime based on the underlying database (MySQL, PostgreSQL, SQL Server, Oracle, Sybase), ensuring reliable and portable behavior across all Openfire-supported DBs.

fixes #265

@dessanhemrayev

dessanhemrayev commented Oct 10, 2025 •

Copy link
Copy Markdown
Author

Hi @Fishbowler , @guusdk
I create new PR
PR #215 closed

Comment thread changelog.html Outdated
@dessanhemrayev

Copy link
Copy Markdown
Author

Hi @guusdk
Please check.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Cross-database SQL behavior warrants final human validation.

Review effort: Lite
Findings: None

What changed in this PR

Updates unread-message counting with database-specific casts for cross-database compatibility.

Changes:

  • Adds runtime database-aware SQL casting.
  • Uses the generated query for unread counts.
  • Updates plugin metadata and changelog.
File Description
src/​java/​org/​jivesoftware/​openfire/​plugin/​rest/​controller/​MsgArchiveController.java Adds database-specific casting to the unread-count query.
plugin.xml Updates the plugin date.
changelog.html Documents the compatibility fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…ead message count query

In the "ofpresence" table, the "offlineDate" field has the data type "VARCHAR/CHAR" depending on the
database, and in the query we are trying to compare this field with the "sentDate" field, which has
the data type "BIGINT/INTEGER". This results in the following error:

```
ERROR: operator does not exist: bigint > character varying
LINE 3: JOIN ofPresence p ON (a.sentDate > p.offlineDate)
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
```

This change replaces implicit comparison with explicit, database-specific CAST expressions.
The correct CAST is selected at runtime based on the underlying database (MySQL, PostgreSQL,
SQL Server, Oracle, Sybase), ensuring reliable and portable behavior across all Openfire-supported DBs.
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1c64cbc8-c98d-4555-bb1e-05af7cc2bc0e

📥 Commits

Reviewing files that changed from the base of the PR and between 6f119ef and 88a3b32.

📒 Files selected for processing (2)
  • changelog.html
  • src/java/org/jivesoftware/openfire/plugin/rest/controller/MsgArchiveController.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Fishbowler
Fishbowler merged commit 35a943d into igniterealtime:main Sep 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unread message count fails on some databases because it compares a number with a string

3 participants