instance method
table_exists?
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v3.2.22.5Signature
table_exists?(name)
No documentation comment.
Parameters
-
namereq
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 737
def table_exists?(name)
schema, table = extract_schema_and_table(name.to_s)
return false unless table # Abstract classes is having nil table name
binds = [[nil, table.gsub(/(^"|"$)/,'')]]
binds << [nil, schema] if schema
exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
SELECT COUNT(*)
FROM pg_tables
WHERE tablename = $1
AND schemaname = #{schema ? "$2" : "ANY (current_schemas(false))"}
SQL
end
Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 737
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter