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

fix: Query modification and Refresh Client Issue #1003

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion sources/common/dbdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ func ProcessDbDump(conv *internal.Conv, r *internal.Reader, dbDump DbDump, ddlVe
ExpressionVerificationAccessor: exprVerifier,
DdlV: ddlVerifier,
}
schemaToSpanner.SchemaToSpannerDDL(conv, dbDump.GetToDdl(), internal.AdditionalSchemaAttributes{})
err := schemaToSpanner.SchemaToSpannerDDL(conv, dbDump.GetToDdl(), internal.AdditionalSchemaAttributes{})
if err != nil {
return err
}
conv.AddPrimaryKeys()
}
return nil
Expand Down
5 changes: 4 additions & 1 deletion sources/common/infoschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ func (ps *ProcessSchemaImpl) ProcessSchema(conv *internal.Conv, infoSchema InfoS
}
uo.initPrimaryKeyOrder(conv)
uo.initIndexOrder(conv)
s.SchemaToSpannerDDL(conv, infoSchema.GetToDdl(), attributes)
err = s.SchemaToSpannerDDL(conv, infoSchema.GetToDdl(), attributes)
if err != nil {
return err
}
if tableCount != len(conv.SpSchema) {
fmt.Printf("Failed to load all the source tables, source table count: %v, processed tables:%v. Please retry connecting to the source database to load tables.\n", tableCount, len(conv.SpSchema))
return fmt.Errorf("failed to load all the source tables, source table count: %v, processed tables:%v. Please retry connecting to the source database to load tables.", tableCount, len(conv.SpSchema))
Expand Down
1 change: 1 addition & 0 deletions sources/mysql/infoschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func (isi InfoSchemaImpl) getConstraintsDQL() (string, error) {
AND t.TABLE_NAME = k.TABLE_NAME
LEFT JOIN INFORMATION_SCHEMA.CHECK_CONSTRAINTS AS c
ON t.CONSTRAINT_NAME = c.CONSTRAINT_NAME
AND t.TABLE_SCHEMA = c.CONSTRAINT_SCHEMA
WHERE t.TABLE_SCHEMA = ?
AND t.TABLE_NAME = ?;`, nil
}
Expand Down
1 change: 1 addition & 0 deletions sources/mysql/infoschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ func TestGetConstraints_CheckConstraintsTableExists(t *testing.T) {
AND t.TABLE_NAME = k.TABLE_NAME
LEFT JOIN INFORMATION_SCHEMA.CHECK_CONSTRAINTS AS c
ON t.CONSTRAINT_NAME = c.CONSTRAINT_NAME
AND t.TABLE_SCHEMA = c.CONSTRAINT_SCHEMA
WHERE t.TABLE_SCHEMA = ?
AND t.TABLE_NAME = ?;`),
args: []driver.Value{"test_schema", "test_table"},
Expand Down
1 change: 1 addition & 0 deletions webv2/api/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ func (expressionVerificationHandler *ExpressionsVerificationHandler) VerifyCheck
}

sessionState.Conv.SchemaIssues = common.RemoveError(sessionState.Conv.SchemaIssues)
expressionVerificationHandler.ExpressionVerificationAccessor.RefreshSpannerClient(ctx, sessionState.Conv.SpProjectId, sessionState.Conv.SpInstanceId)
result := expressionVerificationHandler.ExpressionVerificationAccessor.VerifyExpressions(ctx, verifyExpressionsInput)
if result.ExpressionVerificationOutputList == nil {
http.Error(w, fmt.Sprintf("Unhandled error: : %s", result.Err.Error()), http.StatusInternalServerError)
Expand Down
1 change: 1 addition & 0 deletions webv2/api/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2870,6 +2870,7 @@ func TestVerifyCheckConstraintExpressions(t *testing.T) {
ExpressionVerificationOutputList: tc.expectedResults,
})

mockAccessor.On("RefreshSpannerClient", ctx, mock.Anything, mock.Anything).Return(nil)
rr := httptest.NewRecorder()
handler.VerifyCheckConstraintExpression(rr, req)

Expand Down
Loading