From c4e65aa6c4af4239f36510cb6d472b1387f47d94 Mon Sep 17 00:00:00 2001 From: dbs Date: Mon, 26 Oct 2009 14:31:56 +0000 Subject: [PATCH] Scrub smartquotes / emdashes from JSONGrammar.xml as well git-svn-id: svn://svn.open-ils.org/ILS/trunk@14604 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- docs/TechRef/JSONGrammar.xml | 206 +++++++++++++++++------------------ 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/docs/TechRef/JSONGrammar.xml b/docs/TechRef/JSONGrammar.xml index 4812128c22..9c3d890d08 100644 --- a/docs/TechRef/JSONGrammar.xml +++ b/docs/TechRef/JSONGrammar.xml @@ -126,7 +126,7 @@ When json_query requires an integral value, it will usually accept a quoted string - and convert it to an integer by brute force – to zero if necessary. Likewise it may + and convert it to an integer by brute force -- to zero if necessary. Likewise it may truncate a floating point number to an integral value. Scientific notation will be accepted but may not give the intended results. @@ -216,7 +216,7 @@ FROM Clause - The object identified by “from” encodes the FROM clause of + The object identified by "from" encodes the FROM clause of the SQL. The associated value may be a string, an array, or a JSON object. @@ -253,7 +253,7 @@ If from_list is a JSON array, then it represents a table-like function from which the SQL statement will select rows, using a SELECT clause consisting - of “SELECT *” (regardless of the select_list supplied by the method parameter). + of "SELECT *" (regardless of the select_list supplied by the method parameter). The first entry in the array is the name of the function. It must be a string @@ -306,12 +306,12 @@ class_name ':' '{' - [ '”type”' ':' string ] - [ '”field”' ':' field_name ] - [ '”fkey”' ':' field_name ] - [ '”filter”' ':' where_condition ] - [ '”filter_op”' ':' string ] - [ '”join”' ':' join_list ] + [ '"type"' ':' string ] + [ '"field"' ':' field_name ] + [ '"fkey"' ':' field_name ] + [ '"filter"' ':' where_condition ] + [ '"filter_op"' ':' string ] + [ '"join"' ':' join_list ] '}' @@ -319,24 +319,24 @@ - The data portion of the “join_type” entry tells json_query + The data portion of the "join_type" entry tells json_query whether to use a left join, right join, full join, or inner join. The values - “left”, “right”, and “full”, + "left", "right", and "full", in upper, lower, or mixed case, have the obvious meanings. If the - “join_type” entry has any other value, or is not present, + "join_type" entry has any other value, or is not present, json_query constructs an inner join. - The “field” and “fkey” attributes specify the - columns to be equated in the join condition. The “field” + The "field" and "fkey" attributes specify the + columns to be equated in the join condition. The "field" attribute refers to the column in the joined table, i.e. the one named by the - join_def. The “fkey” attribute refers to the + join_def. The "fkey" attribute refers to the corresponding column in the other table, i.e. the one named outside the - join_def – either the top-level table or a table named by some + join_def -- either the top-level table or a table named by some other join_def. - It may be tempting to suppose that “fkey” stands for “foreign key”, + It may be tempting to suppose that "fkey" stands for "foreign key", and therefore refers to a column in the child table that points to the key of a parent table. Resist the temptation; the labels are arbitrary. The json_query method doesn't care which table is the parent and which is the child. @@ -374,9 +374,9 @@ - Note in this example that “fkey” refers to a column of the - class “aou”, and “field” refers to a - column of the class “asv”. + Note in this example that "fkey" refers to a column of the + class "aou", and "field" refers to a + column of the class "asv". If you specify only one of the two columns, json_query will try to identify the @@ -396,32 +396,32 @@ method always uses a simple equality condition. - Using a “filter” entry in the join_def, you can apply one + Using a "filter" entry in the join_def, you can apply one or more additional conditions to the JOIN clause, typically to restrict the join to certain rows of the joined table. The data associated with the - “filter” key is the same sort of + "filter" key is the same sort of where_condition that you use for a WHERE clause (discussed below). - If the string associated with the “filter_op” entry is - “OR” in upper, lower, or mixed case, then the json_query + If the string associated with the "filter_op" entry is + "OR" in upper, lower, or mixed case, then the json_query method uses OR to connect the standard join condition to any additional - conditions supplied by a “filter” entry. + conditions supplied by a "filter" entry. (Note that if the where_condition supplies multiple conditions, they will be connected by AND. You will probably want to move - them down a layer – enclose them in parentheses, in effect – to avoid a + them down a layer -- enclose them in parentheses, in effect -- to avoid a confusing mixture of ANDs and ORs.) - If the “filter_op” entry carries any other value, or if + If the "filter_op" entry carries any other value, or if it is absent, then the json_query method uses AND. In the absence of a - “filter” entry, “filter_op” has no effect. + "filter" entry, "filter_op" has no effect. - A “join” entry in a join_def specifies + A "join" entry in a join_def specifies another layer of join. The class named in the subjoin is joined to the class named by the join_def to which it is subordinate. By this means you can encode multiple joins in a hierarchy. @@ -430,7 +430,7 @@ SELECT Clause - If a query does not contain an entry for “select”, json_query + If a query does not contain an entry for "select", json_query will construct a default SELECT clause. The default includes every non-virtual field from the top-level class of the FROM clause, as defined by the IDL. The result is similar to SELECT *, except: @@ -473,7 +473,7 @@ field_list - 'null' | '”*”' + 'null' | '"*"' @@ -481,7 +481,7 @@ If a field_list is either the JSON reserved word null (in lower case) or an asterisk in double quotes, json_query constructs a - default SELECT list – provided that the class is the top-level class of the + default SELECT list -- provided that the class is the top-level class of the query. If the class belongs to a join somewhere, json_query ignores the field_list. @@ -501,7 +501,7 @@ If the array is empty, json_query will construct a default SELECT list for - the class – again, provided that the class is the top-level class in the query. + the class -- again, provided that the class is the top-level class in the query. In the simplest case, a field specification may name a non-virtual field @@ -529,7 +529,7 @@ in the field definition for the field in the IDL, the tag - “il8n” is present and true; + "il8n" is present and true; the query does not include the @@ -547,9 +547,9 @@ field_spec '{' - '”column”' ':' - [ ',' '”alias”' ':' string ] - [ ',' '”aggregate”' ':' boolean ] + '"column"' ':' + [ ',' '"alias"' ':' string ] + [ ',' '"aggregate"' ':' boolean ] [ ',' transform_spec ] '}' @@ -558,19 +558,19 @@ - The “column” entry provides the column name, which must + The "column" entry provides the column name, which must be defined as non-virtual in the IDL. - The “alias” entry provides a column alias. If no alias + The "alias" entry provides a column alias. If no alias is specified, json_query uses the column name as its own alias. - The “aggregate” entry has no effect on the SELECT clause + The "aggregate" entry has no effect on the SELECT clause itself. Rather, it affects the construction of a GROUP BY class. If there - is an “aggregate” entry for any field, then json_query builds + is an "aggregate" entry for any field, then json_query builds a GROUP BY clause listing every column that is not tagged - for aggregation (or that carries an “aggregate” entry with + for aggregation (or that carries an "aggregate" entry with a value of false). If all columns are tagged for aggregation, then json_query omits the GROUP BY clause. @@ -580,9 +580,9 @@ transform_spec - '”transform”' ':' string ] - [ ',' '”result_field” ':' string ] - [ ',' '”params” ':' param_list ] + '"transform"' ':' string ] + [ ',' '"result_field" ':' string ] + [ ',' '"params" ':' param_list ] @@ -591,20 +591,20 @@ When a transform_spec is present, json_query selects the return value of a function instead of selecting the column directly. The entry - for “transform” provides the name of the function, and the - column name (as specified by the “column” tag), qualified by + for "transform" provides the name of the function, and the + column name (as specified by the "column" tag), qualified by the class name, is the argument to the function. For example, you might use such a function to format a date or time, or otherwise transform a column value. You might also use an aggregate function such as SUM, COUNT, or MAX (possibly - together with the “aggregate” tag). + together with the "aggregate" tag). - The “result_field” entry, when present, specifies a subcolumn + The "result_field" entry, when present, specifies a subcolumn of the function's return value. The resulting SQL encloses the function call in parentheses, and follows it with a period and the subcolumn name. - The “params” entry, if present, provides a possibly empty + The "params" entry, if present, provides a possibly empty array of additional parameter values, either strings, numbers, or nulls: @@ -652,7 +652,7 @@ JSON requires that every key string be unique within an object. This requirement imposes some awkward limitations on a JSON query. For example, you might want to express two conditions for the same column: id > 10 and id != 25. Since each of - those conditions would have the same key string, namely “id”, you can't put them + those conditions would have the same key string, namely "id", you can't put them into the same JSON object. The solution is to put such conflicting conditions in separate JSON objects, and put the objects into an array: @@ -736,7 +736,7 @@ The resulting SQL is enclosed in parentheses, and qualifies the columns with the specified class name. This syntax provides a mechanism to shift the class - context – i.e. to refer to one class in a context that would otherwise refer to + context -- i.e. to refer to one class in a context that would otherwise refer to a different class. Ordinarily the class name must be a valid non-virtual class defined in the IDL, and applicable to the associated where_condition. There is at @@ -756,14 +756,14 @@ - ...even though neither “abc”, nor “xyz”, - nor “frobozz” is defined in the IDL. The class name - “abc” isn't used at all because the “+xyz” + ...even though neither "abc", nor "xyz", + nor "frobozz" is defined in the IDL. The class name + "abc" isn't used at all because the "+xyz" operator overrides it. Such a query won't fail until json_query tries to execute it in the database. The other operators that may occur at this level all begin with a minus sign, and they all represent familiar SQL operators. For example, the - “-or” operator joins the conditions within a + "-or" operator joins the conditions within a where_condition by OR (instead of the default AND), and encloses them all in parentheses: @@ -771,29 +771,29 @@ condition - '”-or”' ':' where_condition + '"-or"' ':' where_condition - In fact the “-or” operator is the only way to get OR into + In fact the "-or" operator is the only way to get OR into the WHERE clause. - The “-and” operator is similar, except that it uses AND: + The "-and" operator is similar, except that it uses AND: condition - '”-and”' ':' where_condition + '"-and"' ':' where_condition - Arguably the “-and” operator is redundant, because you can + Arguably the "-and" operator is redundant, because you can get the same effect by wrapping the subordinate where_condition in a JSON array. Either technique merely adds a layer of parentheses, since AND connects successive conditions by default. - The “-not” operator expands the subordinate + The "-not" operator expands the subordinate where_condition within parentheses, and prefaces the result with NOT: @@ -801,24 +801,24 @@ condition - '”-not”' ':' where_condition + '"-not"' ':' where_condition - The “-exists” or “-not-exists” operator + The "-exists" or "-not-exists" operator constructs a subquery within an EXISTS or NOT EXISTS clause, respectively: condition - '”-exists”' ':' query + '"-exists"' ':' query condition - '”-not-exists”' ':' query + '"-not-exists"' ':' query @@ -826,7 +826,7 @@ The remaining kinds of condition all have a field_name on the left and some kind of predicate on the right. A predicate places a constraint on the value of - the column – or, in some cases, on the value of the column as transformed by some + the column -- or, in some cases, on the value of the column as transformed by some function call: @@ -886,14 +886,14 @@ Strictly speaking, json_query accepts any compare_op that doesn't contain semicolons or white space (or - “similar to” as a special exception). As a result, it - is possible – and potentially useful – to use a custom operator like - “>100*” in order to insert an expression that would + "similar to" as a special exception). As a result, it + is possible -- and potentially useful -- to use a custom operator like + ">100*" in order to insert an expression that would otherwise be difficult or impossible to create through a JSON query. The ban on semicolons and white space prevents certain kinds of SQL injection. Note that json_query does not accept two operators that - PostgreSQL does accept: “is distinct from” - and “is not distinct from”. + PostgreSQL does accept: "is distinct from" + and "is not distinct from". You can also compare a column to a null value: @@ -905,7 +905,7 @@ - The equality operator “=” turns into IS NULL. Any other + The equality operator "=" turns into IS NULL. Any other operator turns into IS NOT NULL. When a compare_op is paired with an array, it defines a function call: @@ -923,13 +923,13 @@ the array, if any, represent the parameters of the function call. They may be strings, numbers, or nulls. In the generated SQL, the function call appears on the right of the comparison. - The “between” operator creates a BETWEEN clause: + The "between" operator creates a BETWEEN clause: predicate - '{' “between” ':' '[' lit_value ',' lit_value ']' '}' + '{' "between" ':' '[' lit_value ',' lit_value ']' '}' @@ -960,8 +960,8 @@ For the HAVING clause, json_query accepts exactly the same syntax as it accepts for the WHERE clause. The other way to create an IN list is to use an explicit - “in” operator with an array of literal values. This format - also works for the “not in” operator: + "in" operator with an array of literal values. This format + also works for the "not in" operator: @@ -972,7 +972,7 @@ in_operator - “in” | “not in” + "in" | "not in" @@ -991,7 +991,7 @@ The remaining types of predicate can put a function call on the left of the comparison, by using a transform_spec together - with a “value” tag. The transform_spec is + with a "value" tag. The transform_spec is optional, and if you don't need it, the same SQL would in many cases be easier to express by other means. The transform_spec construct was described earlier in @@ -1002,18 +1002,18 @@ transform_spec - '”transform”' ':' string ] - [ ',' '”result_field” ':' string ] - [ ',' '”params” ':' param_list ] + '"transform"' ':' string ] + [ ',' '"result_field" ':' string ] + [ ',' '"params" ':' param_list ] - As in the SELECT clause, the “transform” string names the + As in the SELECT clause, the "transform" string names the function. The first parameter is always the column identified by the field_name. Additional parameters, if any, appear in the param_list. The - “result_field” string, if present, identifies one column of a + "result_field" string, if present, identifies one column of a multicolumn return value. Here's a second way to compare a value to a literal value (but not to a null value): @@ -1022,7 +1022,7 @@ predicate - '{' compare_op ':' '{' '”value”' ':' lit_value + '{' compare_op ':' '{' '"value"' ':' lit_value [ transform_spec ] '}' '}' @@ -1034,7 +1034,7 @@ predicate - '{' compare_op ':' '{' '”value”' ':' '{' + '{' compare_op ':' '{' '"value"' ':' '{' condition { ',' condition } [ transform_spec ] '}' '}' @@ -1047,7 +1047,7 @@ predicate - '{' compare_op ':' '{' '”value”' ':' '[' + '{' compare_op ':' '{' '"value"' ':' '[' string { ',' parameter } ']' [ transform_spec ] '}' '}' @@ -1084,24 +1084,24 @@ sort_field_def '{' - '”class”' ':' class_name - ',' '”field”' ':' field_name - [ ',' '”direction”' ':' lit_value ] + '"class"' ':' class_name + ',' '"field"' ':' field_name + [ ',' '"direction"' ':' lit_value ] [ ',' transform_spec ] '}' - The “class” and “field” entries are + The "class" and "field" entries are required, and of course the field must belong to the class. Furthermore, at least one field from the class must appear in the SELECT clause. - The “direction” entry, if present, specifies whether the + The "direction" entry, if present, specifies whether the sort will be ascending or descending for the column in question. If the associated - value begins with “D” or “d”, the sort will be descending; otherwise the sort will + value begins with "D" or "d", the sort will be descending; otherwise the sort will be ascending. If the value is a number, it will be treated as a string that does not - start with “D” or “d”, resulting in an ascending sort. - In the absence of a “direction” entry, the sort will be + start with "D" or "d", resulting in an ascending sort. + In the absence of a "direction" entry, the sort will be ascending. The transform_spec works here the same way it works in the SELECT clause and the WHERE clause, enabling you to pass the column through a @@ -1112,9 +1112,9 @@ transform_spec - '”transform”' ':' string ] - [ ',' '”result_field” ':' string ] - [ ',' '”params” ':' param_list ] + '"transform"' ':' string ] + [ ',' '"result_field" ':' string ] + [ ',' '"params" ':' param_list ] @@ -1169,7 +1169,7 @@ Since the field_name is the key for the object, it cannot appear more than once. As a result, some kinds of sorts are not possible with this syntax. For example, one might want to sort by UPPER( family_name ), and then by - family_name with case unchanged, to make sure that “diBona” comes before “Dibona”. + family_name with case unchanged, to make sure that "diBona" comes before "Dibona". For situations like this, you must encode the ORDER BY clause as an array rather than an object. The data associated with each field_name may take either of @@ -1185,7 +1185,7 @@ - If the literal is a string starting with “D” or “d”, json_query sorts the field + If the literal is a string starting with "D" or "d", json_query sorts the field in descending order. Otherwise it sorts the field in ascending order. In other cases, the field_name may be paired with an object to specify more details: @@ -1195,19 +1195,19 @@ sort_class_subdef '{' - [ '”direction”' ':' lit_value ] + [ '"direction"' ':' lit_value ] [ transform_spec ] '}' - As before, the value tagged as “direction” specifies the + As before, the value tagged as "direction" specifies the direction of the sort, depending on the first character. If not otherwise specified, the sort direction defaults to ascending. Also as before, the transform_spec may specify a function through which to pass the column. - Since both the “direction” tag and the + Since both the "direction" tag and the transform_spec are optional, the object may be empty: -- 2.43.2