From: Mischa POSLAWSKY Date: Sun, 23 Jan 2022 00:51:12 +0000 (+0100) Subject: word/edit: read fractional crop coordinates X-Git-Tag: v1.13~25 X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/a93c5c61b18192c5f74256e3cb18e7f1cd2034d5?hp=a93c5c61b18192c5f74256e3cb18e7f1cd2034d5 word/edit: read fractional crop coordinates Clean up various separators (,-x;:/) from manual input into common comma, and allow dot for possible future fractions in large numbers: UPDATE word SET image = jsonb_set(image, '{crop32}', regexp_replace(image->>'crop32', '[^0-9,]', ',', 'g') ) WHERE image->>'crop32' IS NOT NULL; Decided against dividing by 1000 to simplify code, but this would do that: UPDATE word SET image = jsonb_set(image, '{crop32}', to_jsonb(array_to_string(array( SELECT unnest(string_to_array(image->>'crop32', ','))::float / 1000 ), ',')) ) WHERE image->>'crop32' IS NOT NULL; ---