Skip to content

Commit

Permalink
Add documentation for #632 (scalar-query to get a Json value out of a…
Browse files Browse the repository at this point in the history
… database)
  • Loading branch information
Cédric L. Charlier committed Dec 14, 2021
1 parent 58ebe1d commit e18c73a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _automation/settings-load.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: automation
title: Load settings
prev_section: template-add
next_section: variable-include
next_section: settings-csv-profile
permalink: /automation/settings-load/
---
For [settings (defaults and references)](../../docs/config-defaults-references), the command is implicit and is always an *add*. You must specify a parameter option with the help of the keywords *reference* or *default* to specify what you want to define. If the option is a reference, you must provide its name. Else you need to specify if the default is for *sut* (system-under-tests) or *assert* with the help of corresponding keywords. Then you need to specify which feature of the setting will be added. Only *connectionString* has been tested but others should work. Then finally, you need to specify the value that you want to set.
Expand Down
32 changes: 31 additions & 1 deletion _documentation/primitive-result-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,37 @@ Most of the features described for an Xml are also available for a Json. You'll
<result-set>
{% endhighlight %}

Note that the default implementation of JSON path doesn't support to go back to a parent level. This version of Json Path is supporting ```!``` has a way to indicate that you'll like to go to the ancestror. This syntax is only supported at the beginning of the JSON path.
Note that the default implementation of JSON path doesn't support to go back to a parent level. This version of Json Path is supporting ```!``` has a way to indicate that you'll like to go to the ancestor. This syntax is only supported at the beginning of the JSON path.

### JSON from SQL query

It's possible to extract a JSON from a database with the help of a SQL query. To achieve this, in the `json-source` element, the location of the JSON token must be specified with the help of a `query-scalar`. `connection-string` and other attributes related to the elements of the `query` family can be specified as usual.

{% highlight xml %}
<result-set>
<json-source>
<query-scalar>
select cast (
(
select
NationalIdNumber as [nid],
month(BirthDate) as [dob.month],
year(BirthDate) as [dob.year]
from
[HumanResources].[Employee] e
for json path
) as nvarchar(max)
) as x
</query-scalar>
<json-path>
<from>$.[*]</from>
<select>$.nid</select>
<select>$.dob.month</select>
<select>$.dob.year</select>
</json-path>
<json-source>
<result-set>
{% endhighlight %}

### Rest API

Expand Down

0 comments on commit e18c73a

Please sign in to comment.