commit:     39d9a91b76cbb5e2ea893875373368df6433febe
Author:     Hans de Graaff <graaff <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 22 09:31:46 2018 +0000
Commit:     Hans de Graaff <graaff <AT> gentoo <DOT> org>
CommitDate: Thu Mar 22 09:32:11 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=39d9a91b

dev-ruby/database_cleaner: backport upstream fix for table name quoting

Package-Manager: Portage-2.3.24, Repoman-2.3.6

 .../database_cleaner-1.6.2-r1.ebuild               | 26 +++++++++++++++
 .../files/database_cleaner-1.6.2-table-quote.patch | 37 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)

diff --git a/dev-ruby/database_cleaner/database_cleaner-1.6.2-r1.ebuild 
b/dev-ruby/database_cleaner/database_cleaner-1.6.2-r1.ebuild
new file mode 100644
index 00000000000..6a4f09e7b5f
--- /dev/null
+++ b/dev-ruby/database_cleaner/database_cleaner-1.6.2-r1.ebuild
@@ -0,0 +1,26 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+USE_RUBY="ruby22 ruby23 ruby24 ruby25"
+
+RUBY_FAKEGEM_RECIPE_DOC="rdoc"
+RUBY_FAKEGEM_TASK_DOC="examples"
+
+RUBY_FAKEGEM_EXTRADOC="History.rdoc README.markdown TODO"
+
+# There are specs and features but they all require configured databases.
+RUBY_FAKEGEM_RECIPE_TEST="none"
+
+inherit ruby-fakegem
+
+DESCRIPTION="Strategies for cleaning databases"
+HOMEPAGE="https://github.com/bmabey/database_cleaner";
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~x86"
+IUSE=""
+
+PATCHES=( "${FILESDIR}/${P}-table-quote.patch" )

diff --git 
a/dev-ruby/database_cleaner/files/database_cleaner-1.6.2-table-quote.patch 
b/dev-ruby/database_cleaner/files/database_cleaner-1.6.2-table-quote.patch
new file mode 100644
index 00000000000..2ca8c978124
--- /dev/null
+++ b/dev-ruby/database_cleaner/files/database_cleaner-1.6.2-table-quote.patch
@@ -0,0 +1,37 @@
+From 94f3c412b154100e53b0800622a503ee56e39a6d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20B=C3=BChmann?= <d...@uuml.de>
+Date: Sun, 27 Aug 2017 09:24:41 +0200
+Subject: [PATCH] Properly quote table names in table_stats_query
+
+---
+ lib/database_cleaner/active_record/deletion.rb | 16 +++++++++-------
+ 1 file changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/lib/database_cleaner/active_record/deletion.rb 
b/lib/database_cleaner/active_record/deletion.rb
+index 59a41c4..d172355 100644
+--- a/lib/database_cleaner/active_record/deletion.rb
++++ b/lib/database_cleaner/active_record/deletion.rb
+@@ -66,14 +66,16 @@ def table_stats_query(connection, db_name)
+       if @cache_tables && !@table_stats_query.nil?
+         return @table_stats_query
+       else
+-        @table_stats_query = connection.select_values(<<-SQL).join(' UNION ')
+-               SELECT CONCAT('SELECT \"', table_name, '\" AS table_name, 
COUNT(*) AS exact_row_count FROM ', table_name)
+-               FROM
+-               INFORMATION_SCHEMA.TABLES
+-               WHERE
+-               table_schema = '#{db_name}'
+-               AND 
#{::DatabaseCleaner::ActiveRecord::Base.exclusion_condition('table_name')};
++        tables = connection.select_values(<<-SQL)
++          SELECT table_name
++          FROM information_schema.tables
++          WHERE table_schema = '#{db_name}'
++          AND 
#{::DatabaseCleaner::ActiveRecord::Base.exclusion_condition('table_name')};
+         SQL
++        queries = tables.map do |table|
++          "SELECT #{connection.quote(table)} AS table_name, COUNT(*) AS 
exact_row_count FROM #{connection.quote_table_name(table)}"
++        end
++        @table_stats_query = queries.join(' UNION ')
+       end
+     end
+ 

Reply via email to