Skip to content

Commit

Permalink
Fix Coding style issues (ameba)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yacine Petitprez committed Jun 29, 2018
1 parent deec505 commit a0c133a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions spec/model/model_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand All @@ -347,16 +348,15 @@ 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 }

user_with_a_post_minimum.to_sql.should eq \
"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
Expand Down
13 changes: 6 additions & 7 deletions src/clear/model/modules/is_polymorphic.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]}"
Expand All @@ -92,5 +92,4 @@ module Clear::Model::IsPolymorphic

@@factory = Factory.new({{through}})
end

end
end

0 comments on commit a0c133a

Please sign in to comment.