Getting requested entity synonym rather than the reference value - actions-on-google

When I do app.getArgument("ARGUMENT_NAME") it returns the reference value for synonym. How do I determine the requested synonym rather than the reference value?

If you look at the JSON, this used to be available in the "result"."parameters"."name.original" field, but that seems to have changed at some point.
Now you can find it in the parameters for any of the contexts. So if you are using JavaScript and have the JSON in a variable named "body" and the argument name in a variable named "name", you can probably evaluate something like
body.result.contexts[0].parameters[`${name}.original`]
to get the value you want.

Related

Apache AGE - Creating Functions With Multiple Parameters

I was looking inside the create_vlabel function and noted that to get the graph_name and label_name it is used graph_name = PG_GETARG_NAME(0) and label_name = PG_GETARG_NAME(1). Since these two variables are also passed as parameters, I was thinking that, if I wanted to add one more parameter to this function, then I would need to use PG_GETARG_NAME(2) to get this parameter and use it in the function's logic. Is my assumption correct or do I need to do more tweaks to do this?
You are correct, but you also need to change the function signature in the "age--1.2.0.sql" file, updating the arguments:
CREATE FUNCTION ag_catalog.create_vlabel(graph_name name, label_name name, type new_argument)
RETURNS void
LANGUAGE c
AS 'MODULE_PATHNAME';
Note that all arguments come as a "Datum" struct, and PG_GETARG_NAME automatically converts it to a "Name" struct. If you need an argument as int32, for example, you should use PG_GETARG_INT32(index_of_the_argument), for strings, PG_GETARG_CSTRING(n), and so on.
Yes, your assumption is correct. If you want to add an additional parameter to the create_vlabel function in PostgreSQL, you can retrieve the value of the third argument using PG_GETARG_NAME(2). Keep in mind that you may need to make additional modifications to the function's logic to handle the new parameter correctly.
The answers given by Fahad Zaheer and Marco Souza are correct, but you can also create a Variadic function, with which you could have n number of arguments but one drawback is that you would have to check the type yourself. You can find more information here. You can also check many Apache Age functions made this way e.g agtype_to_int2.

Is empty string value generally allowed by the FIX protocol?

When I look at the definition of a String type in the FIX protocol (e.g. here or here), I don't see a minimum length specified. Is it allowed to use empty strings? One online decoder seems to accept an empty string value (see tag 320), an other complains that it's invalid.
The FIX 4.4 specification states the following (emphasis in the original text):
Each message is constructed of a stream of <tag>=<value> fields with a
field delimiter between fields in the stream. Tags are of data type
TagNum. All tags must have a value specified. Optional fields without
values should simply not be specified in the FIX message. A Reject
message is the appropriate response to a tag with no value.
That strongly suggests (but does not unambiguously state) to me that the use of an empty value for a string is invalid. It is unsurprising to me that different FIX implementations might treat this edge case in different ways. So, I think the best approach is to avoid using empty values for strings.
+1 for Ciaran's and Grant's answer/comments. Just want to add something.
I generally suggest to look up things like this in the most current specification since they usually have been refined/reworded/clarified to eliminate unclear or ambiguous statements from older specs.
The answer is on the very page you link to in your question (emphasis mine, search for "Well-formed field"): https://www.fixtrading.org/standards/tagvalue-online/#field-syntax
A well-formed field has the form:
tag=value<SOH>
A field shall be considered malformed if any of the following occurs as a result of encoding:
the tag is empty
the tag delimiter is missing
the value is empty
the value contains an <SOH> character and the datatype of the field is not data or XMLdata
the datatype of the field is data and the field is not immediately preceded by its associated Length field.

In PostgreSQL, which types can be cast with the type name first?

Reading the PostgreSQL docs, I see that you can cast a longish bit of text to xml like this:
SELECT xml '<long>long text, may span many lines</long>'
SELECT xml '...'
Curious, I found that I could do the same with JSON:
SELECT json '{"arg1":"val1", <more args spanning many lines>}'
(I couldn't find an official reference for this one. It just works!)
By contrast, this does not work:
SELECT float8 3.14159
I like this alternate syntax from a readability perspective. Now I'm looking for a reference listing which types may be specified up front like this. but I haven't found it yet.
Any pointers?
The documentation says:
A constant of an arbitrary type can be entered using any one of the following notations:
type 'string'
'string'::type
CAST ( 'string' AS type )
The string constant's text is passed to the input conversion routine for the type called type. The result is a constant of the indicated type. The explicit type cast can be omitted if there is no ambiguity as to the type the constant must be (for example, when it is assigned directly to a table column), in which case it is automatically coerced.
The form you are asking about is the first one.
So this can be used for all PostgreSQL types.
Note that the data must be specified as a string literal (in single or dollar quotes) when you use that syntax.

In JSON-RPC 1.0, can a response object's "result" member be an Array?

Section 1.2 of the JSON-RPC 1.0 specification says, "result - The Object that was returned by the invoked method. This must be null in case there was an error invoking the method."
This suggests that the result should be either an Object or null. However, the examples in Section 4 show results that are Strings or Numbers.
I presume that the spec authors intended for all types (including Arrays) to be allowed, and that Section 1.2 is written wrongly. Is there an authoritative source that can confirm or refute this?
(Side note: The v2.0 specs are better, albeit still a bit ambiguous. Section 5 simply says "The value of this [result] member is determined by the method invoked on the Server" but at least the examples do show an Array as a result)
Returning any json value ( including arrays) is fine per the specification.
The phrasing is a bit poor on that part... should have been 'value' instead of 'object'. Reading into it, the wording and speculating.... "object" in the way it is written refers to what is being returned as result of invocation... rather than a 'json object' that is returned on the wire... think 'string object, array object, etc.'.

RESTful query string convention for "value is present"

Say we have a URL like:
http://example.org/resources/?property=1
This will return every resource where the value of property is 1, pretty straightforward. But what if property is nullable, and we want to search for all resources with a non-null query string? I can think of a couple of ideas:
http://example.org/resources/?property
http://example.org/resources/?property=present
But the first one requires treating "" as a special value (and distinguishing it from http://example.org/resources/, where property isn't even in the URL -- which isn't necessarily straightforward in some frameworks), and the second requires declaring and documenting that present is a special value, which goes against the general principle that good API URLs ought to be obvious and unsurprising. And what if property is a free-text field that can't have any reserved words? Is there a well-accepted way of doing this?