- Notifications
You must be signed in to change notification settings - Fork689
Add PostgreSQL range types support#2325
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:develop
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
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.
Please use deepequal to confirm the full object returned.
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.
Updated tests to useassert.deepEqual for comprehensive validation of Range objects. This now checks all properties (lower, upper, lowerInc, upperInc) in a single assertion. Commit:b27778c
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.
Is this really the best way to do it?
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.
Simplified the comparison helper functions. The original approach explicitly handled Date objects with getTime(), but JavaScript's comparison operators already work correctly with Date objects via valueOf(). The new implementation is simpler and more idiomatic while maintaining the same functionality. Commit:b27778c
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Description
Implements PostgreSQL-style range types for AlaSQL, enabling temporal and numeric interval operations requested in#55.
Changes
Core Implementation (
src/60range.js):alasql.Rangeclass with inclusive/exclusive bounds[lower, upper)int4range,int8range,numrange,daterange,tsrange,tstzrangerange_union,range_intersection,range_differencerange_overlaps,range_contains,range_is_subset,range_is_superset,range_is_disjointBuild Integration:
src/60range.jsto build pipeline inbuild.shTest Coverage (
test/test055-B.js):assert.deepEqualfor comprehensive validationExample Usage
Notes
All range types use a unified
alasql.Rangeclass rather than PostgreSQL's six distinct implementations. Default bounds follow PostgreSQL convention: inclusive lower, exclusive upper[lower, upper).Comparison logic leverages JavaScript's built-in valueOf() behavior, making it compatible with Date objects and numeric types without explicit type checking.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.