From 29d00796b04f9de813cc8ee63ff7f5840b096dff Mon Sep 17 00:00:00 2001 From: HereC Date: Thu, 11 Jul 2024 14:44:13 -0400 Subject: [PATCH] Quote table names with periods (#140) --- lib/clickhouse-activerecord/schema_dumper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/clickhouse-activerecord/schema_dumper.rb b/lib/clickhouse-activerecord/schema_dumper.rb index b03839a5..3196f1e6 100644 --- a/lib/clickhouse-activerecord/schema_dumper.rb +++ b/lib/clickhouse-activerecord/schema_dumper.rb @@ -104,7 +104,8 @@ def table(table, stream) raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type) next if column.name == pk type, colspec = column_spec(column) - tbl.print " t.#{type} #{column.name.inspect}" + name = column.name =~ (/\./) ? "\"`#{column.name}`\"" : column.name.inspect + tbl.print " t.#{type} #{name}" tbl.print ", #{format_colspec(colspec)}" if colspec.present? tbl.puts end