Skip to content

fix: PostgreSQL compatibility — explicit numeric comparisons - #5009

Open
skanderphilipp wants to merge 1 commit into
frappe:developfrom
skanderphilipp:develop
Open

fix: PostgreSQL compatibility — explicit numeric comparisons#5009
skanderphilipp wants to merge 1 commit into
frappe:developfrom
skanderphilipp:develop

Conversation

@skanderphilipp

Copy link
Copy Markdown

Fix PostgreSQL error during Frappe v17 (develop) setup with PostgreSQL backend:

update_employee_advance_status.py — bare numeric fields in WHERE

The post-install patch used bare return_amount and claimed_amount (Currency fields, stored as numeric) in boolean context:

.where((advance.return_amount) & (advance.paid_amount == advance.return_amount))

PostgreSQL rejects numeric types in boolean context with:

argument of AND must be type boolean, not type numeric

Fix: Changed bare numeric references to explicit > 0 comparisons:

.where((advance.return_amount > 0) & (advance.paid_amount == advance.return_amount))

Semantically equivalent — both return_amount and claimed_amount are non-negative currency values. Backwards-compatible with MariaDB.

PostgreSQL requires explicit comparison operators in WHERE clauses
for numeric fields. The bare references to return_amount and
claimed_amount (Currency fields stored as numeric) were interpreted
as boolean expressions, which PostgreSQL rejects with:

  argument of AND must be type boolean, not type numeric

Changed to explicit > 0 comparisons, which are semantically
equivalent and backwards-compatible with MariaDB.
@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

Explicit positive comparisons preserve the established non-negative amount semantics while producing valid boolean predicates on PostgreSQL.

Reviews (1): Last reviewed commit: "fix: PostgreSQL compatibility — explicit..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant