Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
vpetrovykh
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
3 ms
·
1.
▲
by
vpetrovykh
7y ago
A few things come to mind: 1) It's a little unlikely that at the same time you have data where an {} is an error, but you are not making the property required AND with knowledge of that you still don't bother with other validation
2.
▲
by
vpetrovykh
7y ago
This type of error is better remedied by making the balance property be required (so that it cannot be set to {} and produce an exception at the time the error is introduced). This way you will know about the error early enough. The point
3.
▲
by
vpetrovykh
7y ago
Oh, that's simple: sum(A UNION B) should be the same as sum(A) + sum(B) for any two sets A and B (or else there would be very weird inconsistencies). sum(A UNION {}) = sum(A) + sum({}) sum(A) = sum(A) + sum({}) 0 = sum({}) Typically fo
4.
▲
by
vpetrovykh
7y ago
You are exactly right about everything consuming sets in EdgeDB. Even when a function is defined on scalars, it's really defined on singleton sets. Literals are also singleton sets, so "1" and "{1}" are equivalent a
5.
▲
by
vpetrovykh
7y ago
Let me make a tiny correction to the expression you wrote: "sum({1, 1, {}})" - the function sum takes only one argument and it's a set. Because we flatten all "nested" sets, the expression "{1, 1, {}}" is
6.
▲
by
vpetrovykh
7y ago
The sum of an empty set is, in fact, 0 (the identity for addition). The generalized conjuction (we have a function called "all" for that) of an empty set is True (the identity for conjunction). The generalized disjuction (we have
7.
▲
by
vpetrovykh
7y ago
If a NULL were just a value in 3-valued logic, it could have been OK. However, that's not how it works out. Consider the following (that should be equivalent if NULL is just like Maybe in True-Maybe-False logic): SELECT null AND tr
8.
▲
by
vpetrovykh
7y ago
You seem to treat NULLs as if they have a specific meaning. So then the question is this: what should count(NULL) be? Here are some options: 1) count(NULL) = 0, so apparently NULL is just like an empty set at least some of the time. This me