diff --git a/lib/active_record/connection_adapters/clickhouse/schema_creation.rb b/lib/active_record/connection_adapters/clickhouse/schema_creation.rb index 95788792..428486e1 100644 --- a/lib/active_record/connection_adapters/clickhouse/schema_creation.rb +++ b/lib/active_record/connection_adapters/clickhouse/schema_creation.rb @@ -67,7 +67,7 @@ def assign_database_to_subquery!(subquery) # If you do not specify a database explicitly, ClickHouse will use the "default" database. return unless subquery - match = subquery.match(/(?<=from)[^.\w]+(?\w+(?=\.))?(?[.\w]+)/i) + match = subquery.match(/(?<=from)[^.\w(]+(?\w+(?=\.))?(?[.\w]+)/i) return unless match return if match[:database]