Case When

Fernando Correa de Oliveira edited this page Nov 17, 2018 · 1 revision

With the same idea from better map grep now its possible to use CASE/WHEN directly from .map. For example:

use Red;

model M is table<mmm> {
   has Str $.a is column;
   has Int $.b is column;
   has Str $.c is column;
}

my $*RED-DB = database "SQLite";
M.^create-table;

say M.^all.map: { .b < 10 ?? .a !! .c }

that runs:

SELECT
   CASE 
      WHEN not b < 10 THEN c
      WHEN b < 10 THEN a
   END
    as "data"
FROM
   mmm
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.