Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sagarwaal
Copy link

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@sagarwaal sagarwaal requested review from a team as code owners November 15, 2024 08:58
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Nov 15, 2024
@sagarwaal sagarwaal requested a review from a team as a code owner March 26, 2025 07:44
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Mar 26, 2025
@olavloite olavloite changed the title Feat(spanner): Add support for Interval feat: Add support for Interval Mar 28, 2025
private days: number;
private nanoseconds: bigint;

private static readonly ISO8601_PATTERN: RegExp =
Copy link
Contributor

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 => {
Copy link
Contributor

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.
Copy link
Contributor

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', () => {
Copy link
Contributor

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', () => {
Copy link
Contributor

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 {
Copy link
Contributor

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)?)?$/;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants