mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove #tables
extra args again
This issue was resolved by #21687 already. But re-add args by #18856. `#tables` extra args was only using by `#table_exists?`. This is for internal API. This commit will remove these extra args again.
This commit is contained in:
parent
d8b076c90e
commit
edfb738b9c
4 changed files with 14 additions and 24 deletions
|
@ -482,16 +482,11 @@ module ActiveRecord
|
|||
show_variable 'collation_database'
|
||||
end
|
||||
|
||||
def tables(name = nil, database = nil, like = nil) #:nodoc:
|
||||
database ||= current_database
|
||||
|
||||
def tables(name = nil) # :nodoc:
|
||||
sql = "SELECT table_name FROM information_schema.tables "
|
||||
sql << "WHERE table_schema = #{quote(database)}"
|
||||
sql << " AND table_name = #{quote(like)}" if like
|
||||
sql << "WHERE table_schema = #{quote(@config[:database])}"
|
||||
|
||||
execute_and_free(sql, 'SCHEMA') do |result|
|
||||
result.collect(&:first)
|
||||
end
|
||||
select_values(sql, 'SCHEMA')
|
||||
end
|
||||
alias data_sources tables
|
||||
|
||||
|
|
|
@ -311,22 +311,18 @@ module ActiveRecord
|
|||
|
||||
# SCHEMA STATEMENTS ========================================
|
||||
|
||||
def tables(name = nil, table_name = nil) #:nodoc:
|
||||
sql = <<-SQL
|
||||
SELECT name
|
||||
FROM sqlite_master
|
||||
WHERE (type = 'table' OR type = 'view') AND NOT name = 'sqlite_sequence'
|
||||
SQL
|
||||
sql << " AND name = #{quote_table_name(table_name)}" if table_name
|
||||
|
||||
exec_query(sql, 'SCHEMA').map do |row|
|
||||
row['name']
|
||||
end
|
||||
def tables(name = nil) # :nodoc:
|
||||
select_values("SELECT name FROM sqlite_master WHERE type IN ('table','view') AND name <> 'sqlite_sequence'", 'SCHEMA')
|
||||
end
|
||||
alias data_sources tables
|
||||
|
||||
def table_exists?(table_name)
|
||||
table_name && tables(nil, table_name).any?
|
||||
return false unless table_name.present?
|
||||
|
||||
sql = "SELECT name FROM sqlite_master WHERE type IN ('table','view') AND name <> 'sqlite_sequence'"
|
||||
sql << " AND name = #{quote(table_name)}"
|
||||
|
||||
select_values(sql, 'SCHEMA').any?
|
||||
end
|
||||
alias data_source_exists? table_exists?
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ module ActiveRecord
|
|||
def test_tables_logs_name
|
||||
sql = <<-SQL
|
||||
SELECT name FROM sqlite_master
|
||||
WHERE (type = 'table' OR type = 'view') AND NOT name = 'sqlite_sequence'
|
||||
WHERE type IN ('table','view') AND name <> 'sqlite_sequence'
|
||||
SQL
|
||||
assert_logged [[sql.squish, 'SCHEMA', []]] do
|
||||
@conn.tables('hello')
|
||||
|
@ -313,8 +313,7 @@ module ActiveRecord
|
|||
with_example_table do
|
||||
sql = <<-SQL
|
||||
SELECT name FROM sqlite_master
|
||||
WHERE (type = 'table' OR type = 'view')
|
||||
AND NOT name = 'sqlite_sequence' AND name = \"ex\"
|
||||
WHERE type IN ('table','view') AND name <> 'sqlite_sequence' AND name = 'ex'
|
||||
SQL
|
||||
assert_logged [[sql.squish, 'SCHEMA', []]] do
|
||||
assert @conn.table_exists?('ex')
|
||||
|
|
|
@ -103,7 +103,7 @@ module ActiveRecord
|
|||
# ignored SQL, or better yet, use a different notification for the queries
|
||||
# instead examining the SQL content.
|
||||
oracle_ignored = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im, /^\s*select .* from all_constraints/im, /^\s*select .* from all_tab_cols/im]
|
||||
mysql_ignored = [/^SHOW FULL TABLES/i, /^SHOW FULL FIELDS/, /^SHOW CREATE TABLE /i, /^SHOW VARIABLES /, /^SELECT DATABASE\(\) as db$/, /^\s*SELECT (?:column_name|table_name)\b.*\bFROM information_schema\.(?:key_column_usage|tables)\b/im]
|
||||
mysql_ignored = [/^SHOW FULL TABLES/i, /^SHOW FULL FIELDS/, /^SHOW CREATE TABLE /i, /^SHOW VARIABLES /, /^\s*SELECT (?:column_name|table_name)\b.*\bFROM information_schema\.(?:key_column_usage|tables)\b/im]
|
||||
postgresql_ignored = [/^\s*select\b.*\bfrom\b.*pg_namespace\b/im, /^\s*select tablename\b.*from pg_tables\b/im, /^\s*select\b.*\battname\b.*\bfrom\b.*\bpg_attribute\b/im, /^SHOW search_path/i]
|
||||
sqlite3_ignored = [/^\s*SELECT name\b.*\bFROM sqlite_master/im, /^\s*SELECT sql\b.*\bFROM sqlite_master/im]
|
||||
|
||||
|
|
Loading…
Reference in a new issue