Skip to content

Commit 95c5eb7

Browse files
raviks789julianbrost
authored andcommitted
Add anynonarrayliketext function in PostgreSQL to fix numeric value suggestion error
1 parent d4dae02 commit 95c5eb7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

schema/pgsql/schema.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ CREATE TYPE boolenum AS ENUM ( 'n', 'y' );
22
CREATE TYPE incident_history_event_type AS ENUM ( 'source_severity_changed', 'incident_severity_changed', 'recipient_role_changed', 'escalation_triggered', 'rule_matched', 'opened', 'closed', 'notified' );
33
CREATE TYPE frequency_type AS ENUM ( 'MINUTELY', 'HOURLY', 'DAILY', 'WEEKLY', 'MONTHLY', 'QUARTERLY', 'YEARLY' );
44

5+
-- IPL ORM renders SQL queries with LIKE operators for all suggestions in the search bar,
6+
-- which fails for numeric and enum types on PostgreSQL. Just like in Icinga DB Web.
7+
CREATE OR REPLACE FUNCTION anynonarrayliketext(anynonarray, text)
8+
RETURNS bool
9+
LANGUAGE plpgsql
10+
IMMUTABLE
11+
PARALLEL SAFE
12+
AS $$
13+
BEGIN
14+
RETURN $1::TEXT LIKE $2;
15+
END;
16+
$$;
17+
CREATE OPERATOR ~~ (LEFTARG=anynonarray, RIGHTARG=text, PROCEDURE=anynonarrayliketext);
18+
519
CREATE TABLE contact (
620
id bigserial,
721
full_name text NOT NULL,

schema/pgsql/upgrades/013.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- IPL ORM renders SQL queries with LIKE operators for all suggestions in the search bar,
2+
-- which fails for numeric and enum types on PostgreSQL. Just like in Icinga DB Web.
3+
CREATE OR REPLACE FUNCTION anynonarrayliketext(anynonarray, text)
4+
RETURNS bool
5+
LANGUAGE plpgsql
6+
IMMUTABLE
7+
PARALLEL SAFE
8+
AS $$
9+
BEGIN
10+
RETURN $1::TEXT LIKE $2;
11+
END;
12+
$$;
13+
CREATE OPERATOR ~~ (LEFTARG=anynonarray, RIGHTARG=text, PROCEDURE=anynonarrayliketext);

0 commit comments

Comments
 (0)