Skip to content

Commit

Permalink
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/pact_broker/repositories/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
Sequel.extension :escaped_like

module PactBroker
module Repositories
module Helpers

extend self

def name_like column_name, value
Sequel.like(column_name, value, case_sensitivity_options)
end

def case_sensitivity_options
{case_insensitive: !PactBroker.configuration.use_case_sensitive_resource_names}
if PactBroker.configuration.use_case_sensitive_resource_names
if mysql?
# sigh, mysql, this is the only way to perform a case sensitive search
Sequel.escaped_like(column_name, value)
else
{ column_name => value }
end
else
{ Sequel.function(:lower, column_name) => value.downcase }
end
end

def order_ignore_case column_name = :name

0 comments on commit 0a6c7dd

Please sign in to comment.