diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6d3eb4d..afa17146 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: ruby: ["3.2", "3.3", "3.4"] - rails: ["7.1", "7.2", "8.0", "8.1.0"] + rails: ["7.2", "8.0", "8.1"] continue-on-error: [false] services: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f363d2c..9c8af5ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ changelog, see the [commits] for each version via the version links. - Require Ruby >= 3.1 (#162) - Drop EOL Ruby versions (3.0) (#162) - Drop EOL Rails versions (7.0) (#162) +- Add Rails 8.1 to the test matrix (#175) +- Ensure multi-schema dumping in Rails 8.1.0 does not dump the same objects for + all schemas (#177) +- Drop Rails 7.1 due to EOL (#176) ## [0.9.0] diff --git a/lib/fx/adapters/postgres/functions.rb b/lib/fx/adapters/postgres/functions.rb index dd0def11..2047bdaa 100644 --- a/lib/fx/adapters/postgres/functions.rb +++ b/lib/fx/adapters/postgres/functions.rb @@ -8,7 +8,7 @@ class Postgres class Functions # The SQL query used by F(x) to retrieve the functions considered # dumpable into `db/schema.rb`. - FUNCTIONS_WITH_DEFINITIONS_QUERY = <<~EOS.freeze + FUNCTIONS_WITH_DEFINITIONS_QUERY = <<~SQL.freeze SELECT pp.proname AS name, pg_get_functiondef(pp.oid) AS definition @@ -23,7 +23,7 @@ class Functions AND pd.objid IS NULL AND pa.aggfnoid IS NULL ORDER BY pp.oid; - EOS + SQL # Wraps #all as a static facade. # diff --git a/lib/fx/adapters/postgres/triggers.rb b/lib/fx/adapters/postgres/triggers.rb index 68cdded5..06ad188f 100644 --- a/lib/fx/adapters/postgres/triggers.rb +++ b/lib/fx/adapters/postgres/triggers.rb @@ -8,7 +8,7 @@ class Postgres class Triggers # The SQL query used by F(x) to retrieve the triggers considered # dumpable into `db/schema.rb`. - TRIGGERS_WITH_DEFINITIONS_QUERY = <<~EOS.freeze + TRIGGERS_WITH_DEFINITIONS_QUERY = <<~SQL.freeze SELECT pt.tgname AS name, pg_get_triggerdef(pt.oid) AS definition @@ -23,7 +23,7 @@ class Triggers AND pt.tgname NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%' ORDER BY pc.oid; - EOS + SQL # Wraps #all as a static facade. # diff --git a/spec/acceptance/user_manages_functions_spec.rb b/spec/acceptance/user_manages_functions_spec.rb index b788e248..86129155 100644 --- a/spec/acceptance/user_manages_functions_spec.rb +++ b/spec/acceptance/user_manages_functions_spec.rb @@ -3,14 +3,14 @@ RSpec.describe "User manages functions" do it "handles simple functions" do successfully "rails generate fx:function test" - write_function_definition "test_v01", <<~EOS + write_function_definition "test_v01", <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL successfully "rake db:migrate" result = execute("SELECT * FROM test() AS result") @@ -21,14 +21,14 @@ "db/functions/test_v01.sql", "db/functions/test_v02.sql" ) - write_function_definition "test_v02", <<~EOS + write_function_definition "test_v02", <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'testest'; END; $$ LANGUAGE plpgsql; - EOS + SQL successfully "rake db:migrate" result = execute("SELECT * FROM test() AS result") @@ -37,14 +37,14 @@ it "handles functions with arguments" do successfully "rails generate fx:function adder" - write_function_definition "adder_v01", <<~EOS + write_function_definition "adder_v01", <<~SQL CREATE FUNCTION adder(x int, y int) RETURNS int AS $$ BEGIN RETURN $1 + $2; END; $$ LANGUAGE plpgsql; - EOS + SQL successfully "rake db:migrate" result = execute("SELECT * FROM adder(1, 2) AS result") diff --git a/spec/acceptance/user_manages_triggers_spec.rb b/spec/acceptance/user_manages_triggers_spec.rb index ae293d12..94f06dce 100644 --- a/spec/acceptance/user_manages_triggers_spec.rb +++ b/spec/acceptance/user_manages_triggers_spec.rb @@ -4,7 +4,7 @@ it "handles simple triggers" do successfully "rails generate model user name:string upper_name:string" successfully "rails generate fx:function uppercase_users_name" - write_function_definition "uppercase_users_name_v01", <<~EOS + write_function_definition "uppercase_users_name_v01", <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -12,38 +12,38 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS + SQL successfully "rails generate fx:trigger uppercase_users_name table_name:users" - write_trigger_definition "uppercase_users_name_v01", <<~EOS + write_trigger_definition "uppercase_users_name_v01", <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL successfully "rake db:migrate" - execute <<~EOS + execute <<~SQL INSERT INTO users (name, created_at, updated_at) VALUES ('Bob', NOW(), NOW()); - EOS + SQL result = execute("SELECT upper_name FROM users WHERE name = 'Bob';") expect(result).to eq("upper_name" => "BOB") successfully "rails generate fx:trigger uppercase_users_name table_name:users" - write_trigger_definition "uppercase_users_name_v02", <<~EOS + write_trigger_definition "uppercase_users_name_v02", <<~SQL CREATE TRIGGER uppercase_users_name BEFORE UPDATE ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL successfully "rake db:migrate" - execute <<~EOS + execute <<~SQL UPDATE users SET name = 'Alice' WHERE id = 1; - EOS + SQL result = execute("SELECT upper_name FROM users WHERE name = 'Alice';") expect(result).to eq("upper_name" => "ALICE") diff --git a/spec/features/functions/migrations_spec.rb b/spec/features/functions/migrations_spec.rb index ce57992b..173d14f3 100644 --- a/spec/features/functions/migrations_spec.rb +++ b/spec/features/functions/migrations_spec.rb @@ -2,14 +2,14 @@ RSpec.describe "Function migrations", :db do around do |example| - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL with_function_definition(name: :test, sql_definition: sql_definition) do example.run end @@ -40,14 +40,14 @@ def up it "can run migrations that updates functions" do connection.create_function(:test) - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'testest'; END; $$ LANGUAGE plpgsql; - EOS + SQL with_function_definition( name: :test, version: 2, diff --git a/spec/features/functions/revert_spec.rb b/spec/features/functions/revert_spec.rb index c326a1bd..77e54c51 100644 --- a/spec/features/functions/revert_spec.rb +++ b/spec/features/functions/revert_spec.rb @@ -2,14 +2,14 @@ RSpec.describe "Reverting migrations", :db do around do |example| - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL with_function_definition(name: :test, sql_definition: sql_definition) do example.run end @@ -50,14 +50,14 @@ def change it "can run reversible migrations for updating functions" do connection.create_function(:test) - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'bar'; END; $$ LANGUAGE plpgsql; - EOS + SQL with_function_definition( name: :test, version: 2, diff --git a/spec/features/triggers/migrations_spec.rb b/spec/features/triggers/migrations_spec.rb index ba65a964..8675adcc 100644 --- a/spec/features/triggers/migrations_spec.rb +++ b/spec/features/triggers/migrations_spec.rb @@ -2,14 +2,14 @@ RSpec.describe "Trigger migrations", :db do around do |example| - connection.execute <<~EOS + connection.execute <<~SQL CREATE TABLE users ( id int PRIMARY KEY, name varchar(256), upper_name varchar(256) ); - EOS - Fx.database.create_function <<~EOS + SQL + Fx.database.create_function <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -17,13 +17,13 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS - sql_definition = <<~EOS + SQL + sql_definition = <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL with_trigger_definition( name: :uppercase_users_name, sql_definition: sql_definition diff --git a/spec/features/triggers/revert_spec.rb b/spec/features/triggers/revert_spec.rb index ec0177f8..5d16213a 100644 --- a/spec/features/triggers/revert_spec.rb +++ b/spec/features/triggers/revert_spec.rb @@ -2,14 +2,14 @@ RSpec.describe "Reverting migrations", :db do around do |example| - connection.execute <<~EOS + connection.execute <<~SQL CREATE TABLE users ( id int PRIMARY KEY, name varchar(256), upper_name varchar(256) ); - EOS - Fx.database.create_function <<~EOS + SQL + Fx.database.create_function <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -17,13 +17,13 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS - sql_definition = <<~EOS + SQL + sql_definition = <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL with_trigger_definition( name: :uppercase_users_name, sql_definition: sql_definition @@ -67,12 +67,12 @@ def change it "can run reversible migrations for updating triggers" do connection.create_trigger(:uppercase_users_name) - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE TRIGGER uppercase_users_name BEFORE UPDATE ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL with_trigger_definition( name: :uppercase_users_name, sql_definition: sql_definition, diff --git a/spec/fx/adapters/postgres/functions_spec.rb b/spec/fx/adapters/postgres/functions_spec.rb index 86653852..af681618 100644 --- a/spec/fx/adapters/postgres/functions_spec.rb +++ b/spec/fx/adapters/postgres/functions_spec.rb @@ -4,21 +4,21 @@ describe ".all" do it "returns `Function` objects" do connection = ActiveRecord::Base.connection - connection.execute <<~EOS + connection.execute <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL functions = Fx::Adapters::Postgres::Functions.new(connection).all first = functions.first expect(functions.size).to eq(1) expect(first.name).to eq("test") - expect(first.definition).to eq(<<~EOS) + expect(first.definition).to eq(<<~SQL) CREATE OR REPLACE FUNCTION public.test() RETURNS text LANGUAGE plpgsql @@ -27,7 +27,7 @@ RETURN 'test'; END; $function$ - EOS + SQL connection.execute "CREATE SCHEMA IF NOT EXISTS other;" connection.execute "SET search_path = 'other';" diff --git a/spec/fx/adapters/postgres/triggers_spec.rb b/spec/fx/adapters/postgres/triggers_spec.rb index 54d40ae2..0bcd8c45 100644 --- a/spec/fx/adapters/postgres/triggers_spec.rb +++ b/spec/fx/adapters/postgres/triggers_spec.rb @@ -4,14 +4,14 @@ describe ".all" do it "returns `Trigger` objects" do connection = ActiveRecord::Base.connection - connection.execute <<~EOS + connection.execute <<~SQL CREATE TABLE users ( id int PRIMARY KEY, name varchar(256), upper_name varchar(256) ); - EOS - connection.execute <<~EOS + SQL + connection.execute <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -19,13 +19,13 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS - connection.execute <<~EOS + SQL + connection.execute <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL triggers = Fx::Adapters::Postgres::Triggers.new(connection).all diff --git a/spec/fx/adapters/postgres_spec.rb b/spec/fx/adapters/postgres_spec.rb index f2ffccd9..2e1adae8 100644 --- a/spec/fx/adapters/postgres_spec.rb +++ b/spec/fx/adapters/postgres_spec.rb @@ -5,14 +5,14 @@ it "successfully creates a function" do adapter = Fx::Adapters::Postgres.new adapter.create_function( - <<~EOS + <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL ) expect(adapter.functions.map(&:name)).to include("test") @@ -21,15 +21,15 @@ describe "#create_trigger" do it "successfully creates a trigger" do - connection.execute <<~EOS + connection.execute <<~SQL CREATE TABLE users ( id int PRIMARY KEY, name varchar(256), upper_name varchar(256) ); - EOS + SQL adapter = Fx::Adapters::Postgres.new - adapter.create_function <<~EOS + adapter.create_function <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -37,14 +37,14 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS + SQL adapter.create_trigger( - <<~EOS + <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL ) expect(adapter.triggers.map(&:name)).to include("uppercase_users_name") @@ -56,14 +56,14 @@ it "successfully drops a function with the entire function signature" do adapter = Fx::Adapters::Postgres.new adapter.create_function( - <<~EOS + <<~SQL CREATE FUNCTION adder(x int, y int) RETURNS int AS $$ BEGIN RETURN $1 + $2; END; $$ LANGUAGE plpgsql; - EOS + SQL ) adapter.drop_function(:adder) @@ -76,14 +76,14 @@ it "successfully drops a function" do adapter = Fx::Adapters::Postgres.new adapter.create_function( - <<~EOS + <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL ) adapter.drop_function(:test) @@ -97,14 +97,14 @@ it "finds functions and builds Fx::Function objects" do adapter = Fx::Adapters::Postgres.new adapter.create_function( - <<~EOS + <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL ) expect(adapter.functions.map(&:name)).to eq ["test"] @@ -113,15 +113,15 @@ describe "#triggers" do it "finds triggers and builds Fx::Trigger objects" do - connection.execute <<~EOS + connection.execute <<~SQL CREATE TABLE users ( id int PRIMARY KEY, name varchar(256), upper_name varchar(256) ); - EOS + SQL adapter = Fx::Adapters::Postgres.new - adapter.create_function <<~EOS + adapter.create_function <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -129,13 +129,13 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS - sql_definition = <<~EOS + SQL + sql_definition = <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name() - EOS + SQL adapter.create_trigger(sql_definition) expect(adapter.triggers.map(&:name)).to eq ["uppercase_users_name"] diff --git a/spec/fx/definition_spec.rb b/spec/fx/definition_spec.rb index b53fff22..ab78868c 100644 --- a/spec/fx/definition_spec.rb +++ b/spec/fx/definition_spec.rb @@ -4,14 +4,14 @@ describe "#to_sql" do context "representing a function definition" do it "returns the content of a function definition" do - sql_definition = <<-EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL allow(File).to receive(:read).and_return(sql_definition) definition = Fx::Definition.function(name: "test", version: 1) @@ -33,14 +33,14 @@ context "when definition is at Rails engine" do it "returns the content of a function definition" do - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL engine_path = Rails.root.join("tmp", "engine") FileUtils.mkdir_p(engine_path.join("db", "functions")) File.write(engine_path.join("db", "functions", "custom_test_v01.sql"), sql_definition) @@ -57,12 +57,12 @@ context "representing a trigger definition" do it "returns the content of a trigger definition" do - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE TRIGGER check_update BEFORE UPDATE ON accounts FOR EACH ROW EXECUTE FUNCTION check_account_update(); - EOS + SQL allow(File).to receive(:read).and_return(sql_definition) definition = Fx::Definition.trigger(name: "test", version: 1) diff --git a/spec/fx/schema_dumper_spec.rb b/spec/fx/schema_dumper_spec.rb index cae57972..45a1b6f8 100644 --- a/spec/fx/schema_dumper_spec.rb +++ b/spec/fx/schema_dumper_spec.rb @@ -2,14 +2,14 @@ RSpec.describe Fx::SchemaDumper, :db do it "dumps a create_function for a function in the database" do - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION my_function() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL connection.create_function :my_function, sql_definition: sql_definition connection.create_table :my_table stream = StringIO.new @@ -24,14 +24,14 @@ it "dumps a create_function for a function in the database" do Fx.configuration.dump_functions_at_beginning_of_schema = true - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION my_function() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL connection.create_function :my_function, sql_definition: sql_definition connection.create_table :my_table stream = StringIO.new @@ -47,22 +47,22 @@ end it "does not dump a create_function for aggregates in the database" do - sql_definition = <<~EOS + sql_definition = <<~SQL CREATE OR REPLACE FUNCTION test(text, text) RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; - EOS + SQL - aggregate_sql_definition = <<~EOS + aggregate_sql_definition = <<~SQL CREATE AGGREGATE aggregate_test(text) ( sfunc = test, stype = text ); - EOS + SQL connection.create_function :test, sql_definition: sql_definition connection.execute aggregate_sql_definition @@ -77,14 +77,14 @@ end it "dumps a create_trigger for a trigger in the database" do - connection.execute <<~EOS + connection.execute <<~SQL CREATE TABLE users ( id int PRIMARY KEY, name varchar(256), upper_name varchar(256) ); - EOS - Fx.database.create_function <<~EOS + SQL + Fx.database.create_function <<~SQL CREATE OR REPLACE FUNCTION uppercase_users_name() RETURNS trigger AS $$ BEGIN @@ -92,13 +92,13 @@ RETURN NEW; END; $$ LANGUAGE plpgsql; - EOS - sql_definition = <<~EOS + SQL + sql_definition = <<~SQL CREATE TRIGGER uppercase_users_name BEFORE INSERT ON users FOR EACH ROW EXECUTE FUNCTION uppercase_users_name(); - EOS + SQL connection.create_trigger( :uppercase_users_name, sql_definition: sql_definition @@ -113,58 +113,50 @@ expect(output).to include("EXECUTE FUNCTION uppercase_users_name()") end - context "when there are functions / triggers in multiple schemas" do - before { connection.schema_search_path = "public,test_schema" } - - after { connection.schema_search_path = "public" } - - it "dumps functions and triggers for multiple schemas" do - connection.create_table :my_table - - connection.create_function :test1, sql_definition: <<~EOS - CREATE OR REPLACE FUNCTION test_public_func() - RETURNS TRIGGER AS $$ - BEGIN - RETURN 1; - END; - $$ LANGUAGE plpgsql; - EOS - connection.create_trigger :test1_trigger, sql_definition: <<~EOS - CREATE TRIGGER test_public_trigger - BEFORE INSERT ON my_table - FOR EACH ROW - EXECUTE FUNCTION test_public_func(); - EOS - - connection.execute("CREATE SCHEMA test_schema;") - - connection.create_table "test_schema.my_table2" - - connection.execute <<~EOS - CREATE OR REPLACE FUNCTION test_schema.test_schema_func() - RETURNS TRIGGER AS $$ - BEGIN - RETURN 'test_schema'; - END; - $$ LANGUAGE plpgsql; - EOS - connection.execute <<~EOS - CREATE TRIGGER test_schema_trigger - BEFORE INSERT ON test_schema.my_table2 - FOR EACH ROW - EXECUTE FUNCTION test_schema.test_schema_func(); - EOS - - stream = StringIO.new - dump(connection: connection, stream: stream) - output = stream.string - - expect(output.scan("create_function :test_public_func").size).to eq(1) - expect(output.scan("create_trigger :test_public_trigger").size).to eq(1) - - expect(output.scan("create_function :test_schema_func").size).to eq(1) - expect(output.scan("create_trigger :test_schema_trigger").size).to eq(1) - end + it "dumps functions and triggers for multiple schemas" do + connection.schema_search_path = "public,test_schema" + connection.create_table :my_table + connection.create_function :test1, sql_definition: <<~SQL + CREATE OR REPLACE FUNCTION test_public_func() + RETURNS TRIGGER AS $$ + BEGIN + RETURN 1; + END; + $$ LANGUAGE plpgsql; + SQL + connection.create_trigger :test1_trigger, sql_definition: <<~SQL + CREATE TRIGGER test_public_trigger + BEFORE INSERT ON my_table + FOR EACH ROW + EXECUTE FUNCTION test_public_func(); + SQL + connection.execute("CREATE SCHEMA test_schema;") + connection.create_table "test_schema.my_table2" + connection.execute <<~SQL + CREATE OR REPLACE FUNCTION test_schema.test_schema_func() + RETURNS TRIGGER AS $$ + BEGIN + RETURN 'test_schema'; + END; + $$ LANGUAGE plpgsql; + SQL + connection.execute <<~SQL + CREATE TRIGGER test_schema_trigger + BEFORE INSERT ON test_schema.my_table2 + FOR EACH ROW + EXECUTE FUNCTION test_schema.test_schema_func(); + SQL + stream = StringIO.new + output = stream.string + + dump(connection: connection, stream: stream) + + expect(output.scan("create_function :test_public_func").size).to eq(1) + expect(output.scan("create_trigger :test_public_trigger").size).to eq(1) + expect(output.scan("create_function :test_schema_func").size).to eq(1) + expect(output.scan("create_trigger :test_schema_trigger").size).to eq(1) + + connection.schema_search_path = "public" end def dump(connection:, stream:)