Skip to content

Commit

Permalink
error code for existing table creation; (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricki-epsilla authored Aug 16, 2023
1 parent 520fb2d commit c8d3c84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion engine/db/db_mvp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DBMVP::DBMVP(meta::DatabaseSchema& database_schema, int64_t init_table_scale) {

Status DBMVP::CreateTable(meta::TableSchema& table_schema) {
if (table_name_to_id_map_.find(table_schema.name_) != table_name_to_id_map_.end()) {
return Status(DB_UNEXPECTED_ERROR, "Table already exists: " + table_schema.name_);
return Status(TABLE_ALREADY_EXISTS, "Table already exists: " + table_schema.name_);
}
auto table = std::make_shared<TableMVP>(table_schema, db_catalog_path_, init_table_scale_);
tables_.push_back(table);
Expand Down
6 changes: 5 additions & 1 deletion engine/server/web_server/web_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ class WebController : public oatpp::web::server::api::ApiController {
vectordb::Status status = db_server->CreateTable(db_name, table_schema);

if (!status.ok()) {
dto->statusCode = Status::CODE_500.code;
if (status.code() == TABLE_ALREADY_EXISTS) {
dto->statusCode = Status::CODE_409.code;
} else {
dto->statusCode = Status::CODE_500.code;
}
dto->message = status.message();
return createDtoResponse(Status::CODE_500, dto);
}
Expand Down

0 comments on commit c8d3c84

Please sign in to comment.