fix bug that occurs when GREL contains brackets

This commit is contained in:
Felix Lohmeier 2023-12-06 16:02:59 +00:00
parent 779a6e655b
commit 57cfdfd0cd
3 changed files with 51 additions and 3 deletions

4
orcli
View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script was generated by bashly 1.1.2 (https://bashly.dannyb.co)
# This script was generated by bashly 1.1.3 (https://bashly.dannyb.co)
# Modifying it manually is not recommended
# :wrapper.bash3_bouncer
@ -2264,7 +2264,7 @@ orcli_transform_command() {
array[expression]="${array[expression]//$'\n'/}"
# prepare curl options
mapfile -t curloptions < <(for K in "${!array[@]}"; do
echo "--data"
echo "--data-urlencode"
echo "$K=${array[$K]}"
done)
# get csrf token and post data to it's individual endpoint

View File

@ -88,7 +88,7 @@ for i in "${!files[@]}"; do
array[expression]="${array[expression]//$'\n'/}"
# prepare curl options
mapfile -t curloptions < <(for K in "${!array[@]}"; do
echo "--data"
echo "--data-urlencode"
echo "$K=${array[$K]}"
done)
# get csrf token and post data to it's individual endpoint

View File

@ -0,0 +1,48 @@
#!/bin/bash
t="transform-bracket"
# create tmp directory
tmpdir="$(mktemp -d)"
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
# assertion
cat << "DATA" > "${tmpdir}/${t}.assert"
email name test state gender purchase
danny.baron@example1.com Danny Baron (Danny Baron) CA M TV
melanie.white@example2.edu Melanie White (Melanie White) NC F iPhone
danny.baron@example1.com D. Baron (D. Baron) CA M Winter jacket
ben.tyler@example3.org Ben Tyler (Ben Tyler) NV M Flashlight
arthur.duff@example4.com Arthur Duff (Arthur Duff) OR M Dining table
danny.baron@example1.com Daniel Baron (Daniel Baron) CA M Bike
jean.griffith@example5.org Jean Griffith (Jean Griffith) WA F Power drill
melanie.white@example2.edu Melanie White (Melanie White) NC F iPad
ben.morisson@example6.org Ben Morisson (Ben Morisson) FL M Amplifier
arthur.duff@example4.com Arthur Duff (Arthur Duff) OR M Night table
DATA
# transform
cat << "DATA" > "${tmpdir}/${t}.history"
[
{
"op": "core/column-addition",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"baseColumnName": "name",
"expression": "grel:forNonBlank(value, x, '(' + x + ')', null)",
"newColumnName": "test",
"columnInsertIndex": 2
}
]
DATA
# action
cd "${tmpdir}" || exit 1
orcli import csv "https://git.io/fj5hF" --projectName "duplicates"
orcli transform "duplicates" "${t}.history"
orcli export tsv "duplicates" --output "${t}.output"
# test
diff -u "${t}.assert" "${t}.output"