Skip to content

RDBC-1021/1024/1025 Fix no-tracking includes guard, session refresh in-place, and lazy load None#271

Open
redknightlois wants to merge 3 commits intoravendb:v7.2from
redknightlois:RDBC-1021
Open

RDBC-1021/1024/1025 Fix no-tracking includes guard, session refresh in-place, and lazy load None#271
redknightlois wants to merge 3 commits intoravendb:v7.2from
redknightlois:RDBC-1021

Conversation

@redknightlois
Copy link
Member

Issue link

https://issues.hibernatingrhinos.com/issue/RDBC-1021
https://issues.hibernatingrhinos.com/issue/RDBC-1024
https://issues.hibernatingrhinos.com/issue/RDBC-1025

Additional description

RDBC-1021session.query(...).include(...) and session.advanced.document_query(...).include(...) now raise ValueError immediately when session.no_tracking is True, matching C# behaviour. Previously the call succeeded silently and the included documents were never cached.

RDBC-1024session.advanced.refresh(entity) was creating a new object and replacing the DocumentInfo entry, leaving the caller's original reference stale. Fixed by updating entity.__dict__ in-place so the caller's reference immediately reflects the refreshed server state.

RDBC-1025session.advanced.lazily.load(None) returned None instead of Lazy(None). Fixed by returning Lazy(lambda: None) for a None id, consistent with how the C# client handles it.

Type of change

  • Bug fix
  • Regression bug fix
  • Optimization
  • New feature

How risky is the change?

  • Low
  • Moderate
  • High
  • Not relevant

Backward compatibility

  • Non breaking change
  • Ensured. Please explain how has it been implemented?
  • Breaking change
  • Not relevant

Is it platform specific issue?

  • Yes. Please list the affected platforms.
  • No

Documentation update

  • This change requires a documentation update. Please mark the issue on YouTrack using Documentation Required tag.
  • No documentation update is needed

Testing by Contributor

  • Tests have been added that prove the fix is effective or that the feature works
  • Internal classes added to the test class (e.g. entity or index definition classes) have the lowest possible access modifier (preferable private)
  • It has been verified by manual testing
  • Existing tests verify the correct behavior

Testing by RavenDB QA team

  • This change requires a special QA testing due to possible performance or resources usage implications (CPU, memory, IO). Please mark the issue on YouTrack using QA Required tag.
  • No special testing by RavenDB QA team is needed

Is there any existing behavior change of other features due to this change?

  • Yes. Please list the affected features/subsystems and provide appropriate explanation
  • No

UI work

  • It requires further work in the Studio. Please mark the issue on YouTrack using Studio Required tag.
  • No UI work is needed

@redknightlois redknightlois changed the title RDBC-1021 | RDBC-1024 | RDBC-1025 RDBC-1021 Fix no-tracking includes guard, session refresh in-place, and lazy load None Feb 26, 2026
@redknightlois redknightlois changed the title RDBC-1021 Fix no-tracking includes guard, session refresh in-place, and lazy load None RDBC-1021/1024/1025 Fix no-tracking includes guard, session refresh in-place, and lazy load None Feb 26, 2026
@redknightlois redknightlois force-pushed the RDBC-1021 branch 3 times, most recently from ce7a76a to 2660ad4 Compare February 27, 2026 12:09
…a no_tracking session

session.load(..., includes=...) and query._include() silently discarded includes
when no_tracking=True, giving callers a false sense of correctness.
C# raises InvalidOperationException with "Cannot register includes when NoTracking
is enabled." Added the same guard to both the load() path and the query _include()
method, using the full C# exception message.

Regression test: test_no_tracking_includes_guard.py verifies that include calls raise
InvalidOperationException on no-tracking sessions for load, query, and document_query paths.
…-place

_refresh_internal() was converting a fresh entity and deep-copying it, leaving the caller's original reference stale. Fix: update entity.__dict__ from the freshly converted object so the caller sees the new server state without needing to use the return value.

Regression test: test_session_refresh.py verifies that the original entity reference reflects the updated server state after refresh() is called, that the return value is tracked, and that the change vector is updated.
`if not ids: return None` returned the bare None value for a None id, so lazy.value raised AttributeError. Now returns Lazy(lambda: None), so lazy.value is None as C# specifies.

Regression test: test_lazy_load_null.py verifies that lazily.load(None) resolves to None without raising AttributeError.
@redknightlois redknightlois changed the base branch from v7.1 to v7.2 March 6, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant