Skip to content

Commit 970126e

Browse files
authored
Merge pull request rails#50336 from fatkodima/schema_dumper-dump-global-out
Change `SchemaDumper.dump` default stream to `$stdout`
2 parents fa32da9 + 306b2fc commit 970126e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

activerecord/lib/active_record/schema_dumper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SchemaDumper # :nodoc:
4141
cattr_accessor :unique_ignore_pattern, default: /^uniq_rails_[0-9a-f]{10}$/
4242

4343
class << self
44-
def dump(connection = ActiveRecord::Base.connection, stream = STDOUT, config = ActiveRecord::Base)
44+
def dump(connection = ActiveRecord::Base.connection, stream = $stdout, config = ActiveRecord::Base)
4545
connection.create_schema_dumper(generate_options(config)).dump(stream)
4646
stream
4747
end

activerecord/test/support/schema_dumping_helper.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ def dump_table_schema(*tables)
55
connection = ActiveRecord::Base.connection
66
old_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
77
ActiveRecord::SchemaDumper.ignore_tables = connection.data_sources - tables
8-
stream = StringIO.new
98

10-
ActiveRecord::SchemaDumper.dump(connection, stream)
11-
stream.string
9+
output, = capture_io do
10+
ActiveRecord::SchemaDumper.dump(connection)
11+
end
12+
output
1213
ensure
1314
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
1415
end
1516

1617
def dump_all_table_schema(ignore_tables = [], connection: ActiveRecord::Base.connection)
1718
old_ignore_tables, ActiveRecord::SchemaDumper.ignore_tables = ActiveRecord::SchemaDumper.ignore_tables, ignore_tables
18-
stream = StringIO.new
19-
ActiveRecord::SchemaDumper.dump(connection, stream)
20-
stream.string
19+
output, = capture_io do
20+
ActiveRecord::SchemaDumper.dump(connection)
21+
end
22+
output
2123
ensure
2224
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
2325
end

0 commit comments

Comments
 (0)