Skip to content

Commit

Permalink
Add schemaChange attrs to patch handler (#19769)
Browse files Browse the repository at this point in the history
* add notifySchemaChanges and nonBreakingChangesPreference to patch handler
  • Loading branch information
alovew authored Nov 28, 2022
1 parent d155c49 commit 1f65271
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ private void writeStandardSync(final StandardSync standardSync, final DSLContext
.set(CONNECTION.BREAKING_CHANGE, standardSync.getBreakingChange())
.set(CONNECTION.GEOGRAPHY, Enums.toEnum(standardSync.getGeography().value(),
io.airbyte.db.instance.configs.jooq.generated.enums.GeographyType.class).orElseThrow())
.set(CONNECTION.NON_BREAKING_CHANGE_PREFERENCE, standardSync.getNonBreakingChangesPreference().value())
.set(CONNECTION.NOTIFY_SCHEMA_CHANGES, standardSync.getNotifySchemaChanges())
.where(CONNECTION.ID.eq(standardSync.getConnectionId()))
.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public static StandardSync.Status toPersistenceStatus(final ConnectionStatus api
return Enums.convertTo(apiStatus, StandardSync.Status.class);
}

public static StandardSync.NonBreakingChangesPreference toPersistenceNonBreakingChangesPreference(final NonBreakingChangesPreference preference) {
return Enums.convertTo(preference, StandardSync.NonBreakingChangesPreference.class);
}

public static Geography toApiGeography(final io.airbyte.config.Geography geography) {
return Enums.convertTo(geography, Geography.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,14 @@ private static void applyPatchToStandardSync(final StandardSync sync, final Conn
if (patch.getBreakingChange() != null) {
sync.setBreakingChange(patch.getBreakingChange());
}

if (patch.getNotifySchemaChanges() != null) {
sync.setNotifySchemaChanges(patch.getNotifySchemaChanges());
}

if (patch.getNonBreakingChangesPreference() != null) {
sync.setNonBreakingChangesPreference(ApiPojoConverters.toPersistenceNonBreakingChangesPreference(patch.getNonBreakingChangesPreference()));
}
}

private void validateConnectionPatch(final WorkspaceHelper workspaceHelper, final StandardSync persistedSync, final ConnectionUpdate patch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import io.airbyte.api.model.generated.JobStatus;
import io.airbyte.api.model.generated.JobWithAttemptsRead;
import io.airbyte.api.model.generated.NamespaceDefinitionType;
import io.airbyte.api.model.generated.NonBreakingChangesPreference;
import io.airbyte.api.model.generated.OperationRead;
import io.airbyte.api.model.generated.OperationReadList;
import io.airbyte.api.model.generated.OperationUpdate;
Expand Down Expand Up @@ -539,7 +540,9 @@ void testToConnectionPatch() throws IOException {
.schedule(schedule)
.name(standardSync.getName())
.syncCatalog(catalog)
.geography(Geography.US);
.geography(Geography.US)
.nonBreakingChangesPreference(NonBreakingChangesPreference.DISABLE)
.notifySchemaChanges(false);

final List<UUID> operationIds = List.of(newOperationId);

Expand All @@ -553,7 +556,9 @@ void testToConnectionPatch() throws IOException {
.schedule(schedule)
.name(standardSync.getName())
.syncCatalog(catalog)
.geography(Geography.US);
.geography(Geography.US)
.nonBreakingChangesPreference(NonBreakingChangesPreference.DISABLE)
.notifySchemaChanges(false);

final ConnectionUpdate actual = WebBackendConnectionsHandler.toConnectionPatch(input, operationIds);

Expand Down

0 comments on commit 1f65271

Please sign in to comment.