From d060688b27c4d1c9fa34555f5e6536ec7f0edbcb Mon Sep 17 00:00:00 2001 From: zverok Date: Sat, 14 Dec 2024 17:26:12 +0200 Subject: [PATCH 1/2] Add test --- spec/dumper_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/dumper_spec.rb b/spec/dumper_spec.rb index a5d229c..35d5460 100644 --- a/spec/dumper_spec.rb +++ b/spec/dumper_spec.rb @@ -79,6 +79,14 @@ def after(env) Then { expect(dump use_middleware: false).to match(/\\"substring\\"\(\(random/) } end + context "column with a whitespace", postgresql: :only do + before(:each) do + migration.execute %Q{ALTER TABLE "things" ADD "whitespaced column" integer} + end + + Then { expect(dump use_middleware: false).to include('t.integer "whitespaced column"') } + end + context TestDumper::Middleware::Dumper::Initial do Then { expect(dump).to match(/Schema([\[\].0-9]+)?[.]define.*do\s+#{middleware}/) } end From 2bda7f2b0681f4f5c7d1bae2ff4cf38a71e2818d Mon Sep 17 00:00:00 2001 From: zverok Date: Sat, 14 Dec 2024 17:37:51 +0200 Subject: [PATCH 2/2] More resilient regexp for column names in SchemaDumper --- lib/schema_plus/core/active_record/schema_dumper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/schema_plus/core/active_record/schema_dumper.rb b/lib/schema_plus/core/active_record/schema_dumper.rb index bc058d6..164df3b 100644 --- a/lib/schema_plus/core/active_record/schema_dumper.rb +++ b/lib/schema_plus/core/active_record/schema_dumper.rb @@ -79,7 +79,7 @@ def tables(_) %r{ ^ t\.(?\S+) \s* - [:'"](?[^"\s]+)[,"]? \s* + (:(?[a-z_]+)|"(?[^"]+)"|'(?[^']+)') \s* ,? \s* (?.*) $