You've already forked OpenIntegrations
							
							
				mirror of
				https://github.com/Bayselonarrend/OpenIntegrations.git
				synced 2025-10-30 23:47:46 +02:00 
			
		
		
		
	Main build (Jenkins)
This commit is contained in:
		
							
								
								
									
										3
									
								
								docs/en/data/SQLite/UpdateRecords.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								docs/en/data/SQLite/UpdateRecords.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| { | ||||
| "Base": "C:\\Users\\Administrator\\AppData\\Local\\Temp\\v8_3590_23.sqlite" | ||||
| } | ||||
							
								
								
									
										2
									
								
								docs/en/examples/SQLite/AddRecords.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/en/examples/SQLite/AddRecords.txt
									
									
									
									
										vendored
									
									
								
							| @@ -4,7 +4,7 @@ | ||||
|     PictureFile = GetTempFileName("png"); | ||||
|     Image.Write(PictureFile); // PictureFile - File to disk | ||||
|  | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     DataArray = New Array; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/en/examples/SQLite/CreateTable.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/en/examples/SQLite/CreateTable.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     ColoumnsStruct = New Structure; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/en/examples/SQLite/GetRecords.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/en/examples/SQLite/GetRecords.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     Fields = New Array; | ||||
|   | ||||
							
								
								
									
										20
									
								
								docs/en/examples/SQLite/UpdateRecords.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								docs/en/examples/SQLite/UpdateRecords.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     FieldsStructure = New Structure; | ||||
|     FieldsStructure.Insert("name"  , "Vitaly A."); | ||||
|     FieldsStructure.Insert("salary", "999999"); | ||||
|  | ||||
|     Filters = New Array; | ||||
|  | ||||
|     FilterStructure = New Structure; | ||||
|  | ||||
|     FilterStructure.Insert("field", "name"); | ||||
|     FilterStructure.Insert("type" , "="); | ||||
|     FilterStructure.Insert("value", "Vitaly"); | ||||
|     FilterStructure.Insert("union", "AND"); | ||||
|     FilterStructure.Insert("raw"  , False); | ||||
|  | ||||
|     Filters.Add(FilterStructure); | ||||
|  | ||||
|     Result = OPI_SQLite.UpdateRecords(Table, FieldsStructure, FilterStructure, Base); | ||||
							
								
								
									
										2
									
								
								docs/en/md/SQLite/Orm/Add-records.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/en/md/SQLite/Orm/Add-records.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -34,7 +34,7 @@ import TabItem from '@theme/TabItem'; | ||||
|     PictureFile = GetTempFileName("png"); | ||||
|     Image.Write(PictureFile); // PictureFile - File to disk | ||||
|  | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     DataArray = New Array; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/en/md/SQLite/Orm/Create-table.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/en/md/SQLite/Orm/Create-table.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -27,7 +27,7 @@ import TabItem from '@theme/TabItem'; | ||||
|  | ||||
|  | ||||
| ```bsl title="1C:Enterprise/OneScript code example" | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     ColoumnsStruct = New Structure; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/en/md/SQLite/Orm/Get-records.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/en/md/SQLite/Orm/Get-records.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -30,7 +30,7 @@ import TabItem from '@theme/TabItem'; | ||||
|  | ||||
|  | ||||
| ```bsl title="1C:Enterprise/OneScript code example" | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     Fields = New Array; | ||||
|   | ||||
							
								
								
									
										19
									
								
								docs/en/md/SQLite/Orm/Update-records.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								docs/en/md/SQLite/Orm/Update-records.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -28,7 +28,26 @@ import TabItem from '@theme/TabItem'; | ||||
|  | ||||
|  | ||||
| ```bsl title="1C:Enterprise/OneScript code example" | ||||
|     Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Table = "test"; | ||||
|  | ||||
|     FieldsStructure = New Structure; | ||||
|     FieldsStructure.Insert("name"  , "Vitaly A."); | ||||
|     FieldsStructure.Insert("salary", "999999"); | ||||
|  | ||||
|     Filters = New Array; | ||||
|  | ||||
|     FilterStructure = New Structure; | ||||
|  | ||||
|     FilterStructure.Insert("field", "name"); | ||||
|     FilterStructure.Insert("type" , "="); | ||||
|     FilterStructure.Insert("value", "Vitaly"); | ||||
|     FilterStructure.Insert("union", "AND"); | ||||
|     FilterStructure.Insert("raw"  , False); | ||||
|  | ||||
|     Filters.Add(FilterStructure); | ||||
|  | ||||
|     Result = OPI_SQLite.UpdateRecords(Table, FieldsStructure, FilterStructure, Base); | ||||
| ``` | ||||
|   | ||||
|  | ||||
|   | ||||
							
								
								
									
										3
									
								
								docs/ru/data/SQLite/ОбновитьЗаписи.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								docs/ru/data/SQLite/ОбновитьЗаписи.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| { | ||||
| "База": "C:\\Users\\Administrator\\AppData\\Local\\Temp\\v8_3590_23.sqlite" | ||||
| } | ||||
							
								
								
									
										2
									
								
								docs/ru/examples/SQLite/ДобавитьЗаписи.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/ru/examples/SQLite/ДобавитьЗаписи.txt
									
									
									
									
										vendored
									
									
								
							| @@ -4,7 +4,7 @@ | ||||
|     ФайлКартинки = ПолучитьИмяВременногоФайла("png"); | ||||
|     Картинка.Записать(ФайлКартинки);                          // ФайлКартинки - Файл на диске | ||||
|  | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     МассивДанных = Новый Массив; | ||||
|   | ||||
							
								
								
									
										20
									
								
								docs/ru/examples/SQLite/ОбновитьЗаписи.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								docs/ru/examples/SQLite/ОбновитьЗаписи.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     СтруктураПолей = Новый Структура; | ||||
|     СтруктураПолей.Вставить("name"  , "Vitaly A."); | ||||
|     СтруктураПолей.Вставить("salary", "999999"); | ||||
|  | ||||
|     Фильтры = Новый Массив; | ||||
|  | ||||
|     СтруктураФильтра = Новый Структура; | ||||
|  | ||||
|     СтруктураФильтра.Вставить("field", "name"); | ||||
|     СтруктураФильтра.Вставить("type" , "="); | ||||
|     СтруктураФильтра.Вставить("value", "Vitaly"); | ||||
|     СтруктураФильтра.Вставить("union", "AND"); | ||||
|     СтруктураФильтра.Вставить("raw"  , Ложь); | ||||
|  | ||||
|     Фильтры.Добавить(СтруктураФильтра); | ||||
|  | ||||
|     Результат = OPI_SQLite.ОбновитьЗаписи(Таблица, СтруктураПолей, СтруктураФильтра, База); | ||||
							
								
								
									
										2
									
								
								docs/ru/examples/SQLite/ПолучитьЗаписи.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/ru/examples/SQLite/ПолучитьЗаписи.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     Поля = Новый Массив; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/ru/examples/SQLite/СоздатьТаблицу.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/ru/examples/SQLite/СоздатьТаблицу.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     СтруктураКолонок = Новый Структура; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/ru/md/SQLite/Orm/Add-records.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/ru/md/SQLite/Orm/Add-records.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -34,7 +34,7 @@ import TabItem from '@theme/TabItem'; | ||||
|     ФайлКартинки = ПолучитьИмяВременногоФайла("png"); | ||||
|     Картинка.Записать(ФайлКартинки);                          // ФайлКартинки - Файл на диске | ||||
|  | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     МассивДанных = Новый Массив; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/ru/md/SQLite/Orm/Create-table.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/ru/md/SQLite/Orm/Create-table.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -27,7 +27,7 @@ import TabItem from '@theme/TabItem'; | ||||
|  | ||||
|  | ||||
| ```bsl title="Пример использования для 1С:Предприятие/OneScript" | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     СтруктураКолонок = Новый Структура; | ||||
|   | ||||
							
								
								
									
										2
									
								
								docs/ru/md/SQLite/Orm/Get-records.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								docs/ru/md/SQLite/Orm/Get-records.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -30,7 +30,7 @@ import TabItem from '@theme/TabItem'; | ||||
|  | ||||
|  | ||||
| ```bsl title="Пример использования для 1С:Предприятие/OneScript" | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_BCCE_11.sqlite"; | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     Поля = Новый Массив; | ||||
|   | ||||
							
								
								
									
										19
									
								
								docs/ru/md/SQLite/Orm/Update-records.mdx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								docs/ru/md/SQLite/Orm/Update-records.mdx
									
									
									
									
										vendored
									
									
								
							| @@ -28,7 +28,26 @@ import TabItem from '@theme/TabItem'; | ||||
|  | ||||
|  | ||||
| ```bsl title="Пример использования для 1С:Предприятие/OneScript" | ||||
|     База    = "C:\Users\Administrator\AppData\Local\Temp\v8_3590_23.sqlite"; | ||||
|     Таблица = "test"; | ||||
|  | ||||
|     СтруктураПолей = Новый Структура; | ||||
|     СтруктураПолей.Вставить("name"  , "Vitaly A."); | ||||
|     СтруктураПолей.Вставить("salary", "999999"); | ||||
|  | ||||
|     Фильтры = Новый Массив; | ||||
|  | ||||
|     СтруктураФильтра = Новый Структура; | ||||
|  | ||||
|     СтруктураФильтра.Вставить("field", "name"); | ||||
|     СтруктураФильтра.Вставить("type" , "="); | ||||
|     СтруктураФильтра.Вставить("value", "Vitaly"); | ||||
|     СтруктураФильтра.Вставить("union", "AND"); | ||||
|     СтруктураФильтра.Вставить("raw"  , Ложь); | ||||
|  | ||||
|     Фильтры.Добавить(СтруктураФильтра); | ||||
|  | ||||
|     Результат = OPI_SQLite.ОбновитьЗаписи(Таблица, СтруктураПолей, СтруктураФильтра, База); | ||||
| ``` | ||||
|      | ||||
|  | ||||
|   | ||||
							
								
								
									
										12274
									
								
								service/dictionaries/en.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12274
									
								
								service/dictionaries/en.json
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										42
									
								
								src/en/OInt/tests/Modules/internal/OPI_Tests.os
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										42
									
								
								src/en/OInt/tests/Modules/internal/OPI_Tests.os
									
									
									
									
										vendored
									
									
								
							| @@ -2238,6 +2238,7 @@ Procedure SQLL_ORM() Export | ||||
|     SQLite_CreateTable(TestParameters); | ||||
|     SQLite_AddRecords(TestParameters); | ||||
|     SQLite_GetRecords(TestParameters); | ||||
|     SQLite_UpdateRecords(TestParameters); | ||||
|  | ||||
|     Try | ||||
|        DeleteFiles(Base); | ||||
| @@ -16402,6 +16403,47 @@ Procedure SQLite_GetRecords(FunctionParameters) | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| Procedure SQLite_UpdateRecords(FunctionParameters) | ||||
|  | ||||
|     Base  = FunctionParameters["SQLite_DB"]; | ||||
|     Table = "test"; | ||||
|  | ||||
|     FieldsStructure = New Structure; | ||||
|     FieldsStructure.Insert("name"  , "Vitaly A."); | ||||
|     FieldsStructure.Insert("salary", "999999"); | ||||
|  | ||||
|     Filters = New Array; | ||||
|  | ||||
|     FilterStructure = New Structure; | ||||
|  | ||||
|     FilterStructure.Insert("field", "name"); | ||||
|     FilterStructure.Insert("type" , "="); | ||||
|     FilterStructure.Insert("value", "Vitaly"); | ||||
|     FilterStructure.Insert("union", "AND"); | ||||
|     FilterStructure.Insert("raw"  , False); | ||||
|  | ||||
|     Filters.Add(FilterStructure); | ||||
|  | ||||
|     Result = OPI_SQLite.UpdateRecords(Table, FieldsStructure, FilterStructure, Base); | ||||
|  | ||||
|     // END | ||||
|  | ||||
|     OPI_TestDataRetrieval.WriteLog(Result, "UpdateRecords", "SQLite"); | ||||
|     OPI_TestDataRetrieval.Check_SQLiteSuccess(Result); | ||||
|  | ||||
|     FilterStructure.Insert("value", "Vitaly A."); | ||||
|  | ||||
|     Filters = New Array; | ||||
|     Filters.Add(FilterStructure); | ||||
|  | ||||
|     Check = OPI_SQLite.GetRecords(Table, "['name','salary']", Filters, , , Base); | ||||
|  | ||||
|     OPI_TestDataRetrieval.WriteLog(Check, "Check", "SQLite"); | ||||
|     OPI_TestDataRetrieval.Check_SQLiteSuccess(Check); | ||||
|     OPI_TestDataRetrieval.Check_SQLiteFieldsValues(Check["data"][0], FieldsStructure); | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| #EndRegion | ||||
|  | ||||
| #EndRegion | ||||
|   | ||||
| @@ -2083,6 +2083,14 @@ Procedure Check_SQLiteRows(Val Result, Val Count) Export | ||||
|     ExpectsThat(Result["rows"]).Равно(Count); | ||||
| EndProcedure | ||||
|  | ||||
| Procedure Check_SQLiteFieldsValues(Val Result, Val ValueStructure) Export | ||||
|  | ||||
|     For Each Value In ValueStructure Do | ||||
|         Result[Value.Key] = Value.Value; | ||||
|     EndDo; | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| #EndRegion | ||||
|  | ||||
| #EndRegion | ||||
|   | ||||
							
								
								
									
										51
									
								
								src/en/OInt/tools/Modules/os
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								src/en/OInt/tools/Modules/os
									
									
									
									
										vendored
									
									
								
							| @@ -160,7 +160,11 @@ Function GetRecords(Val Module | ||||
|     Scheme = NewSQLScheme("SELECT"); | ||||
|  | ||||
|     SetTableName(Scheme, Table); | ||||
|     SetSelectOptions(Scheme, Fields, Filters, Sort, Count); | ||||
|     SetLimit(Scheme, Count); | ||||
|  | ||||
|     FillFields(Scheme, Fields); | ||||
|     FillFilters(Scheme, Filters); | ||||
|     FillSorting(Scheme, Sort); | ||||
|  | ||||
|     Request = FormSQLText(Scheme); | ||||
|  | ||||
| @@ -172,13 +176,25 @@ EndFunction | ||||
|  | ||||
| Function UpdateRecords(Val Module | ||||
|     , Val Table | ||||
|     , Val ValuesArray | ||||
|     , Val ValueStructure | ||||
|     , Val Filters = "" | ||||
|     , Val Connection = "") Export | ||||
|  | ||||
|     Scheme = NewSQLScheme("UPDATE"); | ||||
|      | ||||
|     FieldArray = New Array; | ||||
|     ValuesArray = New Array; | ||||
|  | ||||
|     SetTableName(Scheme, Table);  | ||||
|     SplitDataCollection(ValueStructure, FieldArray, ValuesArray); | ||||
|  | ||||
|     Scheme["values"] = ValuesArray; | ||||
|      | ||||
|     For Each Field In FieldArray Do | ||||
|         AddField(Scheme, Field); | ||||
|     EndDo; | ||||
|      | ||||
|     FillFilters(Scheme, Filters); | ||||
|  | ||||
|     Request = FormSQLText(Scheme); | ||||
|     Result = Module.ExecuteSQLQuery(Request, Scheme["values"], , Connection); | ||||
| @@ -324,7 +340,23 @@ EndFunction | ||||
|  | ||||
| Function FormTextUpdate(Val Scheme) | ||||
|  | ||||
|     TextSQL = ""; | ||||
|     CheckSchemeRequiredFields(Scheme, "table,set,values"); | ||||
|      | ||||
|     Table = Scheme["table"]; | ||||
|     Fields = Scheme["set"]; | ||||
|     Filters = Scheme["filter"]; | ||||
|      | ||||
|     SQLTemplate = "UPDATE %1 SET %2 %3"; | ||||
|      | ||||
|     FilterText = FormFilterText(Filters); | ||||
|          | ||||
|     For N = 0 To Fields.UBound() Do | ||||
|          | ||||
|         Fields[N] = Fields[N] + " = ?" + OPI_Tools.NumberToString(N + 1); | ||||
|          | ||||
|     EndDo; | ||||
|      | ||||
|     TextSQL = StrTemplate(SQLTemplate, Table, StrConcat(Fields, "," + Chars.LF), FilterText); | ||||
|  | ||||
|     Return TextSQL; | ||||
|  | ||||
| @@ -565,6 +597,9 @@ EndFunction | ||||
|  | ||||
| Procedure SplitDataCollection(Val Record, FieldArray, ValuesArray) | ||||
|  | ||||
|     ErrorText = "Incorrect data set for updating"; | ||||
|     OPI_TypeConversion.GetKeyValueCollection(Record, ErrorText); | ||||
|      | ||||
|     For Each Element In Record Do | ||||
|  | ||||
|         FieldArray.Add(Element.Key); | ||||
| @@ -715,16 +750,6 @@ Procedure SetLimit(Scheme, Val Count) | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| Procedure SetSelectOptions(Scheme, Val Fields, Val Filters, Val Sort, Val Count) | ||||
|  | ||||
|     SetLimit(Scheme, Count); | ||||
|  | ||||
|     FillFields(Scheme, Fields); | ||||
|     FillFilters(Scheme, Filters); | ||||
|     FillSorting(Scheme, Sort); | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| #EndRegion | ||||
|  | ||||
| #EndRegion | ||||
|   | ||||
| @@ -160,7 +160,11 @@ Function GetRecords(Val Module | ||||
|     Scheme = NewSQLScheme("SELECT"); | ||||
|  | ||||
|     SetTableName(Scheme, Table); | ||||
|     SetSelectOptions(Scheme, Fields, Filters, Sort, Count); | ||||
|     SetLimit(Scheme, Count); | ||||
|  | ||||
|     FillFields(Scheme, Fields); | ||||
|     FillFilters(Scheme, Filters); | ||||
|     FillSorting(Scheme, Sort); | ||||
|  | ||||
|     Request = FormSQLText(Scheme); | ||||
|  | ||||
| @@ -172,13 +176,25 @@ EndFunction | ||||
|  | ||||
| Function UpdateRecords(Val Module | ||||
|     , Val Table | ||||
|     , Val ValuesArray | ||||
|     , Val ValueStructure | ||||
|     , Val Filters    = "" | ||||
|     , Val Connection = "") Export | ||||
|  | ||||
|     Scheme = NewSQLScheme("UPDATE"); | ||||
|  | ||||
|     FieldArray  = New Array; | ||||
|     ValuesArray = New Array; | ||||
|  | ||||
|     SetTableName(Scheme, Table); | ||||
|     SplitDataCollection(ValueStructure, FieldArray, ValuesArray); | ||||
|  | ||||
|     Scheme["values"] = ValuesArray; | ||||
|  | ||||
|     For Each Field In FieldArray Do | ||||
|         AddField(Scheme, Field); | ||||
|     EndDo; | ||||
|  | ||||
|     FillFilters(Scheme, Filters); | ||||
|  | ||||
|     Request = FormSQLText(Scheme); | ||||
|     Result  = Module.ExecuteSQLQuery(Request, Scheme["values"], , Connection); | ||||
| @@ -324,7 +340,23 @@ EndFunction | ||||
|  | ||||
| Function FormTextUpdate(Val Scheme) | ||||
|  | ||||
|     TextSQL = ""; | ||||
|     CheckSchemeRequiredFields(Scheme, "table,set,values"); | ||||
|  | ||||
|     Table   = Scheme["table"]; | ||||
|     Fields  = Scheme["set"]; | ||||
|     Filters = Scheme["filter"]; | ||||
|  | ||||
|     SQLTemplate = "UPDATE %1 SET %2 %3"; | ||||
|  | ||||
|     FilterText = FormFilterText(Filters); | ||||
|  | ||||
|     For N = 0 To Fields.UBound() Do | ||||
|  | ||||
|         Fields[N] = Fields[N] + " = ?" + OPI_Tools.NumberToString(N + 1); | ||||
|  | ||||
|     EndDo; | ||||
|  | ||||
|     TextSQL = StrTemplate(SQLTemplate, Table, StrConcat(Fields, "," + Chars.LF), FilterText); | ||||
|  | ||||
|     Return TextSQL; | ||||
|  | ||||
| @@ -565,6 +597,9 @@ EndFunction | ||||
|  | ||||
| Procedure SplitDataCollection(Val Record, FieldArray, ValuesArray) | ||||
|  | ||||
|     ErrorText = "Incorrect data set for updating"; | ||||
|     OPI_TypeConversion.GetKeyValueCollection(Record, ErrorText); | ||||
|  | ||||
|     For Each Element In Record Do | ||||
|  | ||||
|         FieldArray.Add(Element.Key); | ||||
| @@ -715,16 +750,6 @@ Procedure SetLimit(Scheme, Val Count) | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| Procedure SetSelectOptions(Scheme, Val Fields, Val Filters, Val Sort, Val Count) | ||||
|  | ||||
|     SetLimit(Scheme, Count); | ||||
|  | ||||
|     FillFields(Scheme, Fields); | ||||
|     FillFilters(Scheme, Filters); | ||||
|     FillSorting(Scheme, Sort); | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| #EndRegion | ||||
|  | ||||
| #EndRegion | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|   <name>OPI_TCP</name> | ||||
|   <synonym> | ||||
|     <key>en</key> | ||||
|     <value>TCP</value> | ||||
|     <value>TCP (OPI)</value> | ||||
|   </synonym> | ||||
|   <server>true</server> | ||||
|   <externalConnection>true</externalConnection> | ||||
|   | ||||
| @@ -2083,6 +2083,14 @@ Procedure Check_SQLiteRows(Val Result, Val Count) Export | ||||
|     ExpectsThat(Result["rows"]).Равно(Count); | ||||
| EndProcedure | ||||
|  | ||||
| Procedure Check_SQLiteFieldsValues(Val Result, Val ValueStructure) Export | ||||
|  | ||||
|     For Each Value In ValueStructure Do | ||||
|         Result[Value.Key] = Value.Value; | ||||
|     EndDo; | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| #EndRegion | ||||
|  | ||||
| #EndRegion | ||||
|   | ||||
| @@ -2238,6 +2238,7 @@ Procedure SQLL_ORM() Export | ||||
|     SQLite_CreateTable(TestParameters); | ||||
|     SQLite_AddRecords(TestParameters); | ||||
|     SQLite_GetRecords(TestParameters); | ||||
|     SQLite_UpdateRecords(TestParameters); | ||||
|  | ||||
|     Try | ||||
|        DeleteFiles(Base); | ||||
| @@ -16402,6 +16403,47 @@ Procedure SQLite_GetRecords(FunctionParameters) | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| Procedure SQLite_UpdateRecords(FunctionParameters) | ||||
|  | ||||
|     Base  = FunctionParameters["SQLite_DB"]; | ||||
|     Table = "test"; | ||||
|  | ||||
|     FieldsStructure = New Structure; | ||||
|     FieldsStructure.Insert("name"  , "Vitaly A."); | ||||
|     FieldsStructure.Insert("salary", "999999"); | ||||
|  | ||||
|     Filters = New Array; | ||||
|  | ||||
|     FilterStructure = New Structure; | ||||
|  | ||||
|     FilterStructure.Insert("field", "name"); | ||||
|     FilterStructure.Insert("type" , "="); | ||||
|     FilterStructure.Insert("value", "Vitaly"); | ||||
|     FilterStructure.Insert("union", "AND"); | ||||
|     FilterStructure.Insert("raw"  , False); | ||||
|  | ||||
|     Filters.Add(FilterStructure); | ||||
|  | ||||
|     Result = OPI_SQLite.UpdateRecords(Table, FieldsStructure, FilterStructure, Base); | ||||
|  | ||||
|     // END | ||||
|  | ||||
|     OPI_TestDataRetrieval.WriteLog(Result, "UpdateRecords", "SQLite"); | ||||
|     OPI_TestDataRetrieval.Check_SQLiteSuccess(Result); | ||||
|  | ||||
|     FilterStructure.Insert("value", "Vitaly A."); | ||||
|  | ||||
|     Filters = New Array; | ||||
|     Filters.Add(FilterStructure); | ||||
|  | ||||
|     Check = OPI_SQLite.GetRecords(Table, "['name','salary']", Filters, , , Base); | ||||
|  | ||||
|     OPI_TestDataRetrieval.WriteLog(Check, "Check", "SQLite"); | ||||
|     OPI_TestDataRetrieval.Check_SQLiteSuccess(Check); | ||||
|     OPI_TestDataRetrieval.Check_SQLiteFieldsValues(Check["data"][0], FieldsStructure); | ||||
|  | ||||
| EndProcedure | ||||
|  | ||||
| #EndRegion | ||||
|  | ||||
| #EndRegion | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| // OneScript: ./OInt/tests/Modules/internal/OPI_Тесты.os | ||||
| // OneScript: ./OInt/tests/Modules/internal/OPI_Тесты.os | ||||
|  | ||||
| // MIT License | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user