From: Alan T. DeKok Date: Wed, 19 Jan 2022 16:27:04 +0000 (-0500) Subject: more notes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=949d472733f48b6bf2401ab02f8f124a53d656df;p=thirdparty%2Ffreeradius-server.git more notes --- diff --git a/doc/antora/modules/reference/pages/unlang/edit.adoc b/doc/antora/modules/reference/pages/unlang/edit.adoc index 0836877937..1ecc87f1b7 100644 --- a/doc/antora/modules/reference/pages/unlang/edit.adoc +++ b/doc/antora/modules/reference/pages/unlang/edit.adoc @@ -28,7 +28,7 @@ An edit statement has the following standard syntax: Where we have: -__:: The name of a list or an attribute. +__:: An xref:reference:unlang/attr.adoc[attribute reference], such as the name of a list or an attribute. __:: The operator such as `=`, `:=`, etc. @@ -68,9 +68,11 @@ the list operations are simple, and well defined. | := | Override the list to the contents with the __. If the list already exists, its value is over-written. If the list does not exist, it is created, and the contents set to thex value of the __ | += | Perform list append operation. The contents of the __ are appended to the __. The resulting list is __. | ^= | Perform a list prepend operation. The contents of the __ are prepended to the __. The resulting list is __. -| -= | Remove attributes from the list which match the __ +| -= | Remove attributes from the __ which match the __ | \|= | Perform a list union. The resulting list has all of the contents of the original __, and the __ list. -| \<= | Perform a priority merge of two lists. The resulting list has all of the contents of the original __, and a copy of any __ list attribute which is not already in __. +| \&= | Perform a list intersection. The resulting list has only the attributes which are in both the origianl __, and the __ list. +| >= | Perform a priority merge of two lists. The resulting list has all of the contents of the original __, and of all __ list attributes which are not already in __. +| \<= | Perform a priority merge of two lists. The resulting list has all of the contents of the original __, and of all __ list attributes which are not in __ are left alone.. |===== The __ can be a reference to another list (e.g. `request`, @@ -140,8 +142,6 @@ As a special case, where the right side is an xref:reference:unlang/attr.adoc[attribute reference], it is possible to use `+=`. -This example - .Appending the `User-Name` attribute from the `request` list, to the `reply` list. ==== [source,unlang] @@ -217,6 +217,35 @@ copies all of the `request` list contents to the `reply` list. ---- ==== +=== Parsing strings as lists + +It is also possible to have strings on the __ of a list +assignment. This funtionality is most useful for putting attribute +lists into a database, and then reading them back programmatically. + +.Assigning attributes taken from a string +==== +[source,unlang] +---- +&reply += "Filter-Id = \"foo\"" +---- +==== + +The above example has the same result as the earlier example of adding +`Filter-Id` to the `reply`, using an "in-place" list. + +.Append the contents of the `request` list to the `reply` list. +==== +[source,unlang] +---- +&reply += "%{sql:SELECT pairs FROM pair_table WHERE username = '%{User-Name}'}" +---- +==== + +In this example, the `pair_table` could contain two columns: +`username` and `pairs`. The `pairs` column could have free-form text +strings, such as `Filter-Id = "foo"`. + == Attribute Editing .Syntax