Kexi/Junior Jobs/Add support for "NOT LIKE" SQL operator

From KDE Community Wiki
Revision as of 20:52, 14 March 2014 by Jstaniek (talk | contribs) (Created page with "'''Status: ASSIGNED to Radoslaw Wicik <[email protected]>''', '''Target: 2.8.2''', Difficulty: MEDIUM Proposed and mentored by ~~~~ __TOC__ ==The Goal== Implement "NOT LIKE"...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Status: ASSIGNED to Radoslaw Wicik <[email protected]>, Target: 2.8.2, Difficulty: MEDIUM

Proposed and mentored by Jstaniek (talk) 20:52, 14 March 2014 (UTC)

The Goal

Implement "NOT LIKE" SQL operator for queries.

Rationale

"NOT LIKE" operator is a part of SQL92 standard supported by Kexi's database backends. Without it users forced to use constructions such as NOT (a LIKE '%foo%' OR b LIKE '%bar%'), see Kexi forum.

Equivalent condition with NOT LIKE would be more human: a NOT LIKE '%foo%' AND b NOT LIKE '%bar%'.

Requirements

  1. Between NOT and LIKE there can be any amount of non-empty white space
  2. The token should be case-insensitive while parsed in SQL statements
  3. All properties of LIKE defined by the database backend also apply to NOT LIKE. The difference is in inverting the sense of the test. (See for example 'The LIKE and GLOB operators' section for SQLite at [1])

Hints

  1. LIKE operator uses the BinaryExpr class, NOT LIKE should too.
  2. KexiDB's SQL lexer (sqlscanner.l) should introduce a new token: NOT_LIKE, what is analogous to NOT_SIMILAR_TO.
  3. NOT_LIKE support should be implemented in sqlparser.y (see NOT_SIMILAR_TO for hints).
  4. Do not forget to execute make parser command in $builddir/libs/db to update generated parser and lexer whenever the .y and .l files change.