Open kyrylo opened 1 week ago
Please, write example request.
How to reproduce:
Create a table:
CREATE TABLE things
(
name String,
)
ENGINE = MergeTree
ORDER BY name;
Insert a record with the string DB::Exception
:
INSERT INTO things (name) VALUES ('DB::Exception');
Create a model for this in the Rails app
class Thing < ApplicationRecord
establish_connection :clickhouse
end
Run any query that selects the inserted row:
irb(main):002> Thing.first
Clickhouse Thing Load (4.1ms) SELECT things.* FROM things ORDER BY things.name ASC LIMIT 1
(irb):2:in `<main>': Response code: 200: (ActiveRecord::ActiveRecordError)
["name"]
["String"]
["DB::Exception"]
Query: SELECT things.* FROM things ORDER BY things.name ASC LIMIT 1
This is the commit that introduced the bug: https://github.com/PNixx/clickhouse-activerecord/commit/df61a892da5fe13b685ae38cdcda91ecc4efd27b
Not sure why a DB::Exception happens when the response is 200. I couldn't find any relevant info online.
I created a PR with the possible fix. https://github.com/PNixx/clickhouse-activerecord/pull/165
My issue is with a table that has a
name
column. When I insert a string containingDB::Exception
into the name column and select the row, I get anActiveRecord::ActiveRecordError
.The raw ClickHouse query works fine, but selecting via the adapter triggers the error. The buggy code is here: https://github.com/PNixx/clickhouse-activerecord/blob/ddfa259bbec88aefa3eaf2942392b8473a477601/lib/active_record/connection_adapters/clickhouse/schema_statements.rb#L185-L187
It assumes that DB::Exception only appears during a real ClickHouse exception.
Thank you for the gem! It makes the impossible possible :)