Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11055 (new defect)

Opened 3 months ago

PostgresqlAdapter#tables does not support views

Reported by: cfis Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

In our system, we sometimes use Postgresql views as the table for a Rails model. However, the method PostgresqlAdapter#tables does not support this because it only queries table names.

Right now the method only queries table names:

SELECT tablename FROM pg_tables WHERE schemaname IN (#{schemas})

Its easy to also add in view names like this:

SELECT tablename FROM pg_tables WHERE schemaname IN (#{schemas})

UNION ALL SELECT viewname FROM pg_views WHERE schemaname IN (#{schemas})