From 65ade5cab85522bf686b6d0f93f9f33dcbf08023 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 7 Oct 2021 16:00:35 -0700 Subject: [PATCH] IO-1428 add ph2 to global search. --- .../global-search/global-search.component.jsx | 2 +- .../1633647205750_run_sql_migration/down.sql | 51 +++++++++++++++++++ .../1633647205750_run_sql_migration/up.sql | 49 ++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 hasura/migrations/1633647205750_run_sql_migration/down.sql create mode 100644 hasura/migrations/1633647205750_run_sql_migration/up.sql diff --git a/client/src/components/global-search/global-search.component.jsx b/client/src/components/global-search/global-search.component.jsx index 6d2d138b0..4135f8dc7 100644 --- a/client/src/components/global-search/global-search.component.jsx +++ b/client/src/components/global-search/global-search.component.jsx @@ -62,7 +62,7 @@ export default function GlobalSearch() { }`, label: ( - }> + } wrap> {`${owner.ownr_fn || ""} ${owner.ownr_ln || ""} ${ owner.ownr_co_nm || "" }`} diff --git a/hasura/migrations/1633647205750_run_sql_migration/down.sql b/hasura/migrations/1633647205750_run_sql_migration/down.sql new file mode 100644 index 000000000..36ca692a7 --- /dev/null +++ b/hasura/migrations/1633647205750_run_sql_migration/down.sql @@ -0,0 +1,51 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- CREATE +-- OR REPLACE FUNCTION public.search_owners (search text) RETURNS SETOF owners LANGUAGE plpgsql STABLE AS $function$ +-- BEGIN +-- IF search = '' +-- THEN +-- RETURN query +-- SELECT +-- * +-- FROM +-- owners; +-- ELSE +-- RETURN query +-- SELECT +-- * +-- FROM +-- owners +-- WHERE +-- ( +-- ownr_fn || ' ' || ownr_ln +-- ) +-- ILIKE '%' || search || '%' +-- OR ownr_ln ILIKE '%' || search || '%' +-- OR ownr_fn ILIKE '%' || search || '%' +-- OR ownr_fn ILIKE '%' || search || '%' +-- OR ownr_co_nm ILIKE '%' || search || '%' +-- OR ownr_ph1 ILIKE '%' || search || '%' +-- OR ownr_ph2 ILIKE '%' || search || '%' +-- OR ownr_addr1 ILIKE '%' || search || '%' +-- ORDER BY +-- (ownr_fn || ' ' || ownr_ln) ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_ln ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_fn ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_co_nm ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_fn ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_ph1 ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_ph2 ILIKE '%' || search || '%' +-- OR NULL, +-- ownr_addr1 ILIKE '%' || search || '%' +-- OR NULL; +-- END +-- IF; +-- END +-- $function$; diff --git a/hasura/migrations/1633647205750_run_sql_migration/up.sql b/hasura/migrations/1633647205750_run_sql_migration/up.sql new file mode 100644 index 000000000..8891a1471 --- /dev/null +++ b/hasura/migrations/1633647205750_run_sql_migration/up.sql @@ -0,0 +1,49 @@ +CREATE +OR REPLACE FUNCTION public.search_owners (search text) RETURNS SETOF owners LANGUAGE plpgsql STABLE AS $function$ +BEGIN + IF search = '' +THEN + RETURN query + SELECT + * + FROM + owners; +ELSE + RETURN query + SELECT + * + FROM + owners + WHERE + ( + ownr_fn || ' ' || ownr_ln + ) + ILIKE '%' || search || '%' + OR ownr_ln ILIKE '%' || search || '%' + OR ownr_fn ILIKE '%' || search || '%' + OR ownr_fn ILIKE '%' || search || '%' + OR ownr_co_nm ILIKE '%' || search || '%' + OR ownr_ph1 ILIKE '%' || search || '%' + OR ownr_ph2 ILIKE '%' || search || '%' + OR ownr_addr1 ILIKE '%' || search || '%' + ORDER BY +(ownr_fn || ' ' || ownr_ln) ILIKE '%' || search || '%' + OR NULL, + ownr_ln ILIKE '%' || search || '%' + OR NULL, + ownr_fn ILIKE '%' || search || '%' + OR NULL, + ownr_co_nm ILIKE '%' || search || '%' + OR NULL, + ownr_fn ILIKE '%' || search || '%' + OR NULL, + ownr_ph1 ILIKE '%' || search || '%' + OR NULL, + ownr_ph2 ILIKE '%' || search || '%' + OR NULL, + ownr_addr1 ILIKE '%' || search || '%' + OR NULL; +END +IF; +END +$function$;