DB-1283 corrected copyField to preserve null state for PrimitiveField's

This commit is contained in:
ghidra1 2021-09-03 12:57:13 -04:00
parent 497fe46d19
commit 17c6f5b1e8
9 changed files with 38 additions and 1 deletions

View file

@ -188,6 +188,11 @@ public class BinaryField extends Field {
@Override
public BinaryField copyField() {
if (isNull()) {
BinaryField copy = new BinaryField();
copy.setNull();
return copy;
}
return new BinaryField(getBinaryData().clone());
}

View file

@ -149,6 +149,11 @@ public final class BooleanField extends PrimitiveField {
@Override
public BooleanField copyField() {
if (isNull()) {
BooleanField copy = new BooleanField();
copy.setNull();
return copy;
}
return new BooleanField(getLongValue() != 0);
}

View file

@ -154,6 +154,11 @@ public final class ByteField extends PrimitiveField {
@Override
public ByteField copyField() {
if (isNull()) {
ByteField copy = new ByteField();
copy.setNull();
return copy;
}
return new ByteField((byte) getLongValue());
}

View file

@ -126,6 +126,11 @@ public class FixedField10 extends FixedField {
@Override
public FixedField copyField() {
if (isNull()) {
FixedField10 copy = new FixedField10();
copy.setNull();
return copy;
}
return new FixedField10(hi8, lo2, false);
}

View file

@ -130,7 +130,7 @@ class IndexField extends Field {
}
@Override
public IndexField copyField() {
public IndexField copyField() { // null state not supported
return new IndexField(indexedField.copyField(), primaryKey.copyField());
}

View file

@ -154,6 +154,11 @@ public final class IntField extends PrimitiveField {
@Override
public IntField copyField() {
if (isNull()) {
IntField copy = new IntField();
copy.setNull();
return copy;
}
return new IntField((int) getLongValue());
}

View file

@ -157,6 +157,11 @@ public final class LongField extends PrimitiveField {
@Override
public LongField copyField() {
if (isNull()) {
LongField copy = new LongField();
copy.setNull();
return copy;
}
return new LongField(getLongValue());
}

View file

@ -154,6 +154,11 @@ public final class ShortField extends PrimitiveField {
@Override
public ShortField copyField() {
if (isNull()) {
ShortField copy = new ShortField();
copy.setNull();
return copy;
}
return new ShortField((short) getLongValue());
}

View file

@ -158,6 +158,7 @@ public class DBFixedKeySparseIndexedTableTest extends AbstractGenericTest {
// all fields correspond to a sparse columns and
// should have a null state initially
assertTrue(f.isNull());
assertTrue(f.copyField().isNull());
}
if (i < cnt) {
@ -254,6 +255,7 @@ public class DBFixedKeySparseIndexedTableTest extends AbstractGenericTest {
for (int n = columnIndex + 1; n < cnt; n++) {
Field f = r.getField(n);
assertTrue(f.isNull());
assertTrue(f.copyField().isNull());
}
++recordIndex;