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* (?.*) $ 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