Skip to content

Commit 2ea74e7

Browse files
committed
HTM-1995: prefix table in delete statement with schema when needed
1 parent e147923 commit 2ea74e7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/org/tailormap/api/geotools/featuresources/AttachmentsHelper.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,15 @@ public static AttachmentMetadata insertAttachment(
454454
}
455455

456456
public static void deleteAttachment(UUID attachmentId, TMFeatureType featureType) throws IOException, SQLException {
457-
String deleteSql = MessageFormat.format("""
458-
DELETE FROM {0}_attachments WHERE attachment_id = ?
459-
""", featureType.getName());
460457
JDBCDataStore ds = null;
461458
try {
462459
ds = (JDBCDataStore) new JDBCFeatureSourceHelper().createDataStore(featureType.getFeatureSource());
460+
461+
String deleteSql = MessageFormat.format(
462+
"""
463+
DELETE FROM {1}{0}_attachments WHERE attachment_id = ?
464+
""", featureType.getName(), ds.getDatabaseSchema().isEmpty() ? "" : ds.getDatabaseSchema() + ".");
465+
463466
try (Connection conn = ds.getDataSource().getConnection();
464467
PreparedStatement stmt = conn.prepareStatement(deleteSql)) {
465468
if (featureType

0 commit comments

Comments
 (0)