Skip to content

fix: PostgreSQL Builder's increment() and decrement() methods not working for numeric columns#10172

Open
patel-vansh wants to merge 3 commits intocodeigniter4:developfrom
patel-vansh:fix/postgre-increment-decrement-bug
Open

fix: PostgreSQL Builder's increment() and decrement() methods not working for numeric columns#10172
patel-vansh wants to merge 3 commits intocodeigniter4:developfrom
patel-vansh:fix/postgre-increment-decrement-bug

Conversation

@patel-vansh
Copy link
Copy Markdown
Contributor

Description
As discovered in #10140 in this comment, the PostgreSQL Builder's increment() and decrement() methods were giving errors while incrementing/decrementing numeric columns.

This PR fixes that by changing "to_number({$column}, '9999999') + {$value}" to "CAST({$column} AS numeric) + {$value}", so that both string as well as numeric columns work as expected.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@neznaika0
Copy link
Copy Markdown
Contributor

Isn't the current test tests/system/Database/Live/IncrementTest.php running for postgresql?
https://github.com/codeigniter4/CodeIgniter4/actions/runs/25487825930/job/74789224632?pr=10172
why do we need a duplicate test?

@patel-vansh
Copy link
Copy Markdown
Contributor Author

Isn't the current test tests/system/Database/Live/IncrementTest.php running for postgresql? https://github.com/codeigniter4/CodeIgniter4/actions/runs/25487825930/job/74789224632?pr=10172 why do we need a duplicate test?

Well, yes, I deliberately added that new file because I thought that testing increment for numeric columns was explicit to PostgreSQL, but you're right, I will add that to the normal file only so that other DB builders also get tested with numeric columns.

@paulbalandan paulbalandan added the bug Verified issues on the current code behavior or pull requests that will fix them label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants