From 6001c9c83212822a20eeb917eae844319d1cd04e Mon Sep 17 00:00:00 2001 From: Olivier Picciotto Date: Mon, 2 Sep 2024 12:00:54 +0200 Subject: [PATCH] Fix AND & OR operators must be in CAPS separated by spaces --- README.md | 12 ++++++++-- _c8oProject/sequences/SheetAddRow.yaml | 32 +++++++++++++++++++++---- _c8oProject/sequences/forms_AddRow.yaml | 4 ++-- project.md | 2 +- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 66e63f5..c69d355 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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
of a field on the form.

This action can also be used to update some data in a table. In this case, set
the Where Clause variable to a condition and set the Update variable to the columns you want to update. @@ -77,10 +82,13 @@ Add a row to a table in a Google Sheet. Each column of the table must have the s forms_configCreates a row in a table with a given configuration -forms_updateWill 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:

inputText1 = value1, inputText2 = value2.

Of course values can be dragged and dropped from the list of fields. +forms_updateWill 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:

inputText1 = 'value1', inputText2 = 'value2'.

Of course values can be dragged and dropped from the list of fields. + + +forms_whereIf 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 :

inputText1 = ''value1'' AND inputText1 > ''Other Value''

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. -forms_whereIf 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 :

inputText1 = 'value1'

Google Sheet connector only supports the = operator and one item. Values must be surrounded by single quotes ' +model originalDoc diff --git a/_c8oProject/sequences/SheetAddRow.yaml b/_c8oProject/sequences/SheetAddRow.yaml index 0c431ab..fbccc83 100644 --- a/_c8oProject/sequences/SheetAddRow.yaml +++ b/_c8oProject/sequences/SheetAddRow.yaml @@ -506,10 +506,10 @@ 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."); @@ -517,7 +517,7 @@ comment: Add a row of cells to a Google Sheet. // 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."); } @@ -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 }; } @@ -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 diff --git a/_c8oProject/sequences/forms_AddRow.yaml b/_c8oProject/sequences/forms_AddRow.yaml index d1ee58e..0da0bd8 100644 --- a/_c8oProject/sequences/forms_AddRow.yaml +++ b/_c8oProject/sequences/forms_AddRow.yaml @@ -337,11 +337,11 @@ comment: | '{ "en": { "displayName": "

WHERE 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 :

inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''

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 :

inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''

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": "

Clause Where

", - "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 :

inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''

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 :

inputText1 = ''''value1'''' AND inputText1 > ''''Other Value''''

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 diff --git a/project.md b/project.md index bfc4fe3..35417d6 100644 --- a/project.md +++ b/project.md @@ -174,7 +174,7 @@ Will be use only if the WHERE clause is not empty. Give here separated by commas RequestableVariable forms_where -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 :

inputText1 = ''value1'' AND inputText1 > ''Other Value''

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 :

inputText1 = ''value1'' AND inputText1 > ''Other Value''

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.