Skip to content

Commit

Permalink
Fix types around Adapter#where
Browse files Browse the repository at this point in the history
  • Loading branch information
waterlink committed Jan 1, 2017
1 parent a079bd6 commit ddfe56b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/adapter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module ActiveRecord
abstract def create(fields)
abstract def get(id)
abstract def all
abstract def where(query_hash : Hash)
abstract def where(query_hash : Hash(K, V)) forall K, V
abstract def where(query : ::Query::Query)
abstract def update(id, fields)
abstract def delete(id)
Expand Down
10 changes: 2 additions & 8 deletions src/model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,9 @@ module ActiveRecord
end

macro query_level(level)
{{level.id}} def self.where(query_hash)
{{level.id}} def self.where(query)
pool.connection do |adapter|
adapter.where(query_hash).map { |fields| new(fields) }
end
end

{{level.id}} def self.where(query, params)
pool.connection do |adapter|
adapter.where(query, params).map { |fields| new(fields) }
adapter.where(query).map { |fields| new(fields) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/null_adapter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module ActiveRecord
_where(query.query, query.params)
end

def where(query_hash)
def where(query_hash : Hash(K, V)) forall K, V
result = [] of Fields

records.each_index do |index|
Expand Down

0 comments on commit ddfe56b

Please sign in to comment.