Skip to content

Commit

Permalink
Fix AND & OR operators must be in CAPS separated by spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
opicciotto committed Sep 2, 2024
1 parent 138ef2e commit 6001c9c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For more technical informations : [documentation](./project.md)
- [Installation](#installation)
- [Sequences](#sequences)
- [checkAccessTokenGoogle](#checkaccesstokengoogle)
- [ClearRefreshToken](#clearrefreshtoken)
- [forms_AddRow](#forms_addrow)
- [formssource_GetTableData](#formssource_gettabledata)
- [getApiKey](#getapikey)
Expand Down Expand Up @@ -60,6 +61,10 @@ This as to be called by client apps to decide whenever or not they have to displ



### ClearRefreshToken

Remove any RefreshToken and GoogleSheetAcessTokne form the session and user profile

### forms_AddRow

Add a row to a table in a Google Sheet. Each column of the table must have the same name as the technicalID <br>of a field on the form. <br><br>This action can also be used to update some data in a table. In this case, set <br>the <b>Where Clause</b> variable to a condition and set the <b>Update</b> variable to the columns you want to update.
Expand All @@ -77,10 +82,13 @@ Add a row to a table in a Google Sheet. Each column of the table must have the s
<td>forms_config</td><td>Creates a row in a table with a given configuration</td>
</tr>
<tr>
<td>forms_update</td><td>Will be use only if the WHERE clause is not empty. Give here separated by commas the fields = value to define the columns to be updated by the given values. The fields must be the technical identifiers of the fields of your form. For example: <br><br><i>inputText1 = value1, inputText2 = value2</i>. <br><br>Of course values can be dragged and dropped from the list of fields.</td>
<td>forms_update</td><td>Will be use only if the WHERE clause is not empty. Give here separated by commas the fields = value to define the columns to be updated by the given values. The fields must be the technical identifiers of the fields of your form. For example: <br><br><i>inputText1 = 'value1', inputText2 = 'value2'</i>. <br><br>Of course values can be dragged and dropped from the list of fields.</td>
</tr>
<tr>
<td>forms_where</td><td>If this field is not empty, the action will use the WHERE clause to filter the record to update. The WHERE clause must be a valid ''SQL like'' WHERE clause without the WHERE keyword. A Where clause can be for example : <br><br><i>inputText1 = ''value1'' AND inputText1 > ''Other Value''</i></br></br>Values must be surrounded by single quotes ''. You can use AND/OR operators (in uppercase) but you cannnot combine AND and OR in the same clause.</td>
</tr>
<tr>
<td>forms_where</td><td>If this field is not empty, the action will use the WHERE clause to filter the record to update. The WHERE clause must be a valid 'SQL like' WHERE clause without the WHERE keyword. A Where clause can be for example : <br><br><i>inputText1 = 'value1' </i></br></br>Google Sheet connector only supports the = operator and one item. Values must be surrounded by single quotes '</td>
<td>model</td><td></td>
</tr>
<tr>
<td>originalDoc</td><td></td>
Expand Down
32 changes: 28 additions & 4 deletions _c8oProject/sequences/SheetAddRow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,18 @@ comment: Add a row of cells to a Google Sheet.
function parseWhereWithOperator(whereClause) {
const operators = [''='', ''>'', ''<'', ''>='', ''<=''];
const logicalOperators = [''AND'', ''OR''];
const logicalOperators = ['' AND '', '' OR ''];
// Determine which logical operator is used in the clause
const logicalOperatorUsed = logicalOperators.find(op => whereClause.toUpperCase().includes(op));
const logicalOperatorUsed = logicalOperators.find(op => whereClause.includes(op));
if (!logicalOperatorUsed) {
throw new Error("No logical operator found. Only AND or OR can be used.");
}
// Ensure only one type of logical operator is used
const otherLogicalOperator = logicalOperators.find(op => op !== logicalOperatorUsed);
if (whereClause.toUpperCase().includes(otherLogicalOperator)) {
if (whereClause.includes(otherLogicalOperator)) {
throw new Error("Mixing AND and OR operators is not allowed.");
}
Expand Down Expand Up @@ -545,7 +545,7 @@ comment: Add a row of cells to a Google Sheet.
// Return the parsed conditions along with the logical operator used
return {
logicalOperator: logicalOperatorUsed.toUpperCase(),
logicalOperator: logicalOperatorUsed.toUpperCase().trim(),
conditions: parsedConditions
};
}
Expand Down Expand Up @@ -577,6 +577,30 @@ comment: Add a row of cells to a Google Sheet.
comment: A Google Sheet Where clause
↓update [variables.RequestableVariable-1724340324746]:
comment: a JSON array of field, values
↓TestMultipleAnd [core.TestCase]:
↓SheetID [variables.TestCaseVariable-1725269497149]:
value: 1txNgqBGAwpua2ZhP8XE8i8IHsOl1I-XwmhDs4mAmRCo
↓Range [variables.TestCaseVariable-1725269497152]:
value: '''Add Row''!B2:K100'
↓dataRow [variables.TestCaseVariable-1725269497155]:
value: |
'{
"inputText1": {
"value": "AAAAAAAAA"
},
"inputText2": {
"value": "BBBBBBBB"
},
"datetime1": {
"value": "10/10/2024"
}
}
'
↓where [variables.TestCaseVariable-1725269497158]:
value: email = 'gregoryv@convertigo.com' AND Nom = 'VORBE' AND statut = ''
↓update [variables.TestCaseVariable-1725269497161]:
value: inputText5 = 'Z'hghg , ""gg'hj hg 'ZZ', inputText3 = 'UU,U'
↓TestNewRow [core.TestCase]:
↓SheetID [variables.TestCaseVariable-1607870066727]:
value: 1txNgqBGAwpua2ZhP8XE8i8IHsOl1I-XwmhDs4mAmRCo
Expand Down
4 changes: 2 additions & 2 deletions _c8oProject/sequences/forms_AddRow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ comment: |
'{
"en": {
"displayName": "<p>WHERE Clause</p>",
"comment": "If this field is not empty, the action will use the WHERE clause to filter the record to update. The WHERE clause must be a valid ''''SQL like'''' WHERE clause without the WHERE keyword. A Where clause can be for example : <br><br><i>inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''</i></br></br>Values must be surrounded by single quotes ''''. You can use AND/OR operators but you cannnot combine AND and OR in the same clause."
"comment": "If this field is not empty, the action will use the WHERE clause to filter the record to update. The WHERE clause must be a valid ''''SQL like'''' WHERE clause without the WHERE keyword. A Where clause can be for example : <br><br><i>inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''</i></br></br>Values must be surrounded by single quotes ''''. You can use AND/OR operators (in uppercase) but you cannnot combine AND and OR in the same clause."
},
"fr": {
"displayName": "<p>Clause Where</p>",
"comment": "Si ce champ n''''est pas vide, l''''action utilisera la clause WHERE pour filtrer l''''enregistrement à mettre à jour. La clause WHERE doit être une clause WHERE valide de type ''''SQL'''' sans le mot clé WHERE. Une clause Where peut être par exemple : <br><br><i>inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''</i></br></br>Les valeurs doivent être entourées de guillemets simples ''''. Vous pouvez utiliser les opérateurs AND ou OR mais vous ne pouvez pas combiner les 2 au sein de la même clause."
"comment": "Si ce champ n''''est pas vide, l''''action utilisera la clause WHERE pour filtrer l''''enregistrement à mettre à jour. La clause WHERE doit être une clause WHERE valide de type ''''SQL'''' sans le mot clé WHERE. Une clause Where peut être par exemple : <br><br><i>inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''</i></br></br>Les valeurs doivent être entourées de guillemets simples ''''. Vous pouvez utiliser les opérateurs AND ou OR (en majuscules) mais vous ne pouvez pas combiner les 2 au sein de la même clause."
}
}'
description: Where Clause
Expand Down
2 changes: 1 addition & 1 deletion project.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Will be use only if the WHERE clause is not empty. Give here separated by commas
<img src="https://github.com/convertigo/convertigo/blob/develop/engine/src/com/twinsoft/convertigo/beans/variables/images/variable_color_16x16.png?raw=true " alt="RequestableVariable" >&nbsp;forms_where
</td>
<td>
If this field is not empty, the action will use the WHERE clause to filter the record to update. The WHERE clause must be a valid ''SQL like'' WHERE clause without the WHERE keyword. A Where clause can be for example : <br><br><i>inputText1 = ''value1'' AND inputText1 > ''Other Value''</i></br></br>Values must be surrounded by single quotes ''. You can use AND/OR operators but you cannnot combine AND and OR in the same clause.
If this field is not empty, the action will use the WHERE clause to filter the record to update. The WHERE clause must be a valid ''SQL like'' WHERE clause without the WHERE keyword. A Where clause can be for example : <br><br><i>inputText1 = ''value1'' AND inputText1 > ''Other Value''</i></br></br>Values must be surrounded by single quotes ''. You can use AND/OR operators (in uppercase) but you cannnot combine AND and OR in the same clause.
</td>
</tr>
<tr>
Expand Down

0 comments on commit 6001c9c

Please sign in to comment.