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

Feature: Add Duration Scalar #459

Merged
merged 33 commits into from
Sep 14, 2021
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fcc3af0
add: duration scalar
dmoree Aug 24, 2021
dbd8d2d
add: int test for duration scalar
dmoree Aug 24, 2021
99a9100
add: tck tests for duration scalar
dmoree Aug 24, 2021
396edd4
update: documentation for duration scalar
dmoree Aug 24, 2021
2e98e7e
cleanup: int test
dmoree Aug 24, 2021
3104a7f
fix: regex
dmoree Aug 25, 2021
8b70e0e
add: error thrown on decimal value
dmoree Aug 25, 2021
429ca10
update: documentation about decimal values
dmoree Aug 25, 2021
8f29c06
add: validation and parsing tests
dmoree Aug 25, 2021
4ca8afe
refactor: for readability and performance
dmoree Aug 25, 2021
b79050e
Merge branch 'master' into feature/duration-scalar
darrellwarde Aug 25, 2021
6c18699
Merge branch 'master' into feature/duration-scalar
darrellwarde Aug 25, 2021
d4ca2d1
fix: regex to allow full ISO 8601 duration
dmoree Aug 27, 2021
831c065
add: duration comparison
dmoree Aug 27, 2021
93d303d
Merge branch 'feature/duration-scalar' of https://github.com/dmoree/g…
dmoree Aug 27, 2021
42e6528
add: {Create,Update}Info and bookmarks
dmoree Aug 27, 2021
99980ed
fix: regex group capture
dmoree Aug 27, 2021
e51751c
add: negative duration for unit based
dmoree Aug 27, 2021
e9a5c0f
cleanup
dmoree Aug 29, 2021
cbfa293
fix: documentation
dmoree Aug 29, 2021
d93334d
fix: regex negative unit time
dmoree Aug 31, 2021
d44b7ce
fix: decimal values for components
dmoree Aug 31, 2021
a43a9d6
Merge branch 'master' into feature/duration-scalar
darrellwarde Sep 6, 2021
f7b97d8
Apply suggestions from code review
dmoree Sep 7, 2021
4663bdf
fix: readability and unnecessary regex test
dmoree Sep 7, 2021
273c26b
remove: unnessary type check
dmoree Sep 7, 2021
38c291e
Merge branch 'master' into feature/duration-scalar
darrellwarde Sep 7, 2021
0d7f83f
add: missing type check
dmoree Sep 7, 2021
cb2c4d5
Merge branch 'master' into feature/duration-scalar
darrellwarde Sep 8, 2021
7ab4df1
Merge branch 'master' into feature/duration-scalar
oskarhane Sep 13, 2021
a0538a6
Merge branch 'master' into feature/duration-scalar
darrellwarde Sep 13, 2021
8a4600f
move: duration schema test
dmoree Sep 13, 2021
8823fc4
Merge branch 'master' into feature/duration-scalar
oskarhane Sep 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Darrell Warde <8117355+darrellwarde@users.noreply.github.com>
dmoree and darrellwarde authored Sep 7, 2021
commit f7b97d82cee98ead9b23d9d7858ead1a43e814b4
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/type-definitions/types.adoc
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ type Movie {
_Note:_

- Decimal values are not currently accepted on `[YMWD]`
- Comparisons are made according to the https://neo4j.com/developer/cypher/dates-datetimes-durations/#comparing-filtering-values[cypher developer guide]
- Comparisons are made according to the https://neo4j.com/developer/cypher/dates-datetimes-durations/#comparing-filtering-values[Cypher Developer Guide]

=== `LocalDateTime`

36 changes: 28 additions & 8 deletions packages/graphql/src/translate/create-where-and-params.ts
Original file line number Diff line number Diff line change
@@ -499,8 +499,13 @@ function createWhereAndParams({

let clause = `${property} < $${param}`;

if (pointField) clause = `distance(${varName}.${fieldName}, point($${param}.point)) < $${param}.distance`;
if (durationField) clause = `datetime() + ${property} < datetime() + $${param}`;
if (pointField) {
clause = `distance(${varName}.${fieldName}, point($${param}.point)) < $${param}.distance`;
}

if (durationField) {
clause = `datetime() + ${property} < datetime() + $${param}`;
}

res.clauses.push(clause);
res.params[param] = value;
@@ -522,8 +527,13 @@ function createWhereAndParams({

let clause = `${property} <= $${param}`;

if (pointField) clause = `distance(${varName}.${fieldName}, point($${param}.point)) <= $${param}.distance`;
if (durationField) clause = `datetime() + ${property} <= datetime() + $${param}`;
if (pointField) {
clause = `distance(${varName}.${fieldName}, point($${param}.point)) <= $${param}.distance`;
}

if (durationField) {
clause = `datetime() + ${property} <= datetime() + $${param}`;
}

res.clauses.push(clause);
res.params[param] = value;
@@ -545,8 +555,13 @@ function createWhereAndParams({

let clause = `${property} > $${param}`;

if (pointField) clause = `distance(${varName}.${fieldName}, point($${param}.point)) > $${param}.distance`;
if (durationField) clause = `datetime() + ${property} > datetime() + $${param}`;
if (pointField) {
clause = `distance(${varName}.${fieldName}, point($${param}.point)) > $${param}.distance`;
}

if (durationField) {
clause = `datetime() + ${property} > datetime() + $${param}`;
}

res.clauses.push(clause);
res.params[param] = value;
@@ -568,8 +583,13 @@ function createWhereAndParams({

let clause = `${property} >= $${param}`;

if (pointField) clause = `distance(${varName}.${fieldName}, point($${param}.point)) >= $${param}.distance`;
if (durationField) clause = `datetime() + ${property} >= datetime() + $${param}`;
if (pointField) {
clause = `distance(${varName}.${fieldName}, point($${param}.point)) >= $${param}.distance`;
}

if (durationField) {
clause = `datetime() + ${property} >= datetime() + $${param}`;
}

res.clauses.push(clause);
res.params[param] = value;
Original file line number Diff line number Diff line change
@@ -215,9 +215,13 @@ function createNodeWhereAndParams({
if (operator && ["LT", "LTE", "GTE", "GT"].includes(operator)) {
let clause = `${property} ${operators[operator]} $${param}`;

if (pointField)
if (pointField) {
clause = `distance(${property}, point($${param}.point)) ${operators[operator]} $${param}.distance`;
if (durationField) clause = `datetime() + ${property} ${operators[operator]} datetime() + $${param}`;
}

if (durationField) {
clause = `datetime() + ${property} ${operators[operator]} datetime() + $${param}`;
}

res.clauses.push(clause);
res.params[key] = value;