Module: ActiveRecord::Comments::ConnectionAdapters::PostgreSQLAdapter

Defined in:
lib/active_record/comments/connection_adapters/postgresql_adapter.rb

Instance Method Summary collapse

Instance Method Details

#comment_sql(comment_definition) ⇒ Object



30
31
32
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 30

def comment_sql(comment_definition)
  "COMMENT ON #{comment_target(comment_definition)} IS #{escaped_comment(comment_definition.comment_text)}"
end

#comments_supported?Boolean



3
4
5
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 3

def comments_supported?
  true
end

#independent_comments?Boolean



7
8
9
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 7

def independent_comments?
  true
end

#retrieve_column_comments(table_name, *column_names) ⇒ Object



24
25
26
27
28
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 24

def retrieve_column_comments(table_name, *column_names)
  result = select_rows(column_comment_sql(table_name, *column_names))
  return {} if result.nil?
  return result.inject({}){|m, row| m[row[0].to_sym] = row[1]; m}
end

#retrieve_table_comment(table_name) ⇒ Object



19
20
21
22
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 19

def retrieve_table_comment(table_name)
  result = select_rows(table_comment_sql(table_name))
  result[0].nil? ? nil : result[0][0]
end

#set_column_comment(table_name, column_name, comment_text) ⇒ Object



15
16
17
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 15

def set_column_comment(table_name, column_name, comment_text)
  execute CommentDefinition.new(self, table_name, column_name, comment_text).to_sql
end

#set_table_comment(table_name, comment_text) ⇒ Object



11
12
13
# File 'lib/active_record/comments/connection_adapters/postgresql_adapter.rb', line 11

def set_table_comment(table_name, comment_text)
  execute CommentDefinition.new(self, table_name, nil, comment_text).to_sql
end