Last active
September 16, 2022 15:11
-
-
Save karanlyons/3af10ad9a90dbbd02a6b 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