Skip to content

Conversation

@ili-ad
Copy link

@ili-ad ili-ad commented Jan 6, 2026

Summary

Fix Customer autoname on Postgres by removing MariaDB-only CAST(... AS UNSIGNED).

Problem

Creating a Customer (including via Sales Invoice customer field) can fail on Postgres with:


psycopg2.errors.UndefinedObject: type "unsigned" does not exist

Root cause: Customer.get_customer_name() uses CAST(... AS UNSIGNED) to compute the next suffix when a duplicate name exists.

Fix

  • On Postgres, extract the trailing digits from names like Customer - 3 using:
    SUBSTRING(name FROM '\d+$') and cast to INTEGER.
  • Keep existing MariaDB/MySQL behavior unchanged.

Tests

  • pre-commit run --all-files
  • Manual: Creating duplicate customer names works on Postgres (e.g. Test, then Test - 1, Test - 2).

Notes

Server-side logic only; no UI changes.

@ili-ad ili-ad requested a review from ruthra-kumar as a code owner January 6, 2026 20:14
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Warning

Rate limit exceeded

@ili-ad has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 57624e1 and 323636b.

📒 Files selected for processing (1)
  • erpnext/selling/doctype/customer/customer.py

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 and usage tips.

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Jan 6, 2026
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.09%. Comparing base (3acc3e6) to head (323636b).
⚠️ Report is 178 commits behind head on develop.

Files with missing lines Patch % Lines
erpnext/selling/doctype/customer/customer.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #51558      +/-   ##
===========================================
- Coverage    79.09%   79.09%   -0.01%     
===========================================
  Files         1179     1179              
  Lines       121452   121455       +3     
===========================================
+ Hits         96063    96065       +2     
- Misses       25389    25390       +1     
Files with missing lines Coverage Δ
erpnext/selling/doctype/customer/customer.py 74.64% <75.00%> (-0.07%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ruthra-kumar ruthra-kumar self-assigned this Jan 8, 2026
@ruthra-kumar ruthra-kumar added the postgres issue/pr related to postgres label Jan 16, 2026
@ruthra-kumar
Copy link
Member

@ili-ad

Can't reproduce the same error - psycopg2.errors.UndefinedObject: type "unsigned" does not exist. Any other way to trigger?

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

Labels

needs-tests This PR needs automated unit-tests. postgres issue/pr related to postgres

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants