Skip to content

Commit

Permalink
Allow schema and table to have the same name (#16)
Browse files Browse the repository at this point in the history
As it was, comments couldn't be added to tables that had the same name as the schema they were in (for instance, calculations.calculations).
Think the only reason not to do this would be if the object type was a SCHEMA, so changed the check to work on that.
  • Loading branch information
BertScholten authored Aug 30, 2022
1 parent a0b0046 commit c0c75a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/CommentCollector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Representation of a parsed comment for a database object
#
class CommentItem
attr_accessor :identifier_noschema, :schema, :arguments, :arguments_nodefault
attr_accessor :identifier_noschema, :schema, :object, :arguments, :arguments_nodefault
attr_accessor :full_comment, :parsed_comment
attr_accessor :params, :columns
attr_accessor :returns, :see, :todo, :file
Expand All @@ -15,7 +15,7 @@ def initialize
end

def identifier
if @schema == '' || @schema == @identifier_noschema then
if @schema == '' || @object == 'SCHEMA' then
@identifier_noschema
else
@schema + '.' + @identifier_noschema
Expand Down Expand Up @@ -160,6 +160,7 @@ def self.fix_wrapping(comment_lines)

def self.create_comment_item(object, identifier, arguments)
comment_item = CommentItem.new
comment_item.object = object
comment_item.identifier_noschema = identifier.include?('.') ? identifier.split('.')[1] : identifier
comment_item.schema = identifier.include?('.') ? identifier.split('.')[0] : ''
comment_item.schema = identifier if object == 'SCHEMA'
Expand Down

0 comments on commit c0c75a8

Please sign in to comment.