-
Notifications
You must be signed in to change notification settings - Fork 1
Add code to handle map/list default values #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add tests for map defaults with JSON encoding - Add tests for list defaults with JSON encoding - Add tests for empty map and list defaults - Add tests for complex nested map defaults - Add tests for maps with various JSON types (string, number, bool, null) - Update existing empty map/list tests to reflect new behavior - All 43 migration tests + 54 connection tests pass
WalkthroughAdds JSON-encoding for map/list column defaults, converts temporal and Decimal defaults to quoted ISO8601/string literals, treats Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (3)**/*.{ex,exs,rs,md}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
test/**/*.{exs,ex}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ex,exs}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (13)📓 Common learnings📚 Learning: 2026-01-15T00:20:50.130ZApplied to files:
📚 Learning: 2026-01-15T00:20:50.130ZApplied to files:
📚 Learning: 2026-01-15T00:20:50.130ZApplied to files:
📚 Learning: 2026-01-12T07:35:10.447ZApplied to files:
📚 Learning: 2026-01-12T07:35:10.447ZApplied to files:
📚 Learning: 2026-01-12T07:35:10.447ZApplied to files:
📚 Learning: 2026-01-15T00:20:50.130ZApplied to files:
📚 Learning: 2026-01-12T07:35:10.447ZApplied to files:
📚 Learning: 2026-01-15T00:20:50.130ZApplied to files:
📚 Learning: 2026-01-15T00:20:50.130ZApplied to files:
📚 Learning: 2026-01-12T07:35:10.447ZApplied to files:
📚 Learning: 2026-01-12T07:35:10.447ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (7)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Log descriptive warnings when Jason.encode fails for map defaults - Log descriptive warnings when Jason.encode fails for list defaults - Provides visibility into why DEFAULT clause is not generated - Matches existing error handling pattern from catch-all clause - Includes tests verifying warning is logged for unencodable values (PIDs, functions) Addresses feedback to improve debuggability when JSON encoding fails
- Combine column_default clauses for maps and lists using 'or' guard - Extract common JSON encoding logic into encode_json_default/2 helper - Reduces code duplication while maintaining readability - Helper function handles both map and list type names for accurate logging - All column_default clauses now grouped together per Elixir style guide Addresses feedback to consolidate duplicate logic
- Replace String.contains?(sql, ["DEFAULT '[]'"]) with sql =~ "DEFAULT '[]'" - More idiomatic Elixir pattern matching for simple string checks - Reduces unnecessary list wrapping - Maintains test clarity and intent Addresses feedback to simplify unnecessarily verbose assertions
…ll defaults Support for missing DEFAULT types: - Decimal: Converts to string representation (e.g., '19.99') - DateTime: Converts to ISO8601 string (e.g., '2026-01-16T14:30:00Z') - NaiveDateTime: Converts to ISO8601 string (e.g., '2026-01-16T14:30:00') - Date: Converts to ISO8601 string (e.g., '2026-01-16') - Time: Converts to ISO8601 string (e.g., '14:30:45.123456') - :null atom: Treated same as nil (no DEFAULT clause) All conversions match the parameter encoding behavior in query.ex for consistency. Add comprehensive test coverage: - Basic Decimal defaults with various precision levels - DateTime defaults with microsecond precision - NaiveDateTime, Date, and Time defaults - Edge cases: negative decimals, many decimal places - :null atom behavior parity with nil This closes the gap between what types the library accepts in parameters and what types it accepts as column defaults in migrations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/ecto_migration_test.exs`:
- Around line 1049-1052: The current assertion uses String.contains?(sql,
["string", "number", "bool"]) which only checks for any match; change it to
assert that all three JSON keys are present by checking each explicitly (for
example using Enum.all?/2 with String.contains?/2 or three separate asserts)
against the sql variable; update the test around the assertions that reference
sql and the String.contains? call so it ensures "string", "number", and "bool"
are all contained.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/ecto/adapters/libsql/connection.extest/ecto_migration_test.exs
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ex,exs,rs,md}
📄 CodeRabbit inference engine (CLAUDE.md)
Use British/Australian English for all code, comments, and documentation (except SQL keywords and compatibility requirements)
Files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
test/**/*.{exs,ex}
📄 CodeRabbit inference engine (CLAUDE.md)
test/**/*.{exs,ex}: For state threading in tests, use consistent variable naming:statefor connection scope,trx_statefor transaction scope,cursorfor cursor scope,stmt_idfor prepared statement ID scope
When an error operation returns updated state in tests that IS needed for subsequent operations, rebind the state variable and add clarifying comments
When an error operation returns state in tests that is NOT needed for subsequent operations, discard it with underscore
For terminal test operations, use underscore variable names and assert error tuples with the patternassert {:error, %EctoLibSql.Error{}, _conn}
Files:
test/ecto_migration_test.exs
**/*.{ex,exs}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ex,exs}: Use named parameters (:name,@name, or$namesyntax) in SQL queries instead of positional?parameters for improved readability and maintainability in Elixir code
Use prepared statements with EctoLibSql.Native.prepare/2 and statement caching for repeated queries to achieve 10-15x performance improvement
Always use transactions (handle_begin/handle_commit/handle_rollback) for multi-step database operations to ensure data consistency
When working with maps or lists containing temporal types (DateTime, NaiveDateTime, Date) for JSON storage, manually pre-encode them to ISO8601 strings before JSON serialization
For batch operations, prefer EctoLibSql.Native.batch_transactional/2 over individual inserts within explicit transactions for better atomicity and performance
Use cursors via DBConnection.stream/3 with max_rows parameter for memory-efficient processing of large result sets instead of loading all rows into memory
Implement proper error handling with pattern matching on {:ok, ...} and {:error, ...} tuples, use supervision trees for database worker processes, and log errors with context
In Ecto queries with JSON extraction, use fragment with inline SQL operators likedata ->> 'key'for simpler syntax instead of the arrow_fragment helper for static fields
Use EctoLibSql.JSON module functions for JSON manipulation (extract, type, set, remove, patch, etc.) instead of raw SQL JSON functions for consistency and safety
Always wrap vector similarity search queries with limit clause and filter metadata using standard WHERE conditions before ordering by distance
Avoid using await onfreeze_replica/1function - it is not supported. Use backup/restore or data replication workarounds for disaster recovery scenarios
Files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
lib/ecto/adapters/libsql/connection.ex
📄 CodeRabbit inference engine (CLAUDE.md)
Update SQL generation in
lib/ecto/adapters/libsql/connection.exwhen adding SQLite function support
Files:
lib/ecto/adapters/libsql/connection.ex
lib/**/*.ex
📄 CodeRabbit inference engine (CLAUDE.md)
lib/**/*.ex: Use proper transactions with timeout for database operations:Repo.transaction(fn -> ... end, timeout: 15_000)to avoid database locked errors
Ensure connections are closed in try/after blocks to prevent connection leaks
Use immediate transactions for write operations:begin(state, behavior: :immediate)for write-heavy workloads
Verify schema types match database columns and check custom types have loaders/dumpers to fix type conversion errors
Usecast/3in changesets for automatic type conversion in Elixir
Files:
lib/ecto/adapters/libsql/connection.ex
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.JSON module functions for JSON manipulation (extract, type, set, remove, patch, etc.) instead of raw SQL JSON functions for consistency and safety
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/*.{ex,exs} : When working with maps or lists containing temporal types (DateTime, NaiveDateTime, Date) for JSON storage, manually pre-encode them to ISO8601 strings before JSON serialization
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.JSON module functions for JSON manipulation (extract, type, set, remove, patch, etc.) instead of raw SQL JSON functions for consistency and safety
Applied to files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to priv/repo/migrations/*.exs : Use STRICT table option in Ecto migrations for type safety, and ensure migrations define appropriate indexes (especially for frequently queried columns) and use table constraints
Applied to files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/ecto/adapters/libsql.ex : Update type loaders and dumpers in `lib/ecto/adapters/libsql.ex` when fixing type conversion issues
Applied to files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/**/*.ex : Verify schema types match database columns and check custom types have loaders/dumpers to fix type conversion errors
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to priv/repo/migrations/*.exs : For SQLite migrations requiring column type changes, use table recreation pattern: create new table with desired schema, copy data with transformation, drop old table, rename new table, recreate indexes (SQLite doesn't support ALTER COLUMN; SQLite < 3.35.0 doesn't support DROP COLUMN)
Applied to files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/**/*.ex : Use `cast/3` in changesets for automatic type conversion in Elixir
Applied to files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to test/**/*.{exs,ex} : For terminal test operations, use underscore variable names and assert error tuples with the pattern `assert {:error, %EctoLibSql.Error{}, _conn}`
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/ecto/adapters/libsql/connection.ex : Update SQL generation in `lib/ecto/adapters/libsql/connection.ex` when adding SQLite function support
Applied to files:
test/ecto_migration_test.exslib/ecto/adapters/libsql/connection.ex
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to priv/repo/migrations/*.exs : For R*Tree spatial indexing, ensure table has odd number of columns (id + 1-5 dimension pairs), use proper min/max column naming convention, and create with rtree: true option in migrations
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/schemas/**/*.ex : When using Ecto changesets with LibSQL, always define unique_constraint/2 for email and other unique fields, and use on_conflict handling for upsert operations
Applied to files:
test/ecto_migration_test.exs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Elixir 1.18.0 / OTP 27.0 / ubuntu-latest
- GitHub Check: Elixir 1.18.0 / OTP 27.0 / macos-latest
- GitHub Check: Analyze (rust)
🔇 Additional comments (3)
lib/ecto/adapters/libsql/connection.ex (1)
476-512: Well-implemented JSON encoding for map/list defaults.The implementation correctly handles JSON encoding with proper SQL escaping and graceful error handling. The
escape_string/1call ensures single quotes in JSON are properly escaped to prevent SQL injection.Minor note:
require Loggerinside the error branch is evaluated at runtime on each failure. Since this only occurs during migrations and on encoding errors (both rare), this is acceptable.test/ecto_migration_test.exs (2)
939-966: Tests correctly updated to reflect new JSON encoding behaviour.The assertions now verify that empty maps encode to
'{}'and empty lists encode to'[]', which aligns with the implementation changes.
1054-1096: Excellent coverage for unencodable value edge cases.The tests properly verify both the absence of the DEFAULT clause and the warning messages using
ExUnit.CaptureLog. Good use of real unencodable values (PID, function) rather than mocks.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Changed assertion from: assert String.contains?(sql, ["string", "number", "bool"]) To explicit assertions: assert sql =~ "string" assert sql =~ "number" assert sql =~ "bool" The original assertion only verified that ANY of the keys were present. The new approach ensures ALL three JSON keys are present in the DEFAULT clause, providing stronger validation that the JSON encoding is complete.
Use DateTime.from_iso8601/1 instead of DateTime.new!/4 to avoid timezone database issues. The ISO8601 parser is more reliable and doesn't require timezone configuration in tests.
Add test_pattern and test_paths to mix.exs to explicitly configure which files are test files. This eliminates the warning about support files (test/support/*.ex) not matching test patterns, while ensuring all test files matching **/*_test.exs are correctly identified and run.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/ecto_migration_test.exs`:
- Around line 981-1054: Update each JSON-default test (e.g., "handles map
defaults (JSON encoding)", "handles list defaults", "handles empty list
defaults", "handles complex nested map defaults", "handles map with various JSON
types") to locate the DEFAULT literal in the SQL returned by
Connection.execute_ddl, extract the quoted JSON string (the DEFAULT '...') and
decode it with Jason.decode!/1, then assert the decoded map/list equals the
expected structure (including asserting presence of keys like "null" => nil).
Use the Table struct and Connection.execute_ddl output as the source, parse the
DEFAULT clause for the column name (e.g.,
"preferences","tags","settings","metadata"), unescape the JSON string, decode
and compare to the exact expected Elixir map/list values to strengthen the
tests.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
mix.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
mix.exstest/ecto_migration_test.exs
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ex,exs,rs,md}
📄 CodeRabbit inference engine (CLAUDE.md)
Use British/Australian English for all code, comments, and documentation (except SQL keywords and compatibility requirements)
Files:
mix.exstest/ecto_migration_test.exs
**/*.{ex,exs}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ex,exs}: Use named parameters (:name,@name, or$namesyntax) in SQL queries instead of positional?parameters for improved readability and maintainability in Elixir code
Use prepared statements with EctoLibSql.Native.prepare/2 and statement caching for repeated queries to achieve 10-15x performance improvement
Always use transactions (handle_begin/handle_commit/handle_rollback) for multi-step database operations to ensure data consistency
When working with maps or lists containing temporal types (DateTime, NaiveDateTime, Date) for JSON storage, manually pre-encode them to ISO8601 strings before JSON serialization
For batch operations, prefer EctoLibSql.Native.batch_transactional/2 over individual inserts within explicit transactions for better atomicity and performance
Use cursors via DBConnection.stream/3 with max_rows parameter for memory-efficient processing of large result sets instead of loading all rows into memory
Implement proper error handling with pattern matching on {:ok, ...} and {:error, ...} tuples, use supervision trees for database worker processes, and log errors with context
In Ecto queries with JSON extraction, use fragment with inline SQL operators likedata ->> 'key'for simpler syntax instead of the arrow_fragment helper for static fields
Use EctoLibSql.JSON module functions for JSON manipulation (extract, type, set, remove, patch, etc.) instead of raw SQL JSON functions for consistency and safety
Always wrap vector similarity search queries with limit clause and filter metadata using standard WHERE conditions before ordering by distance
Avoid using await onfreeze_replica/1function - it is not supported. Use backup/restore or data replication workarounds for disaster recovery scenarios
Files:
mix.exstest/ecto_migration_test.exs
test/**/*.{exs,ex}
📄 CodeRabbit inference engine (CLAUDE.md)
test/**/*.{exs,ex}: For state threading in tests, use consistent variable naming:statefor connection scope,trx_statefor transaction scope,cursorfor cursor scope,stmt_idfor prepared statement ID scope
When an error operation returns updated state in tests that IS needed for subsequent operations, rebind the state variable and add clarifying comments
When an error operation returns state in tests that is NOT needed for subsequent operations, discard it with underscore
For terminal test operations, use underscore variable names and assert error tuples with the patternassert {:error, %EctoLibSql.Error{}, _conn}
Files:
test/ecto_migration_test.exs
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/*.{ex,exs} : When working with maps or lists containing temporal types (DateTime, NaiveDateTime, Date) for JSON storage, manually pre-encode them to ISO8601 strings before JSON serialization
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/*.{ex,exs} : Implement proper error handling with pattern matching on {:ok, ...} and {:error, ...} tuples, use supervision trees for database worker processes, and log errors with context
Applied to files:
mix.exs
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/*.{ex,exs} : Use EctoLibSql.JSON module functions for JSON manipulation (extract, type, set, remove, patch, etc.) instead of raw SQL JSON functions for consistency and safety
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to priv/repo/migrations/*.exs : Use STRICT table option in Ecto migrations for type safety, and ensure migrations define appropriate indexes (especially for frequently queried columns) and use table constraints
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/ecto/adapters/libsql.ex : Update type loaders and dumpers in `lib/ecto/adapters/libsql.ex` when fixing type conversion issues
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to test/**/*.{exs,ex} : For terminal test operations, use underscore variable names and assert error tuples with the pattern `assert {:error, %EctoLibSql.Error{}, _conn}`
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to **/schemas/**/*.ex : When using Ecto changesets with LibSQL, always define unique_constraint/2 for email and other unique fields, and use on_conflict handling for upsert operations
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-15T00:20:50.130Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T00:20:50.130Z
Learning: Applies to priv/repo/migrations/*.exs : For R*Tree spatial indexing, ensure table has odd number of columns (id + 1-5 dimension pairs), use proper min/max column naming convention, and create with rtree: true option in migrations
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/ecto/adapters/libsql/connection.ex : Update SQL generation in `lib/ecto/adapters/libsql/connection.ex` when adding SQLite function support
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/**/*.ex : Verify schema types match database columns and check custom types have loaders/dumpers to fix type conversion errors
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to priv/repo/migrations/*.exs : For SQLite migrations requiring column type changes, use table recreation pattern: create new table with desired schema, copy data with transformation, drop old table, rename new table, recreate indexes (SQLite doesn't support ALTER COLUMN; SQLite < 3.35.0 doesn't support DROP COLUMN)
Applied to files:
test/ecto_migration_test.exs
📚 Learning: 2026-01-12T07:35:10.447Z
Learnt from: CR
Repo: ocean/ecto_libsql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-12T07:35:10.447Z
Learning: Applies to lib/**/*.ex : Use `cast/3` in changesets for automatic type conversion in Elixir
Applied to files:
test/ecto_migration_test.exs
🔇 Additional comments (4)
mix.exs (1)
20-21: Nice explicit test discovery settings.
Keeps ExUnit discovery consistent in CI and locally.test/ecto_migration_test.exs (3)
939-966: Good coverage for empty map/list defaults.
Assertions align with the JSON‑encoded behaviour.
1056-1098: Nice warning coverage for unencodable defaults.
Capturing logs keeps the behaviour explicit.
1100-1187: Good coverage for :null, Decimal, and temporal defaults.
These cases now exercise the quoting/ISO‑8601 paths well.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Replace weak substring-based checks with proper extraction and decoding of JSON literals from DEFAULT clauses. This ensures: - Exact structure validation via Jason.decode! - Detection of missing keys (including null values) - Verification that JSON is valid and complete - No false positives from partial matches Applied pattern to 5 JSON default tests: - handles map defaults (JSON encoding) - handles list defaults (JSON encoding) - handles empty list defaults - handles complex nested map defaults - handles map with various JSON types Tests now extract the JSON literal using regex and validate the decoded structure matches exactly, including null values that would be silently dropped by substring assertions.
Further fixes for #57
Summary by CodeRabbit
Bug Fixes
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.