Open dorianmariecom opened 6 months ago
I fixed it by doing:
def self.create!(**attributes)
if attributes[:properties].present?
attributes[:properties] = attributes[:properties]
.transform_values(&:to_s)
.to_json
.gsub('"', "'")
end
super(**attributes)
end
Actually I did:
# frozen_string_literal: true
module Clickhouse
class EventsRaw < BaseRecord
self.table_name = 'events_raw'
def properties=(properties)
super(properties.transform_values(&:to_s).to_json.gsub('"', "'"))
rescue
super(properties)
end
def properties
JSON.parse(super.gsub("'", '"'))
rescue
super
end
end
end
Even more of a hack:
# frozen_string_literal: true
module Clickhouse
class EventsRaw < BaseRecord
self.table_name = 'events_raw'
def properties=(properties)
super(properties.transform_values(&:to_s).to_json.gsub('"', "'").gsub("=>", ":"))
end
def properties
JSON.parse(super.gsub("'", '"').gsub("=>", ":"))
end
end
end
@dorianmariecom Can you write the structure of your table?
This issue is related to a fork of the gem that is adding a (limited) support of the Map type. See: https://github.com/getlago/clickhouse-activerecord
We (Lago) are willing to contribute to this gem with the changes but it's far from ready yet as the current implementation only supports Map(String, String)
and is not tested at all
I'm getting this error with lago.
You can see the source code at https://github.com/dorianmariecom/lago-api/tree/dorian/clickhouse-activerecord-bug
Also happens with
properties: properties
and withproperties.to_json