From 4070cbde22fe8cd2c43c88aad4e1b75d70ae43af Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Thu, 22 Oct 2015 13:05:25 -0600 Subject: [PATCH] fix finding tables for spec truncation refs CNVS-23621 Change-Id: I19218b4453d772f20e22767564622e131387e918 Reviewed-on: https://gerrit.instructure.com/65662 Reviewed-by: Jacob Fugal Tested-by: Jenkins Product-Review: Cody Cutrer QA-Review: Cody Cutrer --- spec/spec_helper.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c1fd397e6fe..df26a2602d9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -252,12 +252,14 @@ def truncate_all_tables model_connections.each do |connection| if connection.adapter_name == "PostgreSQL" # use custom SQL to exclude tables from extensions + schema = connection.shard.name if connection.instance_variable_get(:@config)[:use_qualified_names] table_names = connection.query(<<-SQL, 'SCHEMA').map(&:first) SELECT tablename FROM pg_tables - WHERE schemaname = ANY (current_schemas(false)) AND NOT tablename IN ( - SELECT CAST(objid::regclass AS VARCHAR) FROM pg_depend WHERE deptype='e' - ) + WHERE schemaname = #{schema ? "'#{schema}'" : 'ANY (current_schemas(false))'} + AND NOT tablename IN ( + SELECT CAST(objid::regclass AS VARCHAR) FROM pg_depend WHERE deptype='e' + ) SQL table_names.delete('schema_migrations') connection.execute("TRUNCATE TABLE #{table_names.map { |t| connection.quote_table_name(t) }.join(',')}")