You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aa_text is returned unquoted as it doesn't contain any non-numeric character. xx_text is also unquoted even if it has a hyphen and text. zzzzz_text has a similar pattern to xx_text but is quoted. Dates are correctly unquoted, but timestamps are quoted.
My expection is that all numeric and date-related fields would be unquoted. The rest would be quoted. I haven't tried if this problem exists also on tables/views.
For the time being, I guess I'll need to duplicate all the functions with a separate text/csv domain in order to get a consistent behaviour. Or is there any way to override the default implementation?
The text was updated successfully, but these errors were encountered:
AFAICS, there isn't a standard for CSV, the closest one being the RFC 4180. There, it says that "Each field may or may not be enclosed in double quotes". It does not mention quoting according to the type.
The response handles field types inconsistently:
It looks that way because it doesn't take into consideration the type at all. The response is a result of casting a PostgreSQL composite type (a table row in this case) to text. For instance:
select row('text', 'text with space', 'text with " quote');
-- Result:-- (text,"text with space","text with "" quote")
Some are wrapped because they have certain special characters in the value (e.g. " or space).
My expection is that all numeric and date-related fields would be unquoted. The rest would be quoted.
Since this doesn't adhere to the RFC, I'm sure we won't be implementing this in PostgREST either. I think your CSV parser should understand quoted values when present regardless of the type.
Also, issue #1374, which also had problems with the CSV output, was closed with Overriding a Built-in Handler as the solution. So this would be your workaround if you need to implement it.
Due to both of the points above, I'll be closing this. Feel free to reopen if you disagree.
Environment
Description of issue
I have the following function definition:
And request text/csv content:
The response handles field types inconsistently:
aa_text
is returned unquoted as it doesn't contain any non-numeric character.xx_text
is also unquoted even if it has a hyphen and text.zzzzz_text
has a similar pattern toxx_text
but is quoted. Dates are correctly unquoted, but timestamps are quoted.My expection is that all numeric and date-related fields would be unquoted. The rest would be quoted. I haven't tried if this problem exists also on tables/views.
For the time being, I guess I'll need to duplicate all the functions with a separate
text/csv
domain in order to get a consistent behaviour. Or is there any way to override the default implementation?The text was updated successfully, but these errors were encountered: