Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PostgreSQL Metadata Source Tests #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ml_metadata/metadata_store/metadata_source_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecordSet>(
R"(column_names: "c1"
Expand Down
2 changes: 1 addition & 1 deletion ml_metadata/metadata_store/postgresql_metadata_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, and also from the PR description, this fixes DB creation for names containing a "-", as you also raised on a previous meeting.
Can you split that into a separate commit, with the comment from the PR description? I believe it's important to keep track of the reason why certain changes were made.

IIRC we also need that fix on the MySQL metadata source ConnectImpl, can you confirm/test?

PGresult* res = PQexec(connDefault, create_database_cmd.c_str());
if (PQresultStatus(res) != PGRES_COMMAND_OK &&
PQresultStatus(res) != PGRES_TUPLES_OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down