Skip to content

feat(postgres): add math enhanced functions with proper naming - #25

Merged
vistart merged 2 commits into
release/v1.0.0.dev10from
feature/postgres-math-enhanced-functions
Apr 9, 2026
Merged

vistart merged 2 commits into
release/v1.0.0.dev10from
feature/postgres-math-enhanced-functions

Conversation

@vistart

@vistart vistart commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds enhanced mathematical functions to the PostgreSQL backend with proper naming to avoid conflicts with Python builtins.

Functions Added

Function PostgreSQL Notes
round_ ROUND() Round is Python builtin
pow, power POWER() Power function and its alias
sqrt SQRT() Square root
mod MOD() Modulo
ceil CEIL() Ceiling
floor FLOOR() Floor
trunc TRUNC() Truncate
max_, min_ GREATEST/LEAST Scalar operations
max_, min_ MAX/MIN Aggregate operations
avg AVG() Average aggregate

Problem Solved

This feature provides properly named mathematical functions that:

  • Avoid conflicts with Python builtins (e.g., round vs round_)
  • Provide consistent naming across scalar and aggregate functions
  • Add missing PostgreSQL-specific mathematical functions

Type of change

  • feat: A new feature
  • docs: Documentation only changes (if related to the new feature)
  • perf: A code change that improves performance (if part of the feature)
  • test: Adding missing tests or correcting existing tests (for the new feature)
  • chore: Changes to the build process or auxiliary tools and libraries suchs as documentation generation (if related to the new feature)
  • ci: Changes to our CI configuration files and scripts (if related to the new feature)
  • build: Changes that affect the build system or external dependencies (if related to the new feature)
  • revert: Reverts a previous commit

Breaking Change

  • Yes
  • No

(If Yes, please describe the impact and migration path below):

Applicable rhosocial-activerecord Version Range:
>=1.0.0,<2.0.0

Related Repositories/Packages

N/A

Testing

  • I have added new tests to cover my changes.
  • I have updated existing tests to reflect my changes.
  • All existing tests pass.
  • This change has been tested on PostgreSQL.

Test Plan:
Test file: tests/rhosocial/activerecord_test/backend/postgres/test_postgres_math_enhanced_functions.py

Checklist

  • My code follows the project's code style guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation (Docstrings, README.md, etc.).
  • My changes generate no new warnings.
  • I have added a Changelog fragment (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

Files Changed:

  • src/rhosocial/activerecord/backend/impl/postgres/functions/__init__.py - Export additions
  • src/rhosocial/activerecord/backend/impl/postgres/functions/math_enhanced.py - New functions (381 lines)
  • tests/rhosocial/activerecord_test/backend/postgres/test_postgres_math_enhanced_functions.py - Tests (258 lines)

Total: 3 files changed, 667 insertions(+)

- round_ (round is Python builtin)
- pow, power (POWER alias)
- sqrt, mod, ceil, floor, trunc
- max_, min_ (GREATEST/LEAST for scalar, MAX/MIN for aggregate)
- avg (AVG aggregate)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vistart vistart self-assigned this Apr 9, 2026
@vistart vistart added the feature label Apr 9, 2026
@codecov

codecov Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.49123% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.93%. Comparing base (329a5c5) to head (9607f63).
⚠️ Report is 1 commits behind head on release/v1.0.0.dev10.

Files with missing lines Patch % Lines
...d/backend/impl/postgres/functions/math_enhanced.py 96.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev10      #25      +/-   ##
========================================================
+ Coverage                 72.73%   72.93%   +0.19%     
========================================================
  Files                       121      122       +1     
  Lines                      6867     6924      +57     
  Branches                   1139     1144       +5     
========================================================
+ Hits                       4995     5050      +55     
- Misses                     1470     1471       +1     
- Partials                    402      403       +1     
Flag Coverage Δ
postgres-18 72.93% <96.49%> (+0.19%) ⬆️
python-3.14 72.93% <96.49%> (+0.19%) ⬆️
unittests 72.93% <96.49%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Apr 9, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 644956a into release/v1.0.0.dev10 Apr 9, 2026
14 checks passed
@vistart vistart mentioned this pull request Apr 12, 2026
4 of 12 tasks
vistart added a commit that referenced this pull request Apr 12, 2026
* feat(postgres): add math enhanced functions with proper naming

- round_ (round is Python builtin)
- pow, power (POWER alias)
- sqrt, mod, ceil, floor, trunc
- max_, min_ (GREATEST/LEAST for scalar, MAX/MIN for aggregate)
- avg (AVG aggregate)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: add changelog fragment for PR #25

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vistart
vistart deleted the feature/postgres-math-enhanced-functions branch May 30, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant