-
Notifications
You must be signed in to change notification settings - Fork 145
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
fix: avoid adding duplicate orderBys in startAfter() #1453
Changes from 1 commit
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 |
---|---|---|
|
@@ -49,6 +49,7 @@ import { | |
} from './util/helpers'; | ||
|
||
import api = google.firestore.v1; | ||
import protobuf = google.protobuf; | ||
|
||
const PROJECT_ID = 'test-project'; | ||
const DATABASE_ROOT = `projects/${PROJECT_ID}/databases/(default)`; | ||
|
@@ -285,9 +286,24 @@ function endAt( | |
return {endAt: cursor}; | ||
} | ||
|
||
export function queryEqualsWithParent( | ||
/** | ||
* Returns the timestamp value for the provided readTimes, or the default | ||
* readTime value used in tests if no values are provided. | ||
*/ | ||
export function readTime( | ||
seconds?: number, | ||
nanos?: number | ||
): protobuf.ITimestamp { | ||
if (seconds === undefined && nanos === undefined) { | ||
return {seconds: '5', nanos: 6}; | ||
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. We have to cast to seconds since the 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. Proto3 JSON represents int64 as strings, and the seconds component of Timestamps is an int64. |
||
} | ||
return {seconds: String(seconds), nanos: nanos}; | ||
} | ||
|
||
export function queryEqualsWithParentAndReadTime( | ||
actual: api.IRunQueryRequest | undefined, | ||
parent: string, | ||
readTime?: protobuf.ITimestamp, | ||
...protoComponents: api.IStructuredQuery[] | ||
): void { | ||
expect(actual).to.not.be.undefined; | ||
|
@@ -315,6 +331,10 @@ export function queryEqualsWithParent( | |
]; | ||
} | ||
|
||
if (readTime) { | ||
query.readTime = readTime; | ||
} | ||
|
||
// 'extend' removes undefined fields in the request object. The backend | ||
// ignores these fields, but we need to manually strip them before we compare | ||
// the expected and the actual request. | ||
|
@@ -326,7 +346,12 @@ export function queryEquals( | |
actual: api.IRunQueryRequest | undefined, | ||
...protoComponents: api.IStructuredQuery[] | ||
): void { | ||
queryEqualsWithParent(actual, '', ...protoComponents); | ||
queryEqualsWithParentAndReadTime( | ||
actual, | ||
'', | ||
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. What is ''? Can you add a comment? |
||
/* readTime= */ undefined, | ||
...protoComponents | ||
); | ||
} | ||
|
||
function bundledQueryEquals( | ||
|
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.
I think this would be cleaner if we ran this in two steps: