Closed armiol closed 11 months ago
@yevhenii-nadtochii PTAL. I feel it won't hurt to have another pair of eyes on this.
@yevhenii-nadtochii
But I would add somewhere in docs to DsColumnMapping.customMapping() that this method is a workaround for AbstractColumnMapping.setupCustomMapping(...). This word pops up when I see these two similar-named methods and their docs, but it is not said explicitly.
For this library, this is not a workaround. DsColumnMapping.setupCustomMapping()
is made final
, so nobody is now able to override it. The only extension point is DsColumnMapping.customMapping()
, which is why it is now explicitly marked with @SPI
.
Also, if such is a wish, it is possible to create a descendant from AbstractColumnMapping
, in spirit of port-based architecture, and use it to configure DatstoreStorageFactory
. It has not changed, but generally speaking that would be strange to see from Spine users.
This PR reproduces and addresses core-java#1536.
Previously, it was not possible to clear columns of some Proto types, since it was not possible to distinguish between meaningful "default values" set to columns on purpose, and those "default values" which in fact signalized of "no value set".
Changing the API of
DsColumnMapping
:exclamation: This is a breaking change.
Previously, SPI users could only extend
DsColumnMapping
's behavior by overriding this method:It was good enough if one wanted to append their mapping rules. But such an approach did not allow to re-define the existing (framework-default) mapping — since a builder of
ImmutableMap
was passed, preventing from having duplicate keys.Now, the API for SPI users implies overriding another method:
This one allows to return an immutable map of mappings, combining them into the final result, giving priority to those values which were provided by SPI users.
Please see the documentation for
DsColumnMapping
for more details.How to use it
Referring to the original issue, end-users may configure how
Timestamp.getDefaultValue()
is stored for some column. In the example below, a Datastore-specificnull
is written for such values to the corresponding property of respective DatastoreEntity
:Updates to
TestDatastoreStorageFactory
Additionally, this changeset updates the API of
TestDatastoreStorageFactory
utility to allow access to two features:DatastoreWrapper
via public API, which is useful to verify the actual content of Datastore entities written.See
TestDatastoreStorageFactory
for detail, and have a look at the usage example inDsProjectionColumnsTest
.The library version is set to
1.9.1
.