-
Notifications
You must be signed in to change notification settings - Fork 293
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: schema watch support for mysql driver #2224
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kartikay <[email protected]>
@josephschorr I thought this PR would need refactoring after the changes to base of datastore driver, after looking closely it seems that this could go ahead as well, my bad. |
internal/datastore/mysql/watch.go
Outdated
|
||
// Load caveat changes for the revision range. | ||
if options.Content&datastore.WatchSchema == datastore.WatchSchema { | ||
if err := mds.loadCaveatChanges(ctx, afterRevision, newRevision, stagedChanges); err != nil { |
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.
Put this under the if statement above
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.
done
internal/datastore/mysql/watch.go
Outdated
return fmt.Errorf("unable to parse changed namespace: %w", err) | ||
} | ||
|
||
if createdTxn > afterRevision && createdTxn <= newRevision { |
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 the filter here if we're doing so in the SQL query?
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.
The query can return a wider net of rows in the watch window, hence a double check, was implemented earlier for relationships too, also tested without the if statement, datastore tests tend to break in that case.
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.
Ah
internal/datastore/mysql/watch.go
Outdated
|
||
func (mds *Datastore) loadCaveatChanges(ctx context.Context, afterRevision uint64, newRevision uint64, stagedChanges *common.Changes[revisions.TransactionIDRevision, uint64]) (err error) { | ||
sql, args, err := mds.QueryChangedCaveatsQuery.Where(sq.Or{ | ||
sq.And{ |
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.
We should be able to combine these methods
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.
done, should I do same for loadRelationships and combine that too? (right now loadSchemaChanges
is only called when schema watch is enabled)
e5d02fd
to
5031de0
Compare
internal/datastore/mysql/watch.go
Outdated
return fmt.Errorf("unable to parse changed namespace: %w", err) | ||
} | ||
loaded = def | ||
objName = def.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.
don't need to set objName, since its defined on the SchemaDefinition
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.
done
Signed-off-by: Kartikay <[email protected]>
5031de0
to
b465181
Compare
implements schema watch for mysql datastore