Class: Annotato::CheckConstraintFormatter

Inherits:
Object
  • Object
show all
Extended by:
WrapHelper
Defined in:
lib/annotato/check_constraint_formatter.rb

Constant Summary

Constants included from WrapHelper

WrapHelper::MAX_LINE

Class Method Summary collapse

Methods included from WrapHelper

wrap_sql

Class Method Details

.format(conn, table_name) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/annotato/check_constraint_formatter.rb', line 7

def self.format(conn, table_name)
  conn.check_constraints(table_name).map do |chk|
    expr_clause = ""
    if chk.expression
      expr_clause = "\n" + wrap_sql(chk.expression, first_prefix: "#    (", cont_prefix: "#    ")
    end
    "#  #{chk.name}#{expr_clause}"
  end
end