-
-
Save weivall/e580e9292404ab345356384b44b2dd31 to your computer and use it in GitHub Desktop.
Postgres: Update only portion of range, preserving other half and bounds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE <TABLE> SET | |
<COLUMN>=<RANGE_TYPE>( | |
lower(<COLUMN>), -- Swap out for actual value | |
upper(<COLUMN>), -- Swap out for actual value | |
concat( | |
CASE WHEN lower_inc(<COLUMN>) THEN '[' ELSE '(' END, | |
CASE WHEN upper_inc(<COLUMN>) THEN ']' ELSE ')' END | |
) | |
) | |
WHERE <CONDITION>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment