1 |
commit: 39d9a91b76cbb5e2ea893875373368df6433febe |
2 |
Author: Hans de Graaff <graaff <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Mar 22 09:31:46 2018 +0000 |
4 |
Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Mar 22 09:32:11 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=39d9a91b |
7 |
|
8 |
dev-ruby/database_cleaner: backport upstream fix for table name quoting |
9 |
|
10 |
Package-Manager: Portage-2.3.24, Repoman-2.3.6 |
11 |
|
12 |
.../database_cleaner-1.6.2-r1.ebuild | 26 +++++++++++++++ |
13 |
.../files/database_cleaner-1.6.2-table-quote.patch | 37 ++++++++++++++++++++++ |
14 |
2 files changed, 63 insertions(+) |
15 |
|
16 |
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 |
17 |
new file mode 100644 |
18 |
index 00000000000..6a4f09e7b5f |
19 |
--- /dev/null |
20 |
+++ b/dev-ruby/database_cleaner/database_cleaner-1.6.2-r1.ebuild |
21 |
@@ -0,0 +1,26 @@ |
22 |
+# Copyright 1999-2018 Gentoo Foundation |
23 |
+# Distributed under the terms of the GNU General Public License v2 |
24 |
+ |
25 |
+EAPI=6 |
26 |
+ |
27 |
+USE_RUBY="ruby22 ruby23 ruby24 ruby25" |
28 |
+ |
29 |
+RUBY_FAKEGEM_RECIPE_DOC="rdoc" |
30 |
+RUBY_FAKEGEM_TASK_DOC="examples" |
31 |
+ |
32 |
+RUBY_FAKEGEM_EXTRADOC="History.rdoc README.markdown TODO" |
33 |
+ |
34 |
+# There are specs and features but they all require configured databases. |
35 |
+RUBY_FAKEGEM_RECIPE_TEST="none" |
36 |
+ |
37 |
+inherit ruby-fakegem |
38 |
+ |
39 |
+DESCRIPTION="Strategies for cleaning databases" |
40 |
+HOMEPAGE="https://github.com/bmabey/database_cleaner" |
41 |
+ |
42 |
+LICENSE="MIT" |
43 |
+SLOT="0" |
44 |
+KEYWORDS="~amd64 ~arm ~x86" |
45 |
+IUSE="" |
46 |
+ |
47 |
+PATCHES=( "${FILESDIR}/${P}-table-quote.patch" ) |
48 |
|
49 |
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 |
50 |
new file mode 100644 |
51 |
index 00000000000..2ca8c978124 |
52 |
--- /dev/null |
53 |
+++ b/dev-ruby/database_cleaner/files/database_cleaner-1.6.2-table-quote.patch |
54 |
@@ -0,0 +1,37 @@ |
55 |
+From 94f3c412b154100e53b0800622a503ee56e39a6d Mon Sep 17 00:00:00 2001 |
56 |
+From: =?UTF-8?q?Andreas=20B=C3=BChmann?= <dev@××××.de> |
57 |
+Date: Sun, 27 Aug 2017 09:24:41 +0200 |
58 |
+Subject: [PATCH] Properly quote table names in table_stats_query |
59 |
+ |
60 |
+--- |
61 |
+ lib/database_cleaner/active_record/deletion.rb | 16 +++++++++------- |
62 |
+ 1 file changed, 9 insertions(+), 7 deletions(-) |
63 |
+ |
64 |
+diff --git a/lib/database_cleaner/active_record/deletion.rb b/lib/database_cleaner/active_record/deletion.rb |
65 |
+index 59a41c4..d172355 100644 |
66 |
+--- a/lib/database_cleaner/active_record/deletion.rb |
67 |
++++ b/lib/database_cleaner/active_record/deletion.rb |
68 |
+@@ -66,14 +66,16 @@ def table_stats_query(connection, db_name) |
69 |
+ if @cache_tables && !@table_stats_query.nil? |
70 |
+ return @table_stats_query |
71 |
+ else |
72 |
+- @table_stats_query = connection.select_values(<<-SQL).join(' UNION ') |
73 |
+- SELECT CONCAT('SELECT \"', table_name, '\" AS table_name, COUNT(*) AS exact_row_count FROM ', table_name) |
74 |
+- FROM |
75 |
+- INFORMATION_SCHEMA.TABLES |
76 |
+- WHERE |
77 |
+- table_schema = '#{db_name}' |
78 |
+- AND #{::DatabaseCleaner::ActiveRecord::Base.exclusion_condition('table_name')}; |
79 |
++ tables = connection.select_values(<<-SQL) |
80 |
++ SELECT table_name |
81 |
++ FROM information_schema.tables |
82 |
++ WHERE table_schema = '#{db_name}' |
83 |
++ AND #{::DatabaseCleaner::ActiveRecord::Base.exclusion_condition('table_name')}; |
84 |
+ SQL |
85 |
++ queries = tables.map do |table| |
86 |
++ "SELECT #{connection.quote(table)} AS table_name, COUNT(*) AS exact_row_count FROM #{connection.quote_table_name(table)}" |
87 |
++ end |
88 |
++ @table_stats_query = queries.join(' UNION ') |
89 |
+ end |
90 |
+ end |
91 |
+ |