chore: merge upstream into fork (2026-04-06)#1
Open
richardvenneman wants to merge 42 commits intomasterfrom
Open
chore: merge upstream into fork (2026-04-06)#1richardvenneman wants to merge 42 commits intomasterfrom
richardvenneman wants to merge 42 commits intomasterfrom
Conversation
* Allow removal of `FINAL` keyword. Rewrite to conform to normal ActiveRecord definition structure. * Rename :check_command to :check_command! to reflect that its purpose is to raise an error on a failed check. * Rewrite :settings, while we're in here, to conform to the AR query method API, too. * Allow :unscope to handle :settings and :final. * Invoke correct method for Rails 7.2 and above.
…Nixx#220) The regex in assign_database_to_subquery! used a lookbehind (?<=from) which matched 'from' anywhere in the SQL, including in column names like 'sourced_from'. This caused the next identifier to be incorrectly prefixed with the database name. Bug example: SELECT sourced_from, now() FROM table Would become: SELECT sourced_from, default.now() FROM default.table Causing error: Function with name 'default.now' does not exist Fixed by using \bfrom\s+ to match 'from' only as a complete word (SQL keyword), not as part of column names. Added tests covering: - Column names containing 'from' - Verification that functions are not prefixed - Verification that table names are correctly prefixed All 93 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
* Add JSON column type support
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>
* Fix JSON migration test for ClickHouse 25.10 compatibility
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>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Rails is using `execute_batch` when truncating tables and loading fixtures. https://github.com/rails/rails/blob/bab99f8b51dfbff4d9e161b8f23c0dbf5d3b9314/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L232 https://github.com/rails/rails/blob/bab99f8b51dfbff4d9e161b8f23c0dbf5d3b9314/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L515 But since this gem is changing signature of `raw_execute`, then it does not work out of the box and needs to call `execute` instead. https://github.com/rails/rails/blob/bab99f8b51dfbff4d9e161b8f23c0dbf5d3b9314/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L616-L620
The minitest and rspec helpers were changing ActiveRecord::Base.connection to ClickHouse without restoring it afterward. This broke multi-database Rails apps where the primary database is PostgreSQL/MySQL.
* Add configurable HTTP auth modes Keeps the current behavior as default, sending user and password as URL parameters. Accept http_auth config with x_clickhouse_headers or basic options - basic` sends `Authorization: Basic ...` and keeps `database` in URL params. - x_clickhouse_headers` sends `X-ClickHouse-User`, `X-ClickHouse-Key`, and `X-ClickHouse-Database` headers. * Add explicit query_params http_auth mode It documents and validates all supported modes to reduce ambiguity * Improve local single-spec workflow Fix console loading and add helper/docs to run single adapter tests consistently
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.
Description
Merges the latest upstream changes from PNixx/clickhouse-activerecord into the beehiiv fork. Upstream moved ahead by ~46 commits since the fork diverged at
40ccedf.Most previous fork-specific patches (final position fix, schema dumper fix, lock synchronization, EOFError handling, disconnect method) have since been addressed upstream and merge cleanly. The one customization that remains unique to our fork is the retry logic for transient network errors, which was moved from the now-deprecated
do_executeintoraw_executeto fit upstream's refactored structure. A duplicatedisconnect!override was dropped in favour of upstream's safer guarded version (@connection&.started?).5637a95(Add configurable HTTP auth modes Add configurable HTTP auth modes for ClickHouse requests PNixx/clickhouse-activerecord#240)EOFError/Errno::ECONNRESETretry logic (2 retries) inraw_executedisconnect!that would have shadowed upstream's safer implementationProof
Signoff
Videos/Screenshots
Switched locally to this commit and all Swarm specs passed. Will do more extensive testing when I put up a PR against swarm to update the gem there.
Review Context
Upstream changelog for everything included in this merge:
Version 1.6.7 (Mar 5, 2026)
Version 1.6.6 (Feb 16, 2026)
execute_to_filewill returnTempfileobjectVersion 1.6.3 (Feb 4, 2026)
execute_streamingtoexecute_to_fileVersion 1.6.2 (Jan 30, 2026)
Version 1.6.1 (Jan 20, 2026)
Version 1.6.0 (Jan 19, 2026)
WITHclauseexecute_batchSupport truncating tables and importing fixtures (via execute_batch) PNixx/clickhouse-activerecord#216check_current_protected_environment!to Tasks Add check_current_protected_environment! to Tasks. PNixx/clickhouse-activerecord#222Version 1.5.1 (Nov 6, 2025)
Version 1.5.0 (Nov 5, 2025)
schema_migrationsVersion 1.4.0 (Sep 18, 2025)
CREATE OR REPLACE FUNCTIONin SQL schema dumpsdo_executeis now deprecated in favour ofexecute)Unreleased
X-ClickHouse-*headers Add configurable HTTP auth modes for ClickHouse requests PNixx/clickhouse-activerecord#240