Skip to content

Commit

Permalink
Fix missing_non_null_constraint when there are no STI children for …
Browse files Browse the repository at this point in the history
…STI-like parent
  • Loading branch information
fatkodima committed Jun 7, 2023
1 parent 8ca2e23 commit dca8fb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def detect
model.abstract_class? || sti_base_model?(model)
end

# There are no STI child models.
concrete_models = models if concrete_models.empty?

connection.columns(table).each do |column|
next if config(:ignore_columns).include?("#{table}.#{column.name}")
next if !column.null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ def test_optional_columns_validated_by_some_non_sti_models_are_allowed
refute_problems
end

def test_optional_columns_validated_by_sti_parent_without_child_is_allowed
create_table(:users) do |t|
t.string :type
end.define_model

refute_problems
end

def test_not_null_check_constraint
skip unless postgresql?

Expand Down

0 comments on commit dca8fb3

Please sign in to comment.