Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Only NOT NULL for unique constraint columns on DB2, not foreign key c…
…olumns

Foreign key columns are allowed to be NULL, but unique columns
are not.  The previous code was plan wrong, but wasn't caught
before as the foreign key tests and the unique tests were combined.
  • Loading branch information
jeremyevans committed Sep 20, 2012
1 parent dd0e21a commit 6dd09de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sequel/adapters/shared/db2.rb
Expand Up @@ -123,10 +123,10 @@ def column_definition_null_sql(sql, column)
end

# Supply columns with NOT NULL if they are part of a composite
# primary/foreign key
# primary key or unique constraint
def column_list_sql(g)
ks = []
g.constraints.each{|c| ks = c[:columns] if [:primary_key, :foreign_key].include? c[:type]}
g.constraints.each{|c| ks = c[:columns] if [:primary_key, :unique].include?(c[:type])}
g.columns.each{|c| c[:null] = false if ks.include?(c[:name]) }
super
end
Expand Down

0 comments on commit 6dd09de

Please sign in to comment.