News for hackers. Stuff that matters.
Re:Show HN: EdgeDB – Next generation database by sbr464 on Thursday April 11, 2019 @10:24PM (#19641385)
I may not be following correctly, but if a Boolean field doesn’t support null, how would you handle a use case like: a survey question that hasn’t been answered, vs setting as false by default? Would you use an enum with 3 states vs a Boolean type?
Re:Show HN: EdgeDB – Next generation database by 1st1 on Thursday April 11, 2019 @10:43PM (#19641483)
This goes a bit beyond what fits in a comment reply, but I'll try to be brief.

- You can define a `bool` property as "optional" and then it can have an empty set as its value.

- The 'exists' operator coverts sets into bools; you can use it with the 'if..else' operator to handle empty sets where needed.

- You can coalesce (the "??" operator) your potentially empty property with a non-empty set, say a "{false}".

- An empty set isn't some magical value like NULL in SQL. Functions and operators in EdgeQL are strictly defined if they accept sets as their arguments, or not. In the case of logical operators -- they don't; they are defined as element-wise operators, therefore no three-valued boolean logic. You learn the rules once and they apply to all functions and operators in all contexts.

This documentation page (and subsequent sections) explains how exactly EdgeQL is defined: https://edgedb.com/docs/edgeql/overview.

Re:Show HN: EdgeDB – Next generation database by Scarbutt on Thursday April 11, 2019 @10:43PM (#19641481)
how would you handle a use case like: a survey question that hasn’t been answered

Very simple, you leave it out! Then you can query for this.