Skip to content

release/0.0.4#150

Merged
tamurashingo merged 60 commits into
mainfrom
release/0.0.4
May 13, 2026
Merged

release/0.0.4#150
tamurashingo merged 60 commits into
mainfrom
release/0.0.4

Conversation

@tamurashingo

Copy link
Copy Markdown
Owner

No description provided.

- Add support for :scanner, :keys, and :generate-scanner properties
- Implement priority-based scanner generation in initialize-routing-tables
- Add comprehensive test coverage for custom routing patterns
- Update *routing-tables* docstring with detailed property documentation
- Update environment.md and environment_ja.md with usage examples

This enhancement enables:
- Catch-all routes for SPA applications
- Static file serving with parameter extraction
- Type constraints (e.g., numeric-only IDs)
- Custom scanner generator functions

Fixes #116
…uting-patterns

Support custom regular expression patterns in routing tables
The default implementations of do-get, do-post, do-put, and do-delete
were incorrectly using (getf controller :request) to access request data.
Changed to use the proper accessor function (request controller) instead.

This fixes runtime errors that would occur when these default methods
are called without being overridden.
…-retrieval

Fix incorrect request retrieval method in base-controller
- Import request-path-info from lack/request package
- Replace getf calls with request-path-info accessor in do-get, do-post, do-put, do-delete methods
- Fixes TypeError when accessing path-info from request slot

The request slot contains a Lack Request struct, not a plist, so we need
to use the proper accessor function instead of getf.
…-path-info

Fix: Use request-path-info accessor for Lack Request struct
- Add initialize-instance :after method for <rest-controller>
- Set Content-Type: application/json as default header
- Follows REST API best practices and maintains consistency with <web-controller>
…son-header

Add default application/json header to <rest-controller>
Fix: Handle type mismatch for MySQL TEXT columns
- Implement query-builder function to create <query> instances at runtime
- Add setter functions: set-columns, set-joins, set-where, set-order-by, set-limit, set-offset
- All setters replace existing values and return the query instance for method chaining
- Export generate-query method for SQL inspection
- Add comprehensive unit tests with actual query execution and result verification

This allows dynamic query construction based on runtime conditions while still
returning model instances, bridging the gap between static query macro and
dynamic NATIVE queries.

Note: WHERE clause parameters currently require DB-native values (e.g., 1/0 for boolean)
instead of Lisp values (T/NIL) due to missing cl-db-fn conversion. This is tracked
in issue-where-value.md.
- Add comprehensive guide for dynamic query construction
- Include examples for dynamic column selection, WHERE clause, and ORDER BY
- Explain setter functions and method chaining
- Document SQL inspection using generate-query
- Clarify when to use query macro vs query-builder
- Add to-string, to-text, to-integer, to-float, to-decimal, to-datetime, to-date, to-time, to-boolean functions
- Create clails/model/util package with get-cl-db-fn-by-type helper
- Implement database-specific conversion methods for MySQL, PostgreSQL, and SQLite3
- Export conversion functions from clails/model package

Related to issue #128
- Extend parse-where-claude to return column specs as 3rd value
- Extend parse-exp2, parse-between-clause, parse-in-clause, parse-null2 to return column specs
- Add get-column-type-from-model and convert-value-by-type functions
- Implement automatic type conversion in generate-query based on column types

Related to issue #128
- Add :convert-types keyword parameter to execute-query (default: t)
- Add :convert-types keyword parameter to generate-query
- Type conversion is performed only when convert-types is true
- Maintains backward compatibility with default behavior

Related to issue #128
- Fix LIMIT/OFFSET parameters to not be converted
- Pad column-specs list to match params length
- Add where-clause-type-conversion-test
- Fix existing between test to use :convert-types nil

All tests now pass.

Related to issue #128
- Create new migration 0012-type-conversion-test with test table
- Add type conversion tests for MySQL, PostgreSQL, and SQLite3
- Test boolean, integer, datetime type conversions
- Test multiple conditions with type conversion
- Test :convert-types option (enable/disable conversion)
- Fix BETWEEN test range to expect correct results
- Add CLAILS_MIGRATION_DIR_0012 to CI workflow

All 61 tests pass successfully.

Related to issue #128
…-conversion

Add Automatic Type Conversion for WHERE Clause Parameters
- Add query-cache and query-cache-valid-p slots to <query> class
- Implement get-or-parse-query function to cache parsing results
- Cache SQL template, WHERE params/columns, column types, LIMIT/OFFSET params
- Invalidate cache when query definition is modified via setter functions
- Add comprehensive unit and integration tests for cache functionality
- Update clails-test.asd to include new test file
…arison

- Clear existing todo data before inserting test data to avoid conflicts
- Change boolean comparisons from (= value 1/0) to (eq value T/NIL)
- Make assertions more explicit with T and NIL constants
Add Query Cache Feature to Improve Performance
…ntation

- Add detailed explanation of automatic type conversion in execute-query
- Document supported operators and types for conversion
- Include examples for Boolean, Datetime, IN, and BETWEEN clauses
- Explain :convert-types option to disable conversion
- Add notes on backward compatibility and type information retrieval
- Update both English (model.md) and Japanese (model_ja.md) versions

Related to issue #128
- Add comprehensive explanation of query caching mechanism
- Document automatic caching and cache invalidation
- Explain cached components (SELECT, JOIN, WHERE, ORDER BY, LIMIT/OFFSET)
- Include examples for pagination, batch processing, and complex queries
- Document handling of dynamic IN clauses
- Add best practices for query reuse
- Update both English (model.md) and Japanese (model_ja.md) versions
- Add query cache to summary features list

Related to issue #130
Fix: Apply kebab->snake conversion to table names in add-column operation
- 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.
…lization

Fix issue #135: Implement lazy query initialization
- Change all defparameter to defvar to prevent variable reinitialization
- This fixes the issue where database configuration is reset when <app> is reloaded during test execution
- defvar preserves the value on re-evaluation, which is appropriate for application configuration variables
- Change *enable-transaction-middleware* to defvar (can be toggled by application)
- Change *clails-middleware-stack* to defvar (can be modified by add-middleware-* functions)
- Keep *lack-middleware-transaction* and *lack-middleware-clails-controller* as defparameter (not expected to change)
…issue

Fix: Change defparameter to defvar to prevent configuration reset on reload
Add table_schema condition to information_schema.columns queries to prevent
fetching duplicate columns from multiple databases/schemas.

- MySQL: Add 'table_schema = database()' condition
- PostgreSQL: Add 'table_schema = current_schema()' condition

This ensures only columns from the currently connected database/schema are retrieved.

Fixes issue where columns were duplicated when multiple databases (e.g., dev and test)
exist on the same database instance.
…itialize-table-information

Fix duplicate columns in initialize-table-information
- Added run-tests-with-setup-teardown helper function to properly execute
  suite-level setup and teardown hooks
- Modified 3 locations in run-suite-tests to use the new helper function:
  - When packages are specified
  - When tags are specified
  - When running all tests
- Added find-suite to rove imports

Error handling:
- If setup fails: skip tests for that package, execute teardown, return nil
- If teardown fails: display error message, return test result

Test verification:
- Added setup/teardown to test/e2e/templates/todo-model-test.lisp
- Confirmed that setup and teardown are executed correctly
…uted

Fix: Execute setup and teardown in clails test
Fix incorrect argument order for log-level-enabled-p in src/model
Previously, JOIN clauses were not converting table names from kebab-case
to snake_case, causing SQL errors when JOINs were used.
Fix JOIN clause to apply kebab->snake conversion to table names
- Add query-source-info slot to <query> and <query-placeholder> classes
- Save original query definition in query macro
- Add format-query-source-info function to format error messages
- Update error messages in build-alias-map and generate-join-sql to include query definition
- Pass query instance to generate-join-sql for error message context

This makes it easier to debug relation errors by showing the original
query definition in the error message.
- Add test case to reproduce parameter order bug
- Single table query test: parameters with :in are placed first incorrectly
- JOIN query test: parameters with :in are placed first incorrectly
- Expected: parameters in WHERE clause order
- Actual: :in values first, then other parameters
- Add migration for test tables (todo, tag, todo_tags)
- Add test to clails-test.asd
- Add CLAILS_MIGRATION_DIR_0013 to CI configuration
Fixed the issue where parameters in WHERE clause with :in operator
were ordered incorrectly. Previously, :in values were added first,
followed by regular parameters, which was opposite to their
appearance order in the WHERE clause.

Changes:
- Modified generate-query method in src/model/query.lisp
- Collect all parameter specs (both :in-expansion and regular) in order
- Process parameters sequentially to maintain WHERE clause order
- Add test case for multiple IN clauses with mixed parameters

Test results:
- Single table query: parameters in correct order
- JOIN query: parameters in correct order
- Multiple IN clauses: parameters in correct order
Fix parameter order bug in WHERE clause with :in operator
…ror-message

Improve Relation Definition Error Messages
- Add passed-package-tests variable to track successful packages
- Separate test results into 'Passed Packages' and 'Failed Packages' sections
- Display package count for each section
- Make it clear which tests were executed even when all tests pass
cl-batis library has been updated and now generates SQL without extra spaces.
Previous: 'where id =   ?'
Current: 'where id = ?'

Updated all test assertions in native-query.lisp to match the new format.
Improve test summary to show both passed and failed packages
Enable routing by action name and HTTP method, allowing a single
controller to handle multiple actions (index, show, new, etc.)
instead of requiring separate controllers per path. Routes without
:action/:method continue to use do-get/do-post dispatch for
backward compatibility.
Introduce a resources helper that generates 7 standard RESTful
routes (index, new, create, show, edit, update, destroy) from a
resource name and controller, enabling concise route definitions
like (resources "todos" "myapp/controllers/todo-controller:<todo-controller>").
Routes are ordered so /new is matched before /:id.
Allow selective route generation by specifying which actions to
include or exclude, similar to Rails' resources routing options.
Example: (resources todos controller :except '(:destroy))
Add RESTful routing with resources function
@tamurashingo tamurashingo merged commit 68405d0 into main May 13, 2026
2 checks passed
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