Skip to content

chore: merge upstream into fork (2026-04-06)#1

Open
richardvenneman wants to merge 42 commits intomasterfrom
richard/chore-merge-upstream-2026-04-06
Open

chore: merge upstream into fork (2026-04-06)#1
richardvenneman wants to merge 42 commits intomasterfrom
richard/chore-merge-upstream-2026-04-06

Conversation

@richardvenneman
Copy link
Copy Markdown
Member

@richardvenneman richardvenneman commented Apr 6, 2026

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_execute into raw_execute to fit upstream's refactored structure. A duplicate disconnect! override was dropped in favour of upstream's safer guarded version (@connection&.started?).

Proof

Signoff
  • UI/UX designer signoff
  • User facing copy is sentence case: see guidelines
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)

  • Fix insert with default values in Ruby 4.0 and Rails 8.1

Version 1.6.6 (Feb 16, 2026)

  • Fix error: EOFError (end of file reached)
  • Method execute_to_file will return Tempfile object

Version 1.6.3 (Feb 4, 2026)

  • Rename method execute_streaming to execute_to_file

Version 1.6.2 (Jan 30, 2026)

  • Add streaming request and save response to tmp file

Version 1.6.1 (Jan 20, 2026)

  • Fix prepare rake task on ClickHouse 24.6

Version 1.6.0 (Jan 19, 2026)

Version 1.5.1 (Nov 6, 2025)

  • Fix rake tasks

Version 1.5.0 (Nov 5, 2025)

  • Support for Rails 8.1
  • Fix sql structure dump with schema_migrations
  • Remove old tasks

Version 1.4.0 (Sep 18, 2025)

  • CREATE OR REPLACE FUNCTION in SQL schema dumps
  • Added shard config to handle replica path with shard
  • Add support for simple schema dumping
  • Unscope :final and :settings
  • Encapsulate format logic within Statement and helper classes (do_execute is now deprecated in favour of execute)

Unreleased

leboshi and others added 30 commits September 5, 2025 08:52
* 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>
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.
PNixx and others added 12 commits January 30, 2026 09:37
* 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
@richardvenneman richardvenneman self-assigned this Apr 6, 2026
@richardvenneman richardvenneman marked this pull request as ready for review April 6, 2026 15:23
Copy link
Copy Markdown

@JacobNWolf JacobNWolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo! Thanks for doing this.

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.