From e29fc6155512b7dc82b39379dac4e29de8db86f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Mon, 19 Jun 2023 23:17:04 +0200 Subject: [PATCH] fixes --- .../src/Database/Transaction_Spec.enso | 18 ++++++++++++++---- .../Types/SQLite_Type_Mapping_Spec.enso | 4 +++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/test/Table_Tests/src/Database/Transaction_Spec.enso b/test/Table_Tests/src/Database/Transaction_Spec.enso index 3203aa02ff1a8..b30f21d608703 100644 --- a/test/Table_Tests/src/Database/Transaction_Spec.enso +++ b/test/Table_Tests/src/Database/Transaction_Spec.enso @@ -8,6 +8,8 @@ from Standard.Database.Errors import all from Standard.Test import Test, Test_Suite, Problems import Standard.Test.Extensions +import project.Database.Helpers.Name_Generator + type My_Error Error @@ -18,7 +20,8 @@ spec connection prefix = Test.group prefix+"Transaction Support" <| simple_table_structure = [Column_Description.Value "X" Value_Type.Integer] Test.specify "should commit the changes after the transaction returns a regular value" <| - t1 = connection.create_table table_name=Nothing structure=simple_table_structure temporary=True + table_name = Name_Generator.random_name "transaction-test-1" + t1 = connection.create_table table_name=table_name structure=simple_table_structure temporary=True t1.should_succeed r1 = connection.jdbc_connection.run_within_transaction <| t1.insert [1] . should_succeed @@ -26,9 +29,11 @@ spec connection prefix = r1.should_equal 42 t1.at "X" . to_vector . should_equal [1] + connection.drop_table table_name Test.specify "should rollback the changes after the inner action panics" <| - t1 = connection.create_table table_name=Nothing structure=simple_table_structure temporary=True + table_name = Name_Generator.random_name "transaction-test-2" + t1 = connection.create_table table_name=table_name structure=simple_table_structure temporary=True t1.should_succeed Test.expect_panic_with matcher=My_Error <| connection.jdbc_connection.run_within_transaction <| @@ -36,9 +41,11 @@ spec connection prefix = Panic.throw My_Error.Error t1.at "X" . to_vector . should_equal [] + connection.drop_table table_name Test.specify "should rollback the changes if the inner action returns a dataflow error" <| - t1 = connection.create_table table_name=Nothing structure=simple_table_structure temporary=True + table_name = Name_Generator.random_name "transaction-test-3" + t1 = connection.create_table table_name=table_name structure=simple_table_structure temporary=True t1.should_succeed r1 = connection.jdbc_connection.run_within_transaction <| t1.insert [1] . should_succeed @@ -46,9 +53,11 @@ spec connection prefix = r1.should_fail_with My_Error t1.at "X" . to_vector . should_equal [] + connection.drop_table table_name Test.specify "should commit the changes even if the inner action return value has warnings attached" <| - t1 = connection.create_table table_name=Nothing structure=simple_table_structure temporary=True + table_name = Name_Generator.random_name "transaction-test-4" + t1 = connection.create_table table_name=table_name structure=simple_table_structure temporary=True t1.should_succeed r1 = connection.jdbc_connection.run_within_transaction <| t1.insert [1] . should_succeed @@ -59,3 +68,4 @@ spec connection prefix = Problems.expect_only_warning My_Error r1 t1.at "X" . to_vector . should_equal [1] + connection.drop_table table_name diff --git a/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso b/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso index 4ff60f59c6a2e..1c59c100c8a45 100644 --- a/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso +++ b/test/Table_Tests/src/Database/Types/SQLite_Type_Mapping_Spec.enso @@ -14,6 +14,8 @@ from Standard.Database.Errors import Unsupported_Database_Operation from Standard.Test import Problems, Test, Test_Suite import Standard.Test.Extensions +import project.Database.Helpers.Name_Generator + spec = connection = Database.connect (SQLite In_Memory) make_table prefix columns = @@ -104,7 +106,7 @@ spec = Test.specify "does not support creating tables with date/time values" <| t = Table.new [["a", [Date.now]], ["b", [Time_Of_Day.now]], ["c", [Date_Time.now]]] - r1 = t.select_into_database_table connection temporary=True + r1 = t.select_into_database_table connection table_name=(Name_Generator.random_name "date-time-table") temporary=True r1.should_fail_with Unsupported_Database_Operation Test.specify "should be able to infer types for all supported operations" <|