Re: [whatwg/url] Proposal of .toString({ concise: true }) for nicer output with empty values (#469)

I'd like to record an argument in support of concise query-string values.

There is currently an [impedence mismatch](https://en.wikipedia.org/wiki/Object-relational_impedance_mismatch) between many applications that communicate using URIs and the programming languages and data stores that they use.

Most databases (relational and NoSQL) support the concept of NULL values, as do most programming languages.  We use `null` in C#, Java and JavaScript (distinct from `undefined`), `None` in Python and Rust, `nil` in GoLang, and so forth).

Most query-string serialization and deserialization _currently_ do not reliably distinguish between `?a=&b=1` and `?a&b=1` - there's ambiguity in the treatment of empty values vs empty strings.

To put this argument another way - it's less than ideal that both of the JavaScript objects `{"a": null}` and `{"a": ""}` -- which developers would generally agree have different behaviours and 'mean' different things -- have a tendency to collide into the same `?a=` representation when we put them into a URI.

Similarly, when an application receives and deserializes a query-string, it would be excellent if nulls and empty strings could be distinguished easily.  Storing empty strings in a database column can have unintended consequences when database developers are writing queries on those columns and/or are attempting to assess whether values are present.

There's an opportunity here to select a behaviour that will increase communication compatibility between systems over and reduce ambiguity over a long timescale.  Please balance that against other considerations including consistency, parsing complexity, and backwards compatibility.

Related issues:
- [jQuery bug 8653](https://bugs.jquery.com/ticket/8653#comment:3) (and related issue https://github.com/jquery/jquery/issues/4707 )
- [Python Issue 18857](https://bugs.python.org/issue18857) (and related PRs https://github.com/python/cpython/pull/19949, https://github.com/python/cpython/pull/19945)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/469#issuecomment-627008837

Received on Monday, 11 May 2020 22:57:08 UTC