Skip to content

Commit

Permalink
Revert "PDB-384: Make BLOB accept null values on all database engines"
Browse files Browse the repository at this point in the history
This reverts commit e4c33a9.
  • Loading branch information
victorcmg-fdz committed Jul 5, 2023
1 parent a3bb8df commit a0e9f9a
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import static com.feedzai.commons.sql.abstraction.util.StringUtils.md5;
import static com.feedzai.commons.sql.abstraction.util.StringUtils.quotize;
import static java.lang.String.format;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.join;

/**
Expand Down Expand Up @@ -125,11 +124,6 @@ protected void setPreparedStatementValue(final PreparedStatement ps,
case JSON:
case CLOB:
case BLOB:
if (isNull(value)) {
ps.setBytes(index, null);
break;
}

ps.setBytes(index, objectToArray(value));

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import static com.feedzai.commons.sql.abstraction.util.StringUtils.md5;
import static com.feedzai.commons.sql.abstraction.util.StringUtils.quotize;
import static java.lang.String.format;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.join;

/**
Expand Down Expand Up @@ -123,11 +122,6 @@ protected void setPreparedStatementValue(final PreparedStatement ps,
final boolean fromBatch) throws Exception {
switch (dbColumn.getDbColumnType()) {
case BLOB:
if (isNull(value)) {
ps.setBytes(index, null);
break;
}

ps.setBytes(index, objectToArray(value));

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import static com.feedzai.commons.sql.abstraction.util.StringUtils.md5;
import static com.feedzai.commons.sql.abstraction.util.StringUtils.quotize;
import static java.lang.String.format;
import static java.util.Objects.isNull;
import static java.util.stream.Collectors.joining;
import static org.apache.commons.lang3.StringUtils.join;

Expand Down Expand Up @@ -236,11 +235,6 @@ protected void setPreparedStatementValue(final PreparedStatement ps,
final boolean fromBatch) throws Exception {
switch (dbColumn.getDbColumnType()) {
case BLOB:
if (isNull(value)) {
ps.setBytes(index, null);
break;
}

final byte[] valArray = objectToArray(value);
if (fromBatch && valArray.length > MIN_SIZE_FOR_BLOB) {
// Use a blob for columns greater than 4K when inside a batch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import static com.feedzai.commons.sql.abstraction.util.StringUtils.md5;
import static com.feedzai.commons.sql.abstraction.util.StringUtils.quotize;
import static java.lang.String.format;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.join;

/**
Expand Down Expand Up @@ -144,11 +143,6 @@ protected void setPreparedStatementValue(final PreparedStatement ps,
final boolean fromBatch) throws Exception {
switch (dbColumn.getDbColumnType()) {
case BLOB:
if (isNull(value)) {
ps.setBytes(index, null);
break;
}

ps.setBytes(index, objectToArray(value));
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import static com.feedzai.commons.sql.abstraction.util.StringUtils.md5;
import static com.feedzai.commons.sql.abstraction.util.StringUtils.quotize;
import static java.lang.String.format;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.join;

/**
Expand Down Expand Up @@ -150,11 +149,6 @@ protected void setPreparedStatementValue(final PreparedStatement ps,
final boolean fromBatch) throws Exception {
switch (dbColumn.getDbColumnType()) {
case BLOB:
if (isNull(value)) {
ps.setBytes(index, null);
break;
}

ps.setBytes(index, objectToArray(value));
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.feedzai.commons.sql.abstraction.engine.impl.abs;

import com.feedzai.commons.sql.abstraction.ddl.DbColumn;
import com.feedzai.commons.sql.abstraction.ddl.DbColumnType;
import com.feedzai.commons.sql.abstraction.ddl.DbEntity;
import com.feedzai.commons.sql.abstraction.ddl.DbEntityType;
Expand All @@ -33,7 +32,6 @@
import com.feedzai.commons.sql.abstraction.engine.testconfig.DatabaseConfiguration;
import com.feedzai.commons.sql.abstraction.entry.EntityEntry;
import com.google.common.collect.Sets;
import java.sql.PreparedStatement;
import org.assertj.core.api.MapAssert;
import org.assertj.core.data.MapEntry;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2788,27 +2788,6 @@ public void testBlob() throws Exception {
assertEquals(updBlob, result.get(0).get("COL2").<BlobTest>toBlob());
}

/**
* Tests that persisting a null value to a BLOB type column persists a null value.
*
* @throws Exception If anything goes wrong on engine-related operations, namely adding an entity, persisting an
* entry and querying an entry.
*/
@Test
public void testBlobPersistNull() throws Exception {
DbEntity entity = dbEntity().name("TEST").addColumn("COL1", STRING).addColumn("COL2", BLOB)
.build();
engine.addEntity(entity);
EntityEntry entry = entry().set("COL1", "CENINHAS").set("COL2", null)
.build();

engine.persist("TEST", entry);

List<Map<String, ResultColumn>> result = engine.query(select(all()).from(table("TEST")));
assertEquals("CENINHAS", result.get(0).get("COL1").toString());
assertNull(result.get(0).get("COL2").toObject());
}

@Test
public void testBlobSettingWithIndexTest() throws Exception {
DbEntity entity = dbEntity().name("TEST").addColumn("COL1", STRING).addColumn("COL2", BLOB)
Expand Down

0 comments on commit a0e9f9a

Please sign in to comment.