[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Additional "in" operator for fields being lists of strings
From: |
Marcin Szewczyk |
Subject: |
Additional "in" operator for fields being lists of strings |
Date: |
Thu, 30 Jul 2020 19:30:34 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Hi,
I would like to propose an additional "in" operator which would treat
field's string value as a space-separated list and check if the
specified token is present.
I know that fully normalized relational databases would look like this:
Device: plumbus
Tag: dinglebop
Tag: fleeb
Tag: plubus
Tag: grumbo
But it might be quicker to use when constructed in the following manner:
Device: plumbus
Tags: dinglebop fleeb plubus grumbo
Relational databases support non-scalar types like arrays[1], XML or
JSON. AFAIK arrays are used for performance reasons to save on JOINs.
Here I propose the operator just as a usability enhancement.
The '"fleeb" in Tags' expression seems a bit more expressive and
straightforward than similarly working 'Tag ~ "\bfleeb\b"' or 'Tag ~
"\<fleeb\>"'.
Furthermore, the array structure makes it easy to select records with
fields containing two specified values at the same time. Without an
array it seems to require piping two `recsel` processes[2]. With an
array and the "in" operator one could write:
'"fleeb" in Tags && "grumbo" in Tags'
Proposed patch attached.
[1]: https://www.postgresql.org/docs/current/arrays.html
[2]: https://lists.gnu.org/archive/html/bug-recutils/2017-04/msg00001.html
--
Marcin Szewczyk
http://wodny.org
0001-add-the-in-operator.patch
Description: Text Data
- Additional "in" operator for fields being lists of strings,
Marcin Szewczyk <=