Module: Sequel::Postgres::Comment::DatasetMethods

Defined in:
lib/sequel/extensions/pg_comment/dataset_methods.rb

Overview

Support for retrieving column comments from a PostgreSQL database via a dataset. For example:

DB[:foo_tbl].comment_for(:some_column)

Will retrieve the comment for foo_tbl.some_column, if such a column exists.

Instance Method Summary collapse

Instance Method Details

#commentString, NilClass

Retrieve the comment for the "primary" table in the dataset.

Examples:

Simple, single-table dataset

db[:foo].comment  # => comment for table foo

Multi-table dataset

db[:foo].join(:bar, ...).where { id < 20 }.comment  # => comment for table foo

Returns:

  • (String, NilClass)

    The comment for the table, or nil if there is no comment defined.



34
35
36
# File 'lib/sequel/extensions/pg_comment/dataset_methods.rb', line 34

def comment
	db.comment_for(first_source_table)
end

#comment_for(col) ⇒ String, NilClass

Retrieve the comment for the column named col in the "primary" table for this dataset.

Parameters:

  • col (#to_s)

    The name of the column for which to retrieve the comment.

Returns:

  • (String, NilClass)

    The comment defined for the column, or nil if there is no defined comment.



19
20
21
# File 'lib/sequel/extensions/pg_comment/dataset_methods.rb', line 19

def comment_for(col)
	db.comment_for("#{first_source_table}__#{col}")
end