Simple but frustrating issue… I'm trying to do an update command to correct a misspelling with this field:
grouper=> select * from master_list WHERE group ~ 'JustAdopted';
group | activity | usefulness
-------------------+----------+------------
JustAdoptedAdvice+| |
| |
(1 row)
But postgres won't give me a straight answer on the field name…
grouper=> UPDATE master_list SET group = 'JustAdoptingAdvice' WHERE group = 'JustAdoptedAdvice';
UPDATE 0
grouper=> UPDATE master_list SET group = 'JustAdoptingAdvice' WHERE group = 'JustAdoptedAdvice+';
UPDATE 0
grouper=> select * from master_list WHERE group ~ '+';
ERROR: invalid regular expression: quantifier operand invalid
What is going on with that field? Why is that plus symbol there and what does it represent?
And how do I reference it to change it, if the field won't update with or without the symbol being there?
Best Answer
This:
should work perfectly fine if the field was really
JustAdoptedAdvice+
, but I don't think it is.psql
is showing that+
to meancontinuation
... I suspect there's actually a newline there.There could be whitespace after the newline too, so maybe even:
which says "JustAdoptedAdvice followed by one or more of tab/space/newline".
Demo showing it's likely to be a newline:
To be sure, look at the hex representation of the utf-8 encoding of the string:
You'll see that it ends with 0x0a, which is a newline.