From b54c9ae5e1aa038426cb4c3d067f9f4f6814278e Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 2 Jan 2025 20:39:27 +0100 Subject: [PATCH] Refactor: Remove the last part of the table_sql struct, the name --- src/middle-pgsql.cpp | 49 +++++++------------------------------------- src/middle-pgsql.hpp | 7 +------ 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/src/middle-pgsql.cpp b/src/middle-pgsql.cpp index 6c1cf75cb..4e965a1cc 100644 --- a/src/middle-pgsql.cpp +++ b/src/middle-pgsql.cpp @@ -116,9 +116,10 @@ std::string build_sql(options_t const &options, std::string const &templ) } // anonymous namespace middle_pgsql_t::table_desc::table_desc(options_t const &options, - table_sql const &ts) + std::string_view name) : m_copy_target(std::make_shared( - options.middle_dbschema, build_sql(options, ts.name), "id")) + options.middle_dbschema, fmt::format("{}_{}", options.prefix, name), + "id")) { } @@ -1201,42 +1202,6 @@ void middle_pgsql_t::wait() namespace { -table_sql sql_for_users(middle_pgsql_options const &store_options) -{ - table_sql sql{}; - - sql.name = "{prefix}_users"; - - return sql; -} - -table_sql sql_for_nodes(middle_pgsql_options const &options) -{ - table_sql sql{}; - - sql.name = "{prefix}_nodes"; - - return sql; -} - -table_sql sql_for_ways() -{ - table_sql sql{}; - - sql.name = "{prefix}_ways"; - - return sql; -} - -table_sql sql_for_relations() -{ - table_sql sql{}; - - sql.name = "{prefix}_rels"; - - return sql; -} - void init_params(params_t *params, options_t const &options) { std::string const schema = "\"" + options.middle_dbschema + "\"."; @@ -1304,11 +1269,11 @@ middle_pgsql_t::middle_pgsql_t(std::shared_ptr thread_pool, init_params(&m_params, *options); - m_tables.nodes() = table_desc{*options, sql_for_nodes(m_store_options)}; - m_tables.ways() = table_desc{*options, sql_for_ways()}; - m_tables.relations() = table_desc{*options, sql_for_relations()}; + m_tables.nodes() = table_desc{*options, "nodes"}; + m_tables.ways() = table_desc{*options, "ways"}; + m_tables.relations() = table_desc{*options, "rels"}; - m_users_table = table_desc{*options, sql_for_users(m_store_options)}; + m_users_table = table_desc{*options, "users"}; } void middle_pgsql_t::set_requirements( diff --git a/src/middle-pgsql.hpp b/src/middle-pgsql.hpp index 3744bba58..238b08cc7 100644 --- a/src/middle-pgsql.hpp +++ b/src/middle-pgsql.hpp @@ -86,11 +86,6 @@ class middle_query_pgsql_t : public middle_query_t middle_pgsql_options m_store_options; }; -struct table_sql -{ - std::string name; -}; - struct middle_pgsql_t : public middle_t { middle_pgsql_t(std::shared_ptr thread_pool, @@ -119,7 +114,7 @@ struct middle_pgsql_t : public middle_t { public: table_desc() = default; - table_desc(options_t const &options, table_sql const &ts); + table_desc(options_t const &options, std::string_view name); std::string const &schema() const noexcept {