Skip to content

Commit e93966b

Browse files
authored
Merge pull request #13 from nyaruka/pg_10
🔶 Update Postgresql to 10.6 on Travis
2 parents 2930929 + f57fbc3 commit e93966b

File tree

4 files changed

+40
-33
lines changed

4 files changed

+40
-33
lines changed

Diff for: .travis.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
language: go
22

33
addons:
4-
postgresql: '9.6'
4+
postgresql: '10'
5+
apt:
6+
packages:
7+
- postgresql-10
8+
- postgresql-client-10
59

610
go:
711
- "1.10"
812

913
before_install:
1014
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.deb && sudo dpkg -i --force-confnew elasticsearch-6.2.3.deb
1115
- sudo service elasticsearch start
16+
- sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
17+
- sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/10/main/postgresql.conf
18+
- sudo service postgresql restart 10
1219
- sleep 10
1320

1421
before_script:

Diff for: indexer.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -357,34 +357,34 @@ SELECT org_id, id, modified_on, is_active, row_to_json(t) FROM (
357357
(
358358
SELECT jsonb_agg(f.value)
359359
FROM (
360-
select case
361-
when value ? 'ward'
362-
then jsonb_build_object(
363-
'ward_keyword', (regexp_matches(value ->> 'ward', '(.* > )?([^>]+)'))[2]
364-
)
365-
else '{}' :: jsonb
366-
end || district_value.value as value
367-
FROM (
368-
select case
369-
when value ? 'district'
370-
then jsonb_build_object(
371-
'district_keyword', (regexp_matches(value ->> 'district', '(.* > )?([^>]+)'))[2]
372-
)
373-
else '{}' :: jsonb
374-
end || state_value.value as value
375-
FROM (
376-
377-
select case
378-
when value ? 'state'
379-
then jsonb_build_object(
380-
'state_keyword', (regexp_matches(value ->> 'state', '(.* > )?([^>]+)'))[2]
381-
)
382-
else '{}' :: jsonb
383-
end ||
384-
jsonb_build_object('field', key) || value as value
385-
from jsonb_each(contacts_contact.fields)
386-
) state_value
387-
) as district_value
360+
select case
361+
when value ? 'ward'
362+
then jsonb_build_object(
363+
'ward_keyword', trim(substring(value ->> 'ward' from '(?!.* > )([\w ]+)'))
364+
)
365+
else '{}' :: jsonb
366+
end || district_value.value as value
367+
FROM (
368+
select case
369+
when value ? 'district'
370+
then jsonb_build_object(
371+
'district_keyword', trim(substring(value ->> 'district' from '(?!.* > )([\w ]+)'))
372+
)
373+
else '{}' :: jsonb
374+
end || state_value.value as value
375+
FROM (
376+
377+
select case
378+
when value ? 'state'
379+
then jsonb_build_object(
380+
'state_keyword', trim(substring(value ->> 'state' from '(?!.* > )([\w ]+)'))
381+
)
382+
else '{}' :: jsonb
383+
end ||
384+
jsonb_build_object('field', key) || value as value
385+
from jsonb_each(contacts_contact.fields)
386+
) state_value
387+
) as district_value
388388
) as f
389389
) as fields,
390390
(

Diff for: indexer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ func TestIndexing(t *testing.T) {
190190
// phrase matches all
191191
query = elastic.NewNestedQuery("fields", elastic.NewBoolQuery().Must(
192192
elastic.NewMatchQuery("fields.field", "fcab2439-861c-4832-aa54-0c97f38f24ab"),
193-
elastic.NewMatchPhraseQuery("fields.district", "King County")))
193+
elastic.NewMatchPhraseQuery("fields.district", "King Côunty")))
194194
assertQuery(t, client, physicalName, query, []int64{8})
195195

196196
query = elastic.NewNestedQuery("fields", elastic.NewBoolQuery().Must(
197197
elastic.NewMatchQuery("fields.field", "fcab2439-861c-4832-aa54-0c97f38f24ab"),
198-
elastic.NewMatchQuery("fields.district_keyword", "King County")))
198+
elastic.NewMatchQuery("fields.district_keyword", "King Côunty")))
199199
assertQuery(t, client, physicalName, query, []int64{8})
200200

201201
// ward query

Diff for: testdb.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ INSERT INTO contacts_contact(id, is_active, created_by_id, created_on, modified_
103103
(7, TRUE, -1, '2017-11-10 21:11:59.890662+00', -1, '2017-11-10 21:11:59.890662+00', 2, FALSE, 'Joanne Stone', FALSE, NULL, '7051dff0-0a27-49d7-af1f-4494239139e6', FALSE,
104104
'{ "22d11697-edba-4186-b084-793e3b876379": { "text": "USA > Colorado", "state": "USA > Colorado"} }'),
105105
(8, TRUE, -1, '2015-03-27 13:39:43.995812+00', -1, '2015-03-27 13:39:43.995812+00', 2, FALSE, NULL, FALSE, NULL, 'b46f6e18-95b4-4984-9926-dded047f4eb3', FALSE,
106-
'{ "fcab2439-861c-4832-aa54-0c97f38f24ab": { "text": "USA > Washington > King County", "district": "USA > Washington > King County"} }'),
106+
'{ "fcab2439-861c-4832-aa54-0c97f38f24ab": { "text": "USA > Washington > King Côunty", "district": "USA > Washington > King Côunty"} }'),
107107
(9, TRUE, -1, '2017-11-10 21:11:59.890662+00', -1, '2017-11-10 21:11:59.890662+00', 2, FALSE, NULL, FALSE, NULL, '9195c8b7-6138-4d84-ac56-5192cc3d8ceb', FALSE,
108-
'{ "a551ade4-e5a0-4d83-b185-53b515ad2f2a": { "text": "USA > Washington > King County > Central District", "ward": "USA > Washington > King County > Central District"} }'),
108+
'{ "a551ade4-e5a0-4d83-b185-53b515ad2f2a": { "text": "USA > Washington > King Côunty > Central District", "ward": "USA > Washington > King Côunty > Central District"} }'),
109109
(10, TRUE, -1, '2016-08-22 14:20:05.690311+00', -1, '2016-08-22 14:20:05.690311+00', 2, FALSE, NULL, FALSE, NULL, '2b8bd28d-43e0-4c34-a4bb-0f10b11fdb8a', FALSE,
110110
'{ "fcab2439-861c-4832-aa54-0c97f38f24ab": { "text": "USA > Colorado > King", "district": "USA > Colorado > King"} }');
111111

0 commit comments

Comments
 (0)