Closed OyvindLGjesdal closed 4 years ago
@OyvindLGjesdal Thanks a lot.
@oetterer You may do the honours. :)
I think my first assumption about LUA tables was correct, that the order cannot be guaranteed. That implies that the sep can be inserted anywhere, and will be applied for all items in the dataStoreType2
. Is this how it works?
@OyvindLGjesdal Unfortunately, the relavant bit of information can be found at the very end of the set documentation:
Note however: lua does not maintain the order in an associative array. Using parameters for set like the separator or the template parameter requires a strict parameter order in which case you must use the table format as shown with dataStoreType2 in the example above.
meaning, when you define your query like
query = {
'property1_name=' .. value1,
'property2_name=' .. value2 .. ',' .. value3,
'+sep=,',
}
the order is maintained. When you use
query = {
property1_name = 'value',
property2_name = 'value',
+sep = ',',
}
lua might (and probably will) scramble the order.
This PR addresses or contains: documentation
It was not obvious to me that the
sep=,
andtemplate
should be added as the next sibling(s) in the table. When reading the documentation, I tried the following:until looking at https://github.com/SemanticMediaWiki/SemanticScribunto/blob/b81e565b6991b64ff2a1ca5f5f6c004fd1de3fad/tests/phpunit/Integration/JSONScript/Fixtures/module.smw.lua#L71 which has an example using +sep.