Skip to content

Commit bd5e555

Browse files
committed
Add lower function to sql query
1 parent 3241a9e commit bd5e555

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/detectify/query_builder/sql.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def build
1313
private
1414

1515
def domain_clause
16-
"#{Detectify.config.domain_column} = ?" if need_domain_clause?
16+
"LOWER(#{Detectify.config.domain_column}) = ?" if need_domain_clause?
1717
end
1818

1919
def subdomain_clause
20-
"#{Detectify.config.subdomain_column} = ?" if need_subdomain_clause?
20+
"LOWER(#{Detectify.config.subdomain_column}) = ?" if need_subdomain_clause?
2121
end
2222

2323
def or_operator

spec/detectify/query_builder/sql_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
let(:domain) { 'example.com' }
1010
let(:subdomain) { nil }
1111

12-
it { is_expected.to eq(['domain = ?', 'example.com']) }
12+
it { is_expected.to eq(['LOWER(domain) = ?', 'example.com']) }
1313
end
1414

1515
context 'with only subdomain' do
1616
let(:domain) { nil }
1717
let(:subdomain) { 'example' }
1818

19-
it { is_expected.to eq(['subdomain = ?', 'example']) }
19+
it { is_expected.to eq(['LOWER(subdomain) = ?', 'example']) }
2020
end
2121

2222
context 'with domain and subdomain' do
@@ -25,7 +25,7 @@
2525

2626
it do
2727
is_expected.to eq([
28-
'domain = ? OR subdomain = ?', 'example.com', 'example'
28+
'LOWER(domain) = ? OR LOWER(subdomain) = ?', 'example.com', 'example'
2929
])
3030
end
3131
end
@@ -38,7 +38,7 @@
3838
let(:domain) { 'example.com' }
3939
let(:subdomain) { nil }
4040

41-
it { is_expected.to eq(['domain = ?', 'example.com']) }
41+
it { is_expected.to eq(['LOWER(domain) = ?', 'example.com']) }
4242
end
4343

4444
context 'with only subdomain' do
@@ -52,7 +52,7 @@
5252
let(:domain) { 'example.com' }
5353
let(:subdomain) { 'example' }
5454

55-
it { is_expected.to eq(['domain = ?', 'example.com']) }
55+
it { is_expected.to eq(['LOWER(domain) = ?', 'example.com']) }
5656
end
5757

5858
after { Detectify.reset_config }
@@ -72,14 +72,14 @@
7272
let(:domain) { nil }
7373
let(:subdomain) { 'example' }
7474

75-
it { is_expected.to eq(['subdomain = ?', 'example']) }
75+
it { is_expected.to eq(['LOWER(subdomain) = ?', 'example']) }
7676
end
7777

7878
context 'with domain and subdomain' do
7979
let(:domain) { 'example.com' }
8080
let(:subdomain) { 'example' }
8181

82-
it { is_expected.to eq(['subdomain = ?', 'example']) }
82+
it { is_expected.to eq(['LOWER(subdomain) = ?', 'example']) }
8383
end
8484

8585
after { Detectify.reset_config }

0 commit comments

Comments
 (0)