Skip to content
Snippets Groups Projects

BUG: replacement ids interfering with external ids

Merged Timm Fitschen requested to merge f-mariadb-48 into dev
All threads resolved!
3 files
+ 8
12
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -87,19 +87,19 @@ public class DatabaseUtils {
private static void processPropertiesStage1(
final List<Property> stage1Inserts, final Property p, final EntityInterface e) {
if (!p.isDescOverride()
&& !p.isNameOverride()
&& !p.isDatatypeOverride()
&& (!p.hasProperties() || hasUniquePropertyId(p, e))
&& !(p.getDatatype() instanceof AbstractCollectionDatatype)) {
stage1Inserts.add(p);
processSubPropertiesStage1(stage1Inserts, p);
} else {
Replacement r = new Replacement(p);
stage1Inserts.add(r);
stage1Inserts.add(r.replacement);
processSubPropertiesStage1(stage1Inserts, r);
}
processSubPropertiesStage1(stage1Inserts, p);
}
public static void deriveStage2Inserts(
@@ -109,19 +109,17 @@ public class DatabaseUtils {
EntityInterface entity) {
for (final Property p : stage1Inserts) {
if (p instanceof Replacement) {
EntityID replacementId = replacementIds.pop();
((Replacement) p).setReplacementId(replacementId);
if (p.hasProperties()) {
for (Property subP : p.getProperties()) {
subP.setDomain(p);
stage2Inserts.add(subP);
}
if (!p.hasId() || p.getId().isTemporary()) {
EntityID replacementId = replacementIds.pop();
((Replacement) p).setReplacementId(replacementId);
}
} else {
if (p.hasProperties()) {
for (Property subP : p.getProperties()) {
}
if (p.hasProperties()) {
if (p instanceof Replacement && ((Replacement) p).isStage2Replacement()) {
stage2Inserts.add(((Replacement) p).replacement);
}
for (Property subP : p.getProperties()) {
if (!subP.hasProperties()) {
stage2Inserts.add(subP);
}
}
@@ -142,9 +140,12 @@ public class DatabaseUtils {
private static void processSubPropertiesStage1(
final List<Property> stage1Inserts, final EntityInterface p) {
for (final Property subP : p.getProperties()) {
subP.setDomain(p);
if (subP.hasProperties()) {
stage1Inserts.add(new Replacement(subP));
processSubPropertiesStage1(stage1Inserts, subP);
Replacement r = new Replacement(subP);
r.setStage2Replacement(true);
stage1Inserts.add(r);
processSubPropertiesStage1(stage1Inserts, r);
}
}
}
@@ -164,9 +165,10 @@ public class DatabaseUtils {
if (desc != null) {
p.desc = desc;
}
final String type = bytes2UTF8(rs.getBytes("type_override"));
if (type != null) {
p.type = type;
final String type_id = bytes2UTF8(rs.getBytes("type_id_override"));
if (type_id != null) {
p.type_id = type_id;
p.type_name = bytes2UTF8(rs.getBytes("type_name_override"));
}
final String coll = bytes2UTF8(rs.getBytes("collection_override"));
if (coll != null) {
@@ -221,7 +223,8 @@ public class DatabaseUtils {
final SparseEntity ret = parseNameRoleACL(rs);
ret.id = rs.getString("EntityID");
ret.description = bytes2UTF8(rs.getBytes("EntityDesc"));
ret.datatype = bytes2UTF8(rs.getBytes("Datatype"));
ret.datatype_id = bytes2UTF8(rs.getBytes("DatatypeID"));
ret.datatype_name = bytes2UTF8(rs.getBytes("DatatypeName"));
ret.collection = bytes2UTF8(rs.getBytes("Collection"));
ret.filePath = bytes2UTF8(rs.getBytes("FilePath"));
@@ -300,6 +303,14 @@ public class DatabaseUtils {
if (pp.status.equals(ReplacementStatus.REPLACEMENT.name())) {
replacements.put(pp.value, null);
}
if (pp.subProperties != null) {
for (ProtoProperty subP : pp.subProperties) {
if (subP.status.equals(ReplacementStatus.REPLACEMENT.name())) {
replacements.put(subP.value, null);
}
}
}
}
Iterator<ProtoProperty> iterator = properties.iterator();
while (iterator.hasNext()) {
@@ -325,6 +336,13 @@ public class DatabaseUtils {
if (pp.status.equals(ReplacementStatus.REPLACEMENT.name())) {
replace(pp, replacements.get(pp.value), isHead);
}
if (pp.subProperties != null) {
for (ProtoProperty subP : pp.subProperties) {
if (subP.status.equals(ReplacementStatus.REPLACEMENT.name())) {
replace(subP, replacements.get(subP.value), isHead);
}
}
}
if (pp.collValues != null) {
// sort
pp.collValues.sort(
@@ -358,7 +376,8 @@ public class DatabaseUtils {
}
pp.desc = replacement.desc;
pp.name = replacement.name;
pp.type = replacement.type;
pp.type_id = replacement.type_id;
pp.type_name = replacement.type_name;
pp.collection = replacement.collection;
pp.value = replacement.value;
pp.collValues = replacement.collValues;
Loading