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

Ticket #8659: postgresql_adapter.patch

File postgresql_adapter.patch, 1.1 kB (added by jean.helou, 1 year ago)

Patch for postresql_adapter.rb and schema_test_postgresql.rb

  • postgresql_adapter.rb

    old new  
    195195      end 
    196196 
    197197      def indexes(table_name, name = nil) #:nodoc: 
    198         result = query(<<-SQL, name) 
    199           SELECT i.relname, d.indisunique, a.attname 
    200             FROM pg_class t, pg_class i, pg_index d, pg_attribute a 
     198        schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',') 
     199        result = query(<<-SQL, name) 
     200          SELECT distinct i.relname, d.indisunique, a.attname, s.schemaname 
     201            FROM pg_class t, pg_class i, pg_index d, pg_attribute a, pg_tables s 
    201202           WHERE i.relkind = 'i' 
    202203             AND d.indexrelid = i.oid 
    203204             AND d.indisprimary = 'f' 
    204205             AND t.oid = d.indrelid 
    205206             AND t.relname = '#{table_name}' 
     207             AND t.relname = s.tablename 
     208             AND s.schemaname in (#{schemas}) 
    206209             AND a.attrelid = t.oid 
    207210             AND ( d.indkey[0]=a.attnum OR d.indkey[1]=a.attnum 
    208211                OR d.indkey[2]=a.attnum OR d.indkey[3]=a.attnum