|
|
@ -135,6 +135,7 @@ var private config array<StorageItem> storage; |
|
|
|
|
|
|
|
|
|
|
|
var private const int LATIN_LETTERS_AMOUNT; |
|
|
|
var private const int LATIN_LETTERS_AMOUNT; |
|
|
|
var private const int LOWER_A_CODEPOINT, UPPER_A_CODEPOINT; |
|
|
|
var private const int LOWER_A_CODEPOINT, UPPER_A_CODEPOINT; |
|
|
|
|
|
|
|
var private const string JSONPOINTER_NEW_ARRAY_ELEMENT; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Since `DBRecord` represents JSON array or object, we can use |
|
|
|
* Since `DBRecord` represents JSON array or object, we can use |
|
|
@ -422,16 +423,18 @@ public final function bool SaveObject( |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
directContainer = pointer.record; |
|
|
|
directContainer = pointer.record; |
|
|
|
|
|
|
|
itemKey = __().text.ToString(jsonPointer.Pop(true)); |
|
|
|
if (directContainer.isJSONArray) |
|
|
|
if (directContainer.isJSONArray) |
|
|
|
{ |
|
|
|
{ |
|
|
|
index = jsonPointer.PopNumeric(true); |
|
|
|
index = jsonPointer.PopNumeric(true); |
|
|
|
|
|
|
|
if (index < 0 && itemKey == JSONPOINTER_NEW_ARRAY_ELEMENT) { |
|
|
|
|
|
|
|
index = directContainer.GetStorageLength(); |
|
|
|
|
|
|
|
} |
|
|
|
if (index < 0) { |
|
|
|
if (index < 0) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else { |
|
|
|
{ |
|
|
|
|
|
|
|
itemKey = __().text.ToString(jsonPointer.Pop(true)); |
|
|
|
|
|
|
|
index = directContainer.FindItem(itemKey); |
|
|
|
index = directContainer.FindItem(itemKey); |
|
|
|
} |
|
|
|
} |
|
|
|
directContainer.SetItem(index, ConvertObjectToItem(newItem), itemKey); |
|
|
|
directContainer.SetItem(index, ConvertObjectToItem(newItem), itemKey); |
|
|
@ -624,16 +627,18 @@ public final function Database.DBQueryResult IncrementObject( |
|
|
|
return DBR_InvalidPointer; |
|
|
|
return DBR_InvalidPointer; |
|
|
|
} |
|
|
|
} |
|
|
|
directContainer = pointer.record; |
|
|
|
directContainer = pointer.record; |
|
|
|
|
|
|
|
itemKey = __().text.ToString(jsonPointer.Pop(true)); |
|
|
|
if (directContainer.isJSONArray) |
|
|
|
if (directContainer.isJSONArray) |
|
|
|
{ |
|
|
|
{ |
|
|
|
index = jsonPointer.PopNumeric(true); |
|
|
|
index = jsonPointer.PopNumeric(true); |
|
|
|
|
|
|
|
if (index < 0 && itemKey == JSONPOINTER_NEW_ARRAY_ELEMENT) { |
|
|
|
|
|
|
|
index = directContainer.GetStorageLength(); |
|
|
|
|
|
|
|
} |
|
|
|
if (index < 0) { |
|
|
|
if (index < 0) { |
|
|
|
return DBR_InvalidPointer; |
|
|
|
return DBR_InvalidPointer; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else { |
|
|
|
{ |
|
|
|
|
|
|
|
itemKey = __().text.ToString(jsonPointer.Pop(true)); |
|
|
|
|
|
|
|
index = directContainer.FindItem(itemKey); |
|
|
|
index = directContainer.FindItem(itemKey); |
|
|
|
} |
|
|
|
} |
|
|
|
if (directContainer.IncrementItem(index, object, itemKey)) { |
|
|
|
if (directContainer.IncrementItem(index, object, itemKey)) { |
|
|
@ -752,6 +757,8 @@ private final function bool IncrementItem( |
|
|
|
} |
|
|
|
} |
|
|
|
if (IncrementItemByObject(itemToIncrement, object)) |
|
|
|
if (IncrementItemByObject(itemToIncrement, object)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// Increment object cannot overwrite existing `DBRecord` with |
|
|
|
|
|
|
|
// other value, so it's safe to skip cleaning check |
|
|
|
storage[index] = itemToIncrement; |
|
|
|
storage[index] = itemToIncrement; |
|
|
|
storage[index].k = itemName; |
|
|
|
storage[index].k = itemName; |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -1157,4 +1164,7 @@ defaultproperties |
|
|
|
LATIN_LETTERS_AMOUNT = 26 |
|
|
|
LATIN_LETTERS_AMOUNT = 26 |
|
|
|
LOWER_A_CODEPOINT = 97 |
|
|
|
LOWER_A_CODEPOINT = 97 |
|
|
|
UPPER_A_CODEPOINT = 65 |
|
|
|
UPPER_A_CODEPOINT = 65 |
|
|
|
|
|
|
|
// JSON Pointers allow using "-" as an indicator that element must be |
|
|
|
|
|
|
|
// added at the end of the array |
|
|
|
|
|
|
|
JSONPOINTER_NEW_ARRAY_ELEMENT = "-" |
|
|
|
} |
|
|
|
} |