Fix issue #135: Implement lazy query initialization#136
Merged
tamurashingo merged 1 commit intodevelopfrom Jan 26, 2026
Merged
Conversation
- Add *table-information-initialized* flag to track initialization state - Add *query-initialization-callbacks* list to store delayed query initializations - Create <query-placeholder> class for queries created before initialization - Modify query macro to create placeholders when table info not initialized - Update initialize-table-information to execute callbacks after initialization - Convert set-* functions to generic functions with placeholder delegation - Add comprehensive tests for lazy initialization behavior This allows defining query instances with defparameter before calling initialize-table-information, fixing the error that occurred when queries were defined during application load time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An error occurred when using the
querymacro before executinginitialize-table-information.This prevented pre-defining queries for performance optimization like this:
Solution
Implemented lazy initialization using the placeholder pattern:
Introduction of
<query-placeholder>classquerymacro is called before initialization, returns a placeholder instance<query>instanceInitialization state management
*table-information-initialized*: Flag indicating whether initialization is complete*query-initialization-callbacks*: List of callbacks to execute lazilyTransparent delegation
execute-query,generate-query,set-*to the actual<query>Changes
Added
src/environment.lisp: Added variables for initialization state managementsrc/model/query.lisp: Added<query-placeholder>class and delegation methodstest/model/query-lazy-initialization.lisp: Added tests for lazy initializationModified
src/model/query.lisp: Modifiedquerymacro to behave based on initialization statesrc/model/query.lisp: Convertedset-*functions to generic functionssrc/model/base-model.lisp: Modifiedinitialize-table-informationto execute callbacksUsage Example
Tests
Added 5 new tests (27 assertions):
All 63 existing tests also pass successfully.
Breaking Changes
None. Existing code works without changes.
Related Issue
Closes #135