go-gorm / clickhouse

GORM clickhouse driver
MIT License
244 stars 72 forks source link

setting allow_experimental_object_type to migrate JSON type fields to Clickhouse DB #170

Open samanshahroudi opened 4 months ago

samanshahroudi commented 4 months ago

Your Question

How can I set the allow_experimental_object_type value before creating a table in Clickhouse DB using go-gorm library?

The document you expected this should be explained

I need to have a field of type Json in the Golang structure. According to this document https://clickhouse.com/docs/en/integrations/data-formats/json, I need to set the allow_experimental_object_type value to 1 before creating a table, but I couldn't find a way to set it using the go-gorm library.

Expected answer

I need a code snippet or a small workaround to set allow_experimental_object_type to 1 using go-gorm library, so I can automatically migrate the Golang struct to the Clickhouse table with the JSON field.

mr-tron commented 4 months ago

err = conn.Exec("set allow_experimental_object_type = 1").AutoMigrate(objects...)

xuchen81 commented 1 month ago

having the same question, anyone can help?

xuchen81 commented 1 month ago

err = conn.Exec("set allow_experimental_object_type = 1").AutoMigrate(objects...)

it does not work.