Spring4D Marshmallow and TGuid fields - spring4d

how could I use TGuid type fields together with the Marshmallow ORM? Methods like FindOne, for example, expect parameters of type TValue and when trying to use im TGuid, the error occurs: incompatible types: TValue and TGUID.
thanks.
some information or example of how to make such use.

Related

Kotlin Retrofit: Need to convert Empty Array to Null

I'm new to Retrofit2. I have a legacy backend that's swapping a data object values with an empty array when the value is empty.
Scenario #1 Normal data response:
{data:{"name","john"}}
#Scenario 2 Alternate data response:
{data:[]}
Retrofit obviously can't map both data types without a converter (that I know of) automatically. When the data returns the empty array, the parser errors as expected.
I've attempted to use EmptyToNull converters, which fixes the error, but it also nulls out the normal data object returned in scenario #1.
My data classes are as follows:
data class ResponseData(
error: String,
message: String,
#SerializedName("data")
details: Details?
)
data class Details(
id: Int,
info: String
)
I've searched all over StackOverflow and other tutorials online, but I can't figure out how to detect the data / details value to ensure it's converted to null.
Thank you in advance!

What are the pros and cons of typing interface method parameters generic to make the interface more accessible?

I have an application that creates xml strings from abap structures using many different simple transformations and consequently many different abap structures.
I want to use a more flexible OO approach with an Interface to do this but due to the different structures the method signatures importing parameter is always different.
What are the pros and cons of typing the importing parameter generic instead so I can implement one method from one interface in each class handling the different transformations?
INTERFACE if_transformer.
METHODS transform_xml
IMPORTING isource_structure TYPE REF TO data
RETURNING VALUE(rxml_string) TYPE string.
ENDINTERFACE.
...
CLASS material_transformer definition.
PUBLIC SECTION.
INTERFACES if_transformer.
ENDCLASS.
CLASS material_transformer IMPLEMENTATION.
METHOD if_transformer~transform_xml.
FIELD-SYMBOLS <structure> TYPE concrete_structure.
ASSIGN isource_structure->* TO <structure>.
...
ENDMETHOD.
ENDCLASS.
The more specific your types, the earlier you notice errors, the easier your interfaces can be understood, and the less overhead you have in validating and casting/converting to the concrete types you want to handle.
For example, consider you type the method add_number as methods add_number importing n type i. The compiler will then reject the wrong statement add_number( 'xyz' ) and this class of errors will never make it into executable code. In turn, anybody reading that method's declaration can easily see that the method accepts only integer numbers, not floats, not packeds, and definitely not strings that contain numbers. Within the method, you can probably directly take the input n and do something with it, such as result = sum_so_far + n, without having to first validate the input or convert it to something else.
In contrast, consider you type the same method add_number as methods add_number importing n type ref to data. The compiler will gladly accept add_number( ref #( 'xyz' ) ), although it is complete nonsense; this class of error will thus only be detected at runtime, with type conversion exceptions that the code around this will have to react to in a meaningful way. People reading the method's declaration have to consult its docu, unit tests, and/or code to find out what kind of input it accepts; there is no way to guess it from the specification alone. Finally, within the method, you will first have to validate and convert the input before you can process it, such as is_integer( n ), cast, assign, and the like; in case the input is unacceptable, you need to find suitable error handling mechanisms, such as throwing nice exceptions.
With softly typed languages like JavaScript, using generic types is the default. However, history shows that people often prefer stronger typing, at least on the server side, leading to follow-up evolutions such as TypeScript or Deno. With strongly-typed languages like ABAP, the rule of thumb is to choose a data type as precise as possible.
Note that there are several levels of relaxation in generic types. For example, you should consider resorting to "partially" generic types like simple, which accepts ABAP structures, or standard table, which accepts tables, before resorting to the maximum-generic type data.
Excellent answer by Florian. I might add that an approach I've used in similar scenarios is to use a factory class that inspects the input data and instantiates the appropriate class to deal with it.

Type 'Collection' is not defined vb BC30002

I am attempting to migrate a legacy vb.net application to .net standard and turn it into a nuget package. A good amount of it has been straight forward. I am currently hung up on this error caused by functions like this.
Public Property ErrorMessages As Collection
Get
ErrorMessages = _errorMessages
End Get
Set(value As Collection)
_errorMessages = value
End Set
End Property
If i import System.Collections.ObjectModelCollection(Of T) it is asking me for a type and i am unsure how to proceed. It turns my code into
Collection(Of,) and expects a second argument. Has anyone faced this before? Do i use a different import statement or how is this dealt with in vb now?
You should almost certainly replace Collection with Dictionary(Of TKey, TValue), using the dictionary type from the System.Collections.Generic namespace.
Once again, this requires you to fill in the genetic type arguments TKey and TValue with the actual types. You need to figure out from context which type fits the collection. The value of TKey is probably String since that’s the only key type VB6’ collections properly support. And given the name (ErrorMessages), TValue is probably String as well.

How do I work with NEST when a type have BSonDocument as properties

We currently have an object that has BSon value types as properties.
When trying to use NEST (instead of elasticsearch.net) we get a serialization exception on AsBoolan property, which is part of the BsonValue type.
How should I use NEST when a type has BSon types.
Specifically we use a BSonDocument to have dynamic properties.
Thanks,
Ron

Is it possible to use IUserType as an Id in Fluent Hibernate mapping?

I have a IUserType defined class and I want to use it as an Id of a table. When using Native generator I get an exception
InnerException: System.InvalidOperationException
Message=Identity type must be integral (int, long, uint, ulong)
Source=FluentNHibernate
My next step is to investigate custom generators but I wanted to verify that its possible to use user types as Ids.
So, can it be done?