Add JSON column type support#209
Merged
PNixx merged 2 commits intoPNixx:masterfrom Nov 17, 2025
Merged
Conversation
Owner
|
@ScotterC testing failed |
Adds support for ClickHouse JSON column type to fix schema dump failures.
- Add json: { name: 'JSON' } to NATIVE_DATABASE_TYPES constant
- Register JSON type mapping using ActiveRecord::Type::Json
- Add comprehensive test coverage for JSON column operations
- Include tests for column recognition, CRUD operations, and migrations
- Handle ClickHouse JSON type limitations (non-nullable, numbers as strings)
Resolves "Unknown type 'JSON' for column" errors in Rails schema dumps.
Requires allow_experimental_json_type = 1 setting in ClickHouse 21.1+.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
0392add to
a833002
Compare
Use MergeTree engine for JSON migration test instead of relying on the default Log engine. The Log engine doesn't support JSON columns with dynamic subcolumns in ClickHouse, which causes test failures in version 25.10. This change ensures compatibility with both ClickHouse 24.9 and 25.10. All 98 tests now pass on both versions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
@PNixx updated to fix specs |
woodhull
added a commit
to daisychainapp/clickhouse-activerecord
that referenced
this pull request
Nov 24, 2025
This merge brings in the latest improvements from upstream including: - JSON column type support (PNixx#209) - Fixed regex to match FROM keyword (PNixx#220) - Active Record 8.1 support - SQL structure dumper improvements - Better format logic encapsulation (PNixx#162) - Schema dumper fixes (PNixx#206) - Unscope :final and :settings (PNixx#208) Fork-specific functionality preserved: - EOFError and Errno::ECONNRESET retry logic (integrated into raw_execute) - Custom insert settings via ClickhouseActiverecord::Settings thread-local - disconnect! method implementation - Security fix: no hardcoded OpenSSL::SSL::VERIFY_NONE - Async insert configuration support The retry logic has been adapted to work with the new execute/raw_execute architecture introduced by upstream, ensuring compatibility with the refactored code structure while maintaining reliability for connection errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2 tasks
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.
Summary
This PR adds support for ClickHouse's JSON column type to fix Rails schema dump failures that occur with "Unknown type 'JSON' for column" errors.
Changes Made
json: { name: 'JSON' }toNATIVE_DATABASE_TYPESconstantType::Jsonclasst.jsonsyntaxinsert_alloperationsTechnical Details
Type::Jsonfor consistent behaviorallow_experimental_json_type = 1setting (ClickHouse 21.1+)Testing
Usage Example
Compatibility
allow_experimental_json_type = 1This minimal, backwards-compatible implementation resolves schema dump issues while providing full JSON column support for ClickHouse users.
🤖 Generated with Claude Code