4 ms·
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
by sbr464 8y ago
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?
- Scarbutt 8y agohow 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.
- 1st1 8y agoThis 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 https://edgedb.com/docs/edgeql/overview.