Skip to content

Commit

Permalink
fix handling of ogawayama::stub::tsurugi_error_code.type
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Sep 18, 2024
1 parent 31f98b7 commit b7e1b01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ogawayama/stub/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ ErrorCode Connection::Impl::end_ddl()

static inline bool handle_sql_error(ogawayama::stub::tsurugi_error_code& code, ::jogasaki::proto::sql::response::Error& sql_error) {
if (auto itr = ogawayama::transport::error_map.find(sql_error.code()); itr != ogawayama::transport::error_map.end()) {
code.type = tsurugi_error_code::tsurugi_error_type::sql_error;
code.code = itr->second.second;
code.name = itr->second.first;
code.detail = sql_error.detail();
Expand Down
5 changes: 5 additions & 0 deletions test/ogawayama/stub/ErrorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TEST_F(ErrorTest, begin) {
ogawayama::stub::tsurugi_error_code code{};
EXPECT_EQ(ERROR_CODE::OK, connection->tsurugi_error(code));

EXPECT_EQ(code.type, ogawayama::stub::tsurugi_error_code::tsurugi_error_type::sql_error);
EXPECT_EQ(code.code, 1000); // 1000 corresponds to SQL_SERVICE_EXCEPTION
EXPECT_EQ(code.name, "SQL_SERVICE_EXCEPTION");
EXPECT_EQ(code.detail, "sql_error_for_test");
Expand Down Expand Up @@ -104,6 +105,7 @@ TEST_F(ErrorTest, prepare) {
ogawayama::stub::tsurugi_error_code code{};
EXPECT_EQ(ERROR_CODE::OK, connection->tsurugi_error(code));

EXPECT_EQ(code.type, ogawayama::stub::tsurugi_error_code::tsurugi_error_type::sql_error);
EXPECT_EQ(code.code, 1000); // 1000 corresponds to SQL_SERVICE_EXCEPTION
EXPECT_EQ(code.name, "SQL_SERVICE_EXCEPTION");
EXPECT_EQ(code.detail, "sql_error_for_test");
Expand Down Expand Up @@ -167,6 +169,7 @@ TEST_F(ErrorTest, statement) {
ogawayama::stub::tsurugi_error_code code{};
EXPECT_EQ(ERROR_CODE::OK, connection->tsurugi_error(code));

EXPECT_EQ(code.type, ogawayama::stub::tsurugi_error_code::tsurugi_error_type::sql_error);
EXPECT_EQ(code.code, 1000); // 1000 corresponds to SQL_SERVICE_EXCEPTION
EXPECT_EQ(code.name, "SQL_SERVICE_EXCEPTION");
EXPECT_EQ(code.detail, "sql_error_for_test");
Expand Down Expand Up @@ -254,6 +257,7 @@ TEST_F(ErrorTest, query) {
ogawayama::stub::tsurugi_error_code code{};
EXPECT_EQ(ERROR_CODE::OK, connection->tsurugi_error(code));

EXPECT_EQ(code.type, ogawayama::stub::tsurugi_error_code::tsurugi_error_type::sql_error);
EXPECT_EQ(code.code, 1000); // 1000 corresponds to SQL_SERVICE_EXCEPTION
EXPECT_EQ(code.name, "SQL_SERVICE_EXCEPTION");
EXPECT_EQ(code.detail, "sql_error_for_test");
Expand Down Expand Up @@ -344,6 +348,7 @@ TEST_F(ErrorTest, commit) {
ogawayama::stub::tsurugi_error_code code{};
EXPECT_EQ(ERROR_CODE::OK, connection->tsurugi_error(code));

EXPECT_EQ(code.type, ogawayama::stub::tsurugi_error_code::tsurugi_error_type::sql_error);
EXPECT_EQ(code.code, 1000); // 1000 corresponds to SQL_SERVICE_EXCEPTION
EXPECT_EQ(code.name, "SQL_SERVICE_EXCEPTION");
EXPECT_EQ(code.detail, "sql_error_for_test");
Expand Down

1 comment on commit b7e1b01

@t-horikawa
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please sign in to comment.