Skip to content

refactor(query_builder): implement proper lazy initialization#308

Merged
kcenon merged 2 commits into
mainfrom
refactor/query-builder-lazy-init-306
Dec 31, 2025
Merged

refactor(query_builder): implement proper lazy initialization#308
kcenon merged 2 commits into
mainfrom
refactor/query-builder-lazy-init-306

Conversation

@kcenon

@kcenon kcenon commented Dec 31, 2025

Copy link
Copy Markdown
Owner

Summary

  • Implemented proper lazy initialization in query_builder::ensure_builder()
  • Released unused builders when switching database types via for_database()
  • Reduced memory footprint by keeping only one builder instance at a time

Changes

  • Modified ensure_builder() to release unused builders when database type changes
  • When SQL type (postgres/mysql/sqlite): releases mongo and redis builders
  • When MongoDB type: releases sql and redis builders
  • When Redis type: releases sql and mongo builders
  • When no type set: releases all builders

Test plan

  • All QueryBuilder tests pass (144 tests)
  • All other tests pass (except pre-existing SQLInjectionTest failure)
  • No API changes, fully backward compatible

Fixes #306

- Release unused builders when switching database types via for_database()
- Only allocate the required builder based on database type
- Previously, multiple builders could accumulate in memory
- Memory footprint reduced by keeping only one builder instance at a time
- No API changes, fully backward compatible

Fixes #306
- Add Issue #306 entry to both English and Korean CHANGELOG
- Document lazy initialization improvement in ensure_builder()
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results

No comparison reports available. Baseline may not be established yet.

@kcenon kcenon merged commit 5aeb4e7 into main Dec 31, 2025
26 checks passed
@kcenon kcenon deleted the refactor/query-builder-lazy-init-306 branch December 31, 2025 08:50
kcenon added a commit that referenced this pull request Apr 13, 2026
* refactor(query_builder): implement proper lazy initialization

- Release unused builders when switching database types via for_database()
- Only allocate the required builder based on database type
- Previously, multiple builders could accumulate in memory
- Memory footprint reduced by keeping only one builder instance at a time
- No API changes, fully backward compatible

Fixes #306

* docs: update CHANGELOG for query_builder memory optimization

- Add Issue #306 entry to both English and Korean CHANGELOG
- Document lazy initialization improvement in ensure_builder()
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.

[REFACTOR] Fix query_builder over-allocation - Simple Design compliance

1 participant