From c0c75a84315cf3ac4960364fd5c8af52f1aeb3e2 Mon Sep 17 00:00:00 2001 From: Bert Scholten Date: Tue, 30 Aug 2022 11:02:50 +0200 Subject: [PATCH] Allow schema and table to have the same name (#16) 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. --- bin/CommentCollector.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/CommentCollector.rb b/bin/CommentCollector.rb index c8be021..442343c 100644 --- a/bin/CommentCollector.rb +++ b/bin/CommentCollector.rb @@ -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 @@ -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 @@ -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'