diff --git a/spec/model/model_spec.cr b/spec/model/model_spec.cr index 4e64b344a..3aa4a9dbd 100644 --- a/spec/model/model_spec.cr +++ b/spec/model/model_spec.cr @@ -335,7 +335,8 @@ module ModelSpec reinit u = User.create!({first_name: "Join User"}) - p = Post.create!({title: "A Post", user_id: u.id}) + + Post.create!({title: "A Post", user_id: u.id}) Post.query.join("model_users") { model_posts.user_id == model_users.id }.to_sql .should eq "SELECT model_posts.* FROM model_posts INNER JOIN model_users " + @@ -347,7 +348,7 @@ module ModelSpec temporary do reinit u = User.create!({first_name: "Join User"}) - p = Post.create!({title: "A Post", user_id: u.id}) + Post.create!({title: "A Post", user_id: u.id}) user_with_a_post_minimum = User.query.distinct.join("model_posts") { model_posts.user_id == model_users.id } @@ -355,8 +356,7 @@ module ModelSpec "SELECT DISTINCT model_users.* FROM model_users INNER JOIN " + "model_posts ON ((model_posts.user_id = model_users.id))" - user_with_a_post_minimum.with_posts.each do |u| - end + user_with_a_post_minimum.with_posts.each { } # Should just execute end end end diff --git a/src/clear/model/modules/is_polymorphic.cr b/src/clear/model/modules/is_polymorphic.cr index 910675372..130b533b3 100644 --- a/src/clear/model/modules/is_polymorphic.cr +++ b/src/clear/model/modules/is_polymorphic.cr @@ -6,10 +6,10 @@ module Clear::Model::IsPolymorphic end abstract class Factory - abstract def build(h : Hash(String, ::Clear::SQL::Any ), - cache : Clear::Model::QueryCache? = nil, - persisted = false, - fetch_columns = false ) : Clear::Model + abstract def build(h : Hash(String, ::Clear::SQL::Any), + cache : Clear::Model::QueryCache? = nil, + persisted = false, + fetch_columns = false) : Clear::Model end macro included @@ -82,7 +82,7 @@ module Clear::Model::IsPolymorphic when {{c.id}}.name {{c.id}}.new(h, cache, persisted, fetch_columns) {% end %} - when Nil + when nil raise "No data in column #{@through}, impossible to instantiate !" else raise "Unknown class: #{h[@through]}" @@ -92,5 +92,4 @@ module Clear::Model::IsPolymorphic @@factory = Factory.new({{through}}) end - -end \ No newline at end of file +end