SDK Parity: C# implementation needed
A change was made in supabase-flutter that needs to be implemented in this repository for SDK parity.
Reference Implementation (supabase-flutter)
What Changed
toArray in packages/supabase_realtime/lib/src/transformers.dart used to try json.decode on a Postgres array literal body and, when that threw, fall back to splitting the string on every comma. That silently corrupted realtime payloads for common cases:
| Literal Postgres sends |
Before |
After |
{"a,b",c} |
['"a', ' b"', 'c'] (three elements) |
['a,b', 'c'] |
{NULL,a} on text[] |
['NULL', 'a'] |
[null, 'a'] |
{"",a} |
['""', 'a'] |
['', 'a'] |
{{1,2},{3,4}} on int4[] |
[null, null, null, null] |
[[1, 2], [3, 4]] |
The fix replaced the comma-split with an actual parser for the literal: comma separated elements, optional double quotes where \ escapes the next character, unquoted whitespace trimmed, an unquoted NULL as the null element (a quoted "NULL" stays the four character string), and nested arrays keeping their shape.
Code Reference
Confirmed in supabase-csharp: packages/Realtime/Realtime/Converters/StringArrayConverter.cs and IntArrayConverter.cs Parse() do:
foreach (var item in value.Trim('{', '}', '[', ']').Split(','))
{
if (string.IsNullOrEmpty(item)) continue;
result.Add(item);
}
This has the same class of bug as the pre-fix Dart code, but without even the quoted-string handling Dart had before this fix: a comma inside a quoted string element splits it into extra elements, a literal NULL string is indistinguishable from a real null element, and there's no escape (\") handling at all.
Implementation Guidance
Key Behaviors to Match
- Quoted commas inside an array element don't split the element (
{"a,b",c} → ["a,b", "c"])
\" and \\ escapes inside quoted elements are honored
- Whitespace around unquoted elements is trimmed
- Nested arrays (for multi-dimensional columns) keep their shape rather than being flattened/dropped
Files Likely Affected
packages/Realtime/Realtime/Converters/StringArrayConverter.cs
packages/Realtime/Realtime/Converters/IntArrayConverter.cs
- Any other array converter under
packages/Realtime/Realtime/Converters/ sharing this Parse() shape
Acceptance Criteria
Context
SDK Parity: C# implementation needed
A change was made in
supabase-flutterthat needs to be implemented in this repository for SDK parity.Reference Implementation (supabase-flutter)
What Changed
toArrayinpackages/supabase_realtime/lib/src/transformers.dartused to tryjson.decodeon a Postgres array literal body and, when that threw, fall back to splitting the string on every comma. That silently corrupted realtime payloads for common cases:{"a,b",c}['"a', ' b"', 'c'](three elements)['a,b', 'c']{NULL,a}ontext[]['NULL', 'a'][null, 'a']{"",a}['""', 'a']['', 'a']{{1,2},{3,4}}onint4[][null, null, null, null][[1, 2], [3, 4]]The fix replaced the comma-split with an actual parser for the literal: comma separated elements, optional double quotes where
\escapes the next character, unquoted whitespace trimmed, an unquotedNULLas the null element (a quoted"NULL"stays the four character string), and nested arrays keeping their shape.Code Reference
Confirmed in supabase-csharp:
packages/Realtime/Realtime/Converters/StringArrayConverter.csandIntArrayConverter.csParse()do:This has the same class of bug as the pre-fix Dart code, but without even the quoted-string handling Dart had before this fix: a comma inside a quoted string element splits it into extra elements, a literal
NULLstring is indistinguishable from a real null element, and there's no escape (\") handling at all.Implementation Guidance
Key Behaviors to Match
{"a,b",c}→["a,b", "c"])\"and\\escapes inside quoted elements are honoredFiles Likely Affected
packages/Realtime/Realtime/Converters/StringArrayConverter.cspackages/Realtime/Realtime/Converters/IntArrayConverter.cspackages/Realtime/Realtime/Converters/sharing thisParse()shapeAcceptance Criteria
{1,2,3},{}) is unchangedContext
StringArrayConverter.cs/IntArrayConverter.csonmaster, not a heuristic match