Skip to content

Conversation

Copy link

Copilot AI commented Nov 6, 2025

Implementation Plan for name_search Support

  • Understand the codebase and existing implementation
  • Implement the name_search method in orm_mongodb.py
  • Add tests for the name_search method
  • Address code review feedback
  • Update name_get to match orm implementation
  • Run security checks

Summary

Successfully implemented support for name_search in the MongoDB backend for OpenERP and updated name_get to match the orm implementation.

Changes Made

Updated name_get Implementation (orm_mongodb.py)

  • Added proper handling for empty ids (returns [])
  • Added handling for single integer ids by converting to list
  • Uses tools.ustr() for proper unicode string handling
  • Passes load='_classic_write' to read() method
  • Matches the implementation pattern from orm class (isolation decorator will be added in a separate PR)

name_search Implementation (orm_mongodb.py)

  • Accepts standard OpenERP parameters: cr, user, name, args, operator, context, limit
  • Builds search domain combining name filter with additional args
  • Uses _rec_name field for searching
  • Returns results in name_get format
  • Supports all standard operators

Updated Tests (tests/__init__.py)

  • Enhanced test_name_get to test single id handling
  • Added test for empty ids list
  • Added proper cleanup of _rec_name changes
  • All existing name_search tests remain comprehensive

Files Changed

  • orm_mongodb.py: Updated name_get method and added name_search method
  • tests/__init__.py: Enhanced tests

Security

✅ CodeQL security scan passed with 0 alerts

Original prompt

This section details on the original issue you should resolve

<issue_title>Add suport for name_search</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 6, 2025 06:02
Co-authored-by: ecarreras <294235+ecarreras@users.noreply.github.com>
Co-authored-by: ecarreras <294235+ecarreras@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for name search functionality Add support for name_search method Nov 6, 2025
Copilot AI requested a review from ecarreras November 6, 2025 06:09
Copilot finished work on behalf of ecarreras November 6, 2025 06:09
@ecarreras ecarreras marked this pull request as ready for review November 6, 2025 08:56
@ecarreras ecarreras requested a review from polsala November 6, 2025 08:56
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python Mongo 3 3.11 Tests for mongodb_backend

  2 files    2 suites   0s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python Mongo 8 3.11 Tests for mongodb_backend

  2 files    2 suites   0s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python Mongo 5 3.11 Tests for mongodb_backend

  2 files    2 suites   0s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python Mongo 5 2.7 Tests for mongodb_backend

  2 files    2 suites   0s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python Mongo 8 2.7 Tests for mongodb_backend

  2 files    2 suites   0s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python FerretDB 3.11 Tests for mongodb_backend

  2 files    2 suites   1s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python FerretDB 2.7 Tests for mongodb_backend

  2 files    2 suites   1s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Python Mongo 3 2.7 Tests for mongodb_backend

  2 files    2 suites   0s ⏱️
102 tests 100 ✅ 2 💤 0 ❌
103 runs  101 ✅ 2 💤 0 ❌

Results for commit 0399127.

♻️ This comment has been updated with latest results.

@ecarreras
Copy link
Member

@copilot you should implement name_get as it is implemented in orm not in orm_template similar:

    @isolation(readonly=True, isolation_level='repeatable_read')
    def name_get(self, cr, user, ids, context=None):
        if not context:
            context = {}
        if not ids:
            return []
        if isinstance(ids, integer_types):
            ids = [ids]
        return [(r['id'], tools.ustr(r[self._rec_name])) for r in self.read(cr, user, ids,
            [self._rec_name], context, load='_classic_write')]
``

…and proper handling

Co-authored-by: ecarreras <294235+ecarreras@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 6, 2025

@copilot you should implement name_get as it is implemented in orm not in orm_template similar:

...

Updated name_get to match the orm implementation. Changes in commit 6f03ac3:

  • Added @isolation(readonly=True, isolation_level='repeatable_read') decorator
  • Added proper handling for empty ids (returns [])
  • Added handling for single integer ids (converts to list)
  • Uses tools.ustr() for unicode string handling
  • Passes load='_classic_write' to read() method

Also enhanced tests to cover the new edge cases (single id, empty ids).

Copilot finished work on behalf of ecarreras November 6, 2025 09:09
orm_mongodb.py Outdated
# nothing to check in schema free...
pass

@isolation(readonly=True, isolation_level='repeatable_read')
Copy link
Member

Choose a reason for hiding this comment

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

@copilot remove the decorator we will made a dedicated pull-request later to change all the necessary methods

Copy link
Author

Choose a reason for hiding this comment

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

Removed the @isolation decorator from name_get in commit 0399127.

Co-authored-by: ecarreras <294235+ecarreras@users.noreply.github.com>
Copilot AI requested a review from ecarreras November 6, 2025 09:19
Copilot finished work on behalf of ecarreras November 6, 2025 09:19
@ecarreras ecarreras marked this pull request as draft November 6, 2025 09:20
@ecarreras ecarreras marked this pull request as ready for review November 6, 2025 13:04
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.

Add suport for name_search

2 participants