-
Notifications
You must be signed in to change notification settings - Fork 573
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
asserts: implement Database.FindSequence #8907
Conversation
based on #8906 |
FindSequence finds a sequence-forming assertion based the given headers. Provided headers must contain a prefix of the primary key for the assertion type except for the sequence header. Th assertion is the first in the sequence under the prefix with sequential number > after. If after is -1 it returns instead the assertion with the largest sequential number.
d8c2c51
to
237c010
Compare
return nil, err | ||
} | ||
if !assertType.SequenceForming() { | ||
return nil, fmt.Errorf("cannot use FindSequence with not sequence-forming assertion type %q", assertType.Name) |
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.
s/not/non/ ? (not sure, cc @degville )
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.
s/not/non/ ? (not sure, cc @degville )
you're right - it should be cannot use FindSequence with non sequence-forming assertion type
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.
LGTM, with one nitpick about error message
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.
LGTM with a tiny suggestion about a comment
} | ||
} | ||
|
||
seqKey, err := keysFromHeaders(assertType.PrimaryKey[:len(assertType.PrimaryKey)-1], sequenceHeaders) |
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.
// all keys but the last one which is the sequence number
@bboozzoo @stolowski I'll land this and address the two small points in a follow up |
FindSequence finds a sequence-forming assertion based the given
headers. Provided headers must contain a prefix of the primary key
for the assertion type except for the sequence header.
Th assertion is the first in the sequence under the prefix with
sequential number > after.
If after is -1 it returns instead the assertion with the largest
sequential number.