From dd26bfc15169a8f5b294ce802574b326d2cd8b26 Mon Sep 17 00:00:00 2001 From: Chanakya Thirumala Setty Date: Fri, 31 May 2024 15:15:26 -0500 Subject: [PATCH 1/3] fixes psql test issues --- .vscode/settings.json | 5 +++++ ml_metadata/metadata_store/metadata_source_test_suite.cc | 4 ++-- ml_metadata/metadata_store/postgresql_metadata_source.cc | 2 +- ...test_postgresql_standalone_metadata_source_initializer.cc | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..d8cb3260a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "string": "cpp" + } +} \ No newline at end of file diff --git a/ml_metadata/metadata_store/metadata_source_test_suite.cc b/ml_metadata/metadata_store/metadata_source_test_suite.cc index ce5719438..cb89b909d 100644 --- a/ml_metadata/metadata_store/metadata_source_test_suite.cc +++ b/ml_metadata/metadata_store/metadata_source_test_suite.cc @@ -69,8 +69,8 @@ TEST_P(MetadataSourceTestSuite, TestInsertWithEscapedStringValue) { EXPECT_EQ(absl::OkStatus(), metadata_source_->Begin()); EXPECT_EQ(absl::OkStatus(), metadata_source_->ExecuteQuery( - absl::StrCat("INSERT INTO t1 VALUES (1, '", - metadata_source_->EscapeString("''"), "')"), + absl::StrCat("INSERT INTO t1 VALUES (1, ", + metadata_source_->EscapeString("''"), ")"), nullptr)); RecordSet expected_results = ParseTextProtoOrDie( R"(column_names: "c1" diff --git a/ml_metadata/metadata_store/postgresql_metadata_source.cc b/ml_metadata/metadata_store/postgresql_metadata_source.cc index 40b79180c..b6ee47b2d 100644 --- a/ml_metadata/metadata_store/postgresql_metadata_source.cc +++ b/ml_metadata/metadata_store/postgresql_metadata_source.cc @@ -252,7 +252,7 @@ absl::Status PostgreSQLMetadataSource::ConnectImpl() { MLMD_RETURN_IF_ERROR(databaseExistenceStatus); if (record_set.records_size() == 0) { const std::string create_database_cmd = - absl::Substitute("CREATE DATABASE $0;", config_.dbname().data()); + absl::Substitute("CREATE DATABASE \"$0\";", config_.dbname().data()); PGresult* res = PQexec(connDefault, create_database_cmd.c_str()); if (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK) { diff --git a/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc b/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc index 25e7ec300..04b317da7 100644 --- a/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc +++ b/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc @@ -107,7 +107,7 @@ class TestPostgreSQLStandaloneMetadataSourceInitializer .c_str()); PQclear(res); res = - PQexec(conn, absl::StrCat("DROP DATABASE IF EXISTS ", db_name).c_str()); + PQexec(conn, absl::StrCat("DROP DATABASE IF EXISTS \"", db_name, "\"").c_str()); PQclear(res); PQfinish(conn); } From fa4d5a7f3d0b02b50225d34cde55bf959ec8d220 Mon Sep 17 00:00:00 2001 From: Chanakya Thirumala Setty Date: Fri, 31 May 2024 15:20:48 -0500 Subject: [PATCH 2/3] Fixes psql test issues --- ml_metadata/metadata_store/metadata_source_test_suite.cc | 4 ++-- ml_metadata/metadata_store/postgresql_metadata_source.cc | 2 +- .../test_postgresql_standalone_metadata_source_initializer.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ml_metadata/metadata_store/metadata_source_test_suite.cc b/ml_metadata/metadata_store/metadata_source_test_suite.cc index ce5719438..cb89b909d 100644 --- a/ml_metadata/metadata_store/metadata_source_test_suite.cc +++ b/ml_metadata/metadata_store/metadata_source_test_suite.cc @@ -69,8 +69,8 @@ TEST_P(MetadataSourceTestSuite, TestInsertWithEscapedStringValue) { EXPECT_EQ(absl::OkStatus(), metadata_source_->Begin()); EXPECT_EQ(absl::OkStatus(), metadata_source_->ExecuteQuery( - absl::StrCat("INSERT INTO t1 VALUES (1, '", - metadata_source_->EscapeString("''"), "')"), + absl::StrCat("INSERT INTO t1 VALUES (1, ", + metadata_source_->EscapeString("''"), ")"), nullptr)); RecordSet expected_results = ParseTextProtoOrDie( R"(column_names: "c1" diff --git a/ml_metadata/metadata_store/postgresql_metadata_source.cc b/ml_metadata/metadata_store/postgresql_metadata_source.cc index 40b79180c..b6ee47b2d 100644 --- a/ml_metadata/metadata_store/postgresql_metadata_source.cc +++ b/ml_metadata/metadata_store/postgresql_metadata_source.cc @@ -252,7 +252,7 @@ absl::Status PostgreSQLMetadataSource::ConnectImpl() { MLMD_RETURN_IF_ERROR(databaseExistenceStatus); if (record_set.records_size() == 0) { const std::string create_database_cmd = - absl::Substitute("CREATE DATABASE $0;", config_.dbname().data()); + absl::Substitute("CREATE DATABASE \"$0\";", config_.dbname().data()); PGresult* res = PQexec(connDefault, create_database_cmd.c_str()); if (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK) { diff --git a/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc b/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc index 25e7ec300..04b317da7 100644 --- a/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc +++ b/ml_metadata/metadata_store/test_postgresql_standalone_metadata_source_initializer.cc @@ -107,7 +107,7 @@ class TestPostgreSQLStandaloneMetadataSourceInitializer .c_str()); PQclear(res); res = - PQexec(conn, absl::StrCat("DROP DATABASE IF EXISTS ", db_name).c_str()); + PQexec(conn, absl::StrCat("DROP DATABASE IF EXISTS \"", db_name, "\"").c_str()); PQclear(res); PQfinish(conn); } From 521feeb3ff5c35de4cfa28c965f292b7665a03d3 Mon Sep 17 00:00:00 2001 From: Chanakya Thirumala Setty <66557279+Chanakya-TS@users.noreply.github.com> Date: Fri, 31 May 2024 15:25:56 -0500 Subject: [PATCH 3/3] Delete .vscode directory --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index d8cb3260a..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.associations": { - "string": "cpp" - } -} \ No newline at end of file