Skip to content

Commit

Permalink
feat: Repository's #prepare_query & #prepare_params are public
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfaust committed Sep 29, 2017
1 parent 39ad324 commit 8b73b43
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/repository.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class Core::Repository(ModelType)
end
end

# Prepare *query* for execution.
private def prepare_query(query : String) : String
# Prepare *query* for execution. Replaces "?" with "$i" for PostgreSQL.
def prepare_query(query : String) : String
if db.driver.is_a?(PG::Driver)
counter = 0
query = query.as(String).gsub("?") { "$" + (counter += 1).to_s }
Expand All @@ -170,7 +170,8 @@ class Core::Repository(ModelType)
query
end

private def prepare_params(*params)
# Prepare query params. Replaces `::Enum`'s with their values.
def prepare_params(*params)
params.map do |a|
a.map do |p|
if p.is_a?(Enum)
Expand Down

0 comments on commit 8b73b43

Please sign in to comment.