mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-08-05 12:38:09 -07:00
dev-ruby/database_cleaner: backport upstream fix for table name quoting
Package-Manager: Portage-2.3.24, Repoman-2.3.6
This commit is contained in:
26
dev-ruby/database_cleaner/database_cleaner-1.6.2-r1.ebuild
Normal file
26
dev-ruby/database_cleaner/database_cleaner-1.6.2-r1.ebuild
Normal file
@@ -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" )
|
||||
@@ -0,0 +1,37 @@
|
||||
From 94f3c412b154100e53b0800622a503ee56e39a6d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20B=C3=BChmann?= <dev@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
|
||||
|
||||
Reference in New Issue
Block a user