module Sequel::Database::SQLComments::DatasetSQLComments

Private Instance Methods

_sql_comment() click to toggle source

Include comments added via Database#with_comments in the output SQL.

Calls superclass method Sequel::SQLComments#_sql_comment
# File lib/sequel/extensions/sql_comments.rb, line 175
def _sql_comment
  specific_comment = super
  return specific_comment if @opts[:append_sql]

  t = Sequel.current
  hashes = db.comment_hashes
  block_comment = if comment_hash = Sequel.synchronize{hashes[t]}
    comment_array = comment_hash.map{|k,v| "#{k}:#{v}" unless v.nil?}
    comment_array.compact!
    comment_array.join(",")
  end

  if block_comment
    if specific_comment
      format_sql_comment(block_comment + specific_comment)
    else
      format_sql_comment(block_comment)
    end
  else
    specific_comment
  end
end