-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minimal support for 4.x #733
Changes from 12 commits
665bdc1
8e05449
75227d5
1592963
54f0ee3
ec953ca
b298991
c1579a7
5379b1d
93ba86c
2e97e5b
8701cd7
64b388e
567d960
1407968
8e38a7d
551ed4b
c0c7210
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import { Duration, LocalDate, LocalDateTime } from "./datetime"; | ||
import type { Duration, LocalDate, LocalDateTime } from "./datetime"; | ||
|
||
export class Range< | ||
T extends number | Date | LocalDate | LocalDateTime | Duration | ||
|
@@ -63,3 +63,25 @@ export class Range< | |
}; | ||
} | ||
} | ||
|
||
export class MultiRange< | ||
T extends number | Date | LocalDate | LocalDateTime | Duration | ||
> { | ||
constructor(private readonly _ranges: Range<T>[] = []) {} | ||
|
||
get length() { | ||
return this._ranges.length; | ||
} | ||
|
||
*[Symbol.iterator]() { | ||
for (const range of this._ranges) { | ||
yield range; | ||
} | ||
} | ||
|
||
toJSON() { | ||
return { | ||
ranges: this._ranges, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should probably just return the array, to mirror edgedb's json representation of multiranges. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also probably should copy the array so you can't mutate it. (Or maybe this should be done in the constructor? or both?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I think I just copied this from the python impl, but that makes sense! |
||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change reflects the new behavior of 4.x where the parent type's cardinality is considered when using polymorphic queries. In this case,
Person
has a requiredname
, but the query can returnPerson
records that are notHero
s, which would return a empty set name, which is invalid forPerson
.