-
Notifications
You must be signed in to change notification settings - Fork 107
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
feat: Add support for Interval #2192
base: main
Are you sure you want to change the base?
Conversation
e17c3ab
to
1b3c462
Compare
1b3c462
to
8380a9c
Compare
45b2da1
to
8f99313
Compare
private days: number; | ||
private nanoseconds: bigint; | ||
|
||
private static readonly ISO8601_PATTERN: RegExp = |
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.
@google-cloud/precise-date
library has built-in support for ISO 8601 , Can we use that ?
}); | ||
}; | ||
|
||
it('GOOGLE_STANDARD_SQL should bind the value when param type interval is used', done => { |
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 add a test for `GOOGLE_STANDARD_SQL should interval value is passed as string for both typed and untyped params.
var value = (new Interval(19, 768, BigInt('123456789123'))).toISO8601()
@@ -367,6 +368,7 @@ describe('Spanner', () => { | |||
googleSqlTable = DATABASE.table(TABLE_NAME); | |||
postgreSqlTable = PG_DATABASE.table(TABLE_NAME); | |||
if (IS_EMULATOR_ENABLED) { | |||
// TODO: add columns using Interval Value and Interval Array Value. |
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.
Why this is skipped ?
@@ -6523,6 +6530,264 @@ describe('Spanner', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
describe('interval', () => { |
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.
Test cases for insert are missing. These test cases are only for query. Please add a block in describe('types')
}); | ||
}); | ||
|
||
it('should throw error for invalid ISO8601 strings', () => { |
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 also add test for null, undefined here and elsewhere
return this.nanoseconds; | ||
} | ||
|
||
static fromMonths(months: number): Interval { |
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 add documentation for all public methods.
private nanoseconds: bigint; | ||
|
||
private static readonly ISO8601_PATTERN: RegExp = | ||
/^P(?!$)(-?\d+Y)?(-?\d+M)?(-?\d+D)?(T(?=-?[.,]?\d)(-?\d+H)?(-?\d+M)?(-?(((\d+)([.,]\d{1,9})?)|([.,]\d{1,9}))S)?)?$/; |
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.
Add code comments to explain the regex. Also elsewhere where its not self explanatory.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕