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
Provide an easy way to specify a string value that represents null value.
This issue is related to:
csv-parse
csv-stringify
Motivation
I utilized these packages to imitate COPY command in SQL and found that there is no official way to handle with null values documented.
Most SQL provides COPY command with an option to specify a string value that represents NULL.
And PostgreSQL treats the value as null only when it is unquoted.
Alternative
No alternative considered.
Draft
Provide following options:
null_string: string | undefined - specifies a string value that represents null.
unquoted_null: boolean | undefined - should work only with null_string specified. If unquoted_null is not false,
with parse, the value specified by null_string is treated as null only when it is unquoted.
with stringify, null is emitted as an unquoted null_string value. A string value of null_string is emitted with quotes. This option overrides quoted_empty, quoted_string, quoted_match.
undefined_as_null: boolean | undefined - should work only with null_string specified. If undefied_as_null is not false,
with stringify, undefined is emitted as null.
Additional context
I managed to handle null values in a same way as PostgreSQL does, by using cast and quoted_string.
Iit was a little tricky, and stringify could not emit null as unquoted non-empty string. If there was cast.null option for stringify provided, it would be possible.
The text was updated successfully, but these errors were encountered:
Summary
Provide an easy way to specify a string value that represents
null
value.This issue is related to:
csv-parse
csv-stringify
Motivation
I utilized these packages to imitate
COPY
command in SQL and found that there is no official way to handle withnull
values documented.Most SQL provides
COPY
command with an option to specify a string value that representsNULL
.And PostgreSQL treats the value as null only when it is unquoted.
Alternative
No alternative considered.
Draft
Provide following options:
null_string
: string | undefined - specifies a string value that representsnull
.unquoted_null
: boolean | undefined - should work only withnull_string
specified. Ifunquoted_null
is not false,parse
, the value specified bynull_string
is treated as null only when it is unquoted.stringify
, null is emitted as an unquotednull_string
value. A string value ofnull_string
is emitted with quotes. This option overridesquoted_empty
,quoted_string
,quoted_match
.undefined_as_null
: boolean | undefined - should work only withnull_string
specified. Ifundefied_as_null
is not false,stringify
,undefined
is emitted asnull
.Additional context
I managed to handle
null
values in a same way as PostgreSQL does, by usingcast
andquoted_string
.Iit was a little tricky, and
stringify
could not emitnull
as unquoted non-empty string. If there wascast.null
option forstringify
provided, it would be possible.The text was updated successfully, but these errors were encountered: