Skip to content

Commit

Permalink
[SchemaDumper] Hhandle tables without primary keys
Browse files Browse the repository at this point in the history
(AKA:  "The Martin H. Factor: Part 2")

So this should never happen with a Rails generated table, but if you
were to create a table manually like so:

    CREATE TABLE aaa (id serial);

This wouldn't have a PRIMARY KEY associated with it.  However, Rails
always defines a PRIMARY KEY when generating it's tables:

https://github.com/rails/rails/blob/5-2-stable/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L214-L253

So this shouldn't ever actually happen unless you execute custom table
creates.... which apparently some people do...
  • Loading branch information
NickLaMuro committed Sep 29, 2020
1 parent 02007f7 commit b21043b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/manageiq/schema/schema_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def table(table, stream)
def add_id_column_comment(table, stream)
pk = @connection.primary_key(table)
pkcol = @connection.columns(table).detect { |c| c.name == pk }
comment = pkcol.comment
comment = pkcol.try(:comment)

return unless comment

Expand Down

0 comments on commit b21043b

Please sign in to comment.