From 5d48d6757a92af9acd3a4410da98479a4195dc44 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sun, 19 Jul 2026 04:10:33 -0400 Subject: [PATCH] Formatted src/services/sqlite --- .../pipeline/src/services/sqlite/finalize.cc | 40 +-- .../src/services/sqlite/initialize.cc | 152 +++++----- .../src/services/sqlite/process_record.cc | 275 +++++++++--------- .../services/sqlite/process_user_record.cc | 163 +++++------ .../services/sqlite/sqlite_export_service.cc | 6 +- 5 files changed, 319 insertions(+), 317 deletions(-) diff --git a/tooling/pipeline/src/services/sqlite/finalize.cc b/tooling/pipeline/src/services/sqlite/finalize.cc index b8e64574..9ce60674 100644 --- a/tooling/pipeline/src/services/sqlite/finalize.cc +++ b/tooling/pipeline/src/services/sqlite/finalize.cc @@ -9,26 +9,26 @@ #include "services/database/sqlite_export_service_helpers.h" void SqliteExportService::Finalize() { - if (db_handle_ == nullptr) { - return; - } + if (db_handle_ == nullptr) { + return; + } - try { - insert_user_address_stmt_.reset(); - insert_user_stmt_.reset(); - insert_brewery_address_stmt_.reset(); - insert_brewery_stmt_.reset(); - insert_city_stmt_.reset(); - if (transaction_open_) { - sqlite_export_service_internal::ExecSql( - db_handle_, "COMMIT;", "Failed to commit SQLite transaction"); - transaction_open_ = false; - } + try { + insert_user_address_stmt_.reset(); + insert_user_stmt_.reset(); + insert_brewery_address_stmt_.reset(); + insert_brewery_stmt_.reset(); + insert_city_stmt_.reset(); + if (transaction_open_) { + sqlite_export_service_internal::ExecSql( + db_handle_, "COMMIT;", "Failed to commit SQLite transaction"); + transaction_open_ = false; + } - db_handle_.reset(); - city_cache_.clear(); - } catch (...) { - RollbackAndCloseNoThrow(); - throw; - } + db_handle_.reset(); + city_cache_.clear(); + } catch (...) { + RollbackAndCloseNoThrow(); + throw; + } } diff --git a/tooling/pipeline/src/services/sqlite/initialize.cc b/tooling/pipeline/src/services/sqlite/initialize.cc index 3089ad0c..e8608c7b 100644 --- a/tooling/pipeline/src/services/sqlite/initialize.cc +++ b/tooling/pipeline/src/services/sqlite/initialize.cc @@ -12,99 +12,99 @@ #include "services/database/sqlite_export_service.h" std::filesystem::path SqliteExportService::BuildDatabasePath() const { - std::filesystem::path base_filename("biergarten_seed_" + run_timestamp_utc_ + - ".sqlite"); - std::filesystem::path candidate = output_path_ / base_filename; + std::filesystem::path base_filename("biergarten_seed_" + run_timestamp_utc_ + + ".sqlite"); + std::filesystem::path candidate = output_path_ / base_filename; - for (int suffix = 1; std::filesystem::exists(candidate); ++suffix) { - candidate = output_path_ / std::filesystem::path( - std::format("biergarten_seed_{}-{}.sqlite", - run_timestamp_utc_, suffix)); - } + for (int suffix = 1; std::filesystem::exists(candidate); ++suffix) { + candidate = output_path_ / std::filesystem::path( + std::format("biergarten_seed_{}-{}.sqlite", + run_timestamp_utc_, suffix)); + } - return candidate; + return candidate; } void SqliteExportService::InitializeSchema() const { - sqlite_export_service_internal::ExecSql( - db_handle_, sqlite_export_service_internal::kCreateCitiesTableSql, - "Failed to create SQLite cities table"); - sqlite_export_service_internal::ExecSql( - db_handle_, sqlite_export_service_internal::kCreateBreweriesTableSql, - "Failed to create SQLite breweries table"); - sqlite_export_service_internal::ExecSql( - db_handle_, - sqlite_export_service_internal::kCreateBreweryAddressesTableSql, - "Failed to create SQLite brewery_addresses table"); - sqlite_export_service_internal::ExecSql( - db_handle_, sqlite_export_service_internal::kCreateUsersTableSql, - "Failed to create SQLite users table"); - sqlite_export_service_internal::ExecSql( - db_handle_, sqlite_export_service_internal::kCreateUserAddressesTableSql, - "Failed to create SQLite user_addresses table"); + sqlite_export_service_internal::ExecSql( + db_handle_, sqlite_export_service_internal::kCreateCitiesTableSql, + "Failed to create SQLite cities table"); + sqlite_export_service_internal::ExecSql( + db_handle_, sqlite_export_service_internal::kCreateBreweriesTableSql, + "Failed to create SQLite breweries table"); + sqlite_export_service_internal::ExecSql( + db_handle_, + sqlite_export_service_internal::kCreateBreweryAddressesTableSql, + "Failed to create SQLite brewery_addresses table"); + sqlite_export_service_internal::ExecSql( + db_handle_, sqlite_export_service_internal::kCreateUsersTableSql, + "Failed to create SQLite users table"); + sqlite_export_service_internal::ExecSql( + db_handle_, sqlite_export_service_internal::kCreateUserAddressesTableSql, + "Failed to create SQLite user_addresses table"); } void SqliteExportService::PrepareStatements() { - insert_city_stmt_ = sqlite_export_service_internal::PrepareStatement( - db_handle_, sqlite_export_service_internal::kInsertCitySql, - "Failed to prepare SQLite city insert statement"); - insert_brewery_stmt_ = sqlite_export_service_internal::PrepareStatement( - db_handle_, sqlite_export_service_internal::kInsertBrewerySql, - "Failed to prepare SQLite brewery insert statement"); - insert_brewery_address_stmt_ = - sqlite_export_service_internal::PrepareStatement( - db_handle_, sqlite_export_service_internal::kInsertBreweryAddressSql, - "Failed to prepare SQLite brewery address insert statement"); - insert_user_stmt_ = sqlite_export_service_internal::PrepareStatement( - db_handle_, sqlite_export_service_internal::kInsertUserSql, - "Failed to prepare SQLite user insert statement"); - insert_user_address_stmt_ = sqlite_export_service_internal::PrepareStatement( - db_handle_, sqlite_export_service_internal::kInsertUserAddressSql, - "Failed to prepare SQLite user address insert statement"); + insert_city_stmt_ = sqlite_export_service_internal::PrepareStatement( + db_handle_, sqlite_export_service_internal::kInsertCitySql, + "Failed to prepare SQLite city insert statement"); + insert_brewery_stmt_ = sqlite_export_service_internal::PrepareStatement( + db_handle_, sqlite_export_service_internal::kInsertBrewerySql, + "Failed to prepare SQLite brewery insert statement"); + insert_brewery_address_stmt_ = + sqlite_export_service_internal::PrepareStatement( + db_handle_, sqlite_export_service_internal::kInsertBreweryAddressSql, + "Failed to prepare SQLite brewery address insert statement"); + insert_user_stmt_ = sqlite_export_service_internal::PrepareStatement( + db_handle_, sqlite_export_service_internal::kInsertUserSql, + "Failed to prepare SQLite user insert statement"); + insert_user_address_stmt_ = sqlite_export_service_internal::PrepareStatement( + db_handle_, sqlite_export_service_internal::kInsertUserAddressSql, + "Failed to prepare SQLite user address insert statement"); } void SqliteExportService::RollbackAndCloseNoThrow() noexcept { - if (db_handle_ == nullptr) { - return; - } + if (db_handle_ == nullptr) { + return; + } - if (transaction_open_) { - sqlite_export_service_internal::RollbackTransactionNoThrow(db_handle_); - transaction_open_ = false; - } + if (transaction_open_) { + sqlite_export_service_internal::RollbackTransactionNoThrow(db_handle_); + transaction_open_ = false; + } - insert_user_address_stmt_.reset(); - insert_user_stmt_.reset(); - insert_brewery_address_stmt_.reset(); - insert_brewery_stmt_.reset(); - insert_city_stmt_.reset(); - db_handle_.reset(); - city_cache_.clear(); + insert_user_address_stmt_.reset(); + insert_user_stmt_.reset(); + insert_brewery_address_stmt_.reset(); + insert_brewery_stmt_.reset(); + insert_city_stmt_.reset(); + db_handle_.reset(); + city_cache_.clear(); } void SqliteExportService::Initialize() { - if (db_handle_ != nullptr) { - throw std::runtime_error("SQLite export service is already initialized"); - } + if (db_handle_ != nullptr) { + throw std::runtime_error("SQLite export service is already initialized"); + } - run_timestamp_utc_ = date_time_provider_->GetUtcTimestamp(); - database_path_ = BuildDatabasePath(); - std::filesystem::create_directories(database_path_.parent_path()); + run_timestamp_utc_ = date_time_provider_->GetUtcTimestamp(); + database_path_ = BuildDatabasePath(); + std::filesystem::create_directories(database_path_.parent_path()); - db_handle_ = sqlite_export_service_internal::OpenDatabase(database_path_); + db_handle_ = sqlite_export_service_internal::OpenDatabase(database_path_); - try { - sqlite_export_service_internal::ExecSql( - db_handle_, "PRAGMA foreign_keys = ON;", - "Failed to enable SQLite foreign keys"); - InitializeSchema(); - PrepareStatements(); - sqlite_export_service_internal::ExecSql( - db_handle_, "BEGIN IMMEDIATE TRANSACTION;", - "Failed to begin SQLite transaction"); - transaction_open_ = true; - } catch (...) { - RollbackAndCloseNoThrow(); - throw; - } + try { + sqlite_export_service_internal::ExecSql( + db_handle_, "PRAGMA foreign_keys = ON;", + "Failed to enable SQLite foreign keys"); + InitializeSchema(); + PrepareStatements(); + sqlite_export_service_internal::ExecSql( + db_handle_, "BEGIN IMMEDIATE TRANSACTION;", + "Failed to begin SQLite transaction"); + transaction_open_ = true; + } catch (...) { + RollbackAndCloseNoThrow(); + throw; + } } diff --git a/tooling/pipeline/src/services/sqlite/process_record.cc b/tooling/pipeline/src/services/sqlite/process_record.cc index a4cf9f1a..1c860aee 100644 --- a/tooling/pipeline/src/services/sqlite/process_record.cc +++ b/tooling/pipeline/src/services/sqlite/process_record.cc @@ -12,164 +12,165 @@ #include "services/database/sqlite_export_service_helpers.h" std::string SqliteExportService::BuildCityKey(const City& city) { - std::ostringstream key_stream; - key_stream << city.city << '\n' - << city.state_province << '\n' - << city.iso3166_2 << '\n' - << city.country << '\n' - << city.iso3166_1 << '\n' - << sqlite_export_service_internal::SerializeVector( - city.local_languages); - return key_stream.str(); + std::ostringstream key_stream; + key_stream << city.city << '\n' + << city.state_province << '\n' + << city.iso3166_2 << '\n' + << city.country << '\n' + << city.iso3166_1 << '\n' + << sqlite_export_service_internal::SerializeVector( + city.local_languages); + return key_stream.str(); } sqlite3_int64 SqliteExportService::ResolveCityId(const City& city) { - const std::string city_key = BuildCityKey(city); - const auto cached_city = city_cache_.find(city_key); - if (cached_city != city_cache_.end()) { - return cached_city->second; - } + const std::string city_key = BuildCityKey(city); + const auto cached_city = city_cache_.find(city_key); + if (cached_city != city_cache_.end()) { + return cached_city->second; + } - const std::string local_languages_json = - sqlite_export_service_internal::SerializeVector(city.local_languages); - const std::string city_regex_json = - sqlite_export_service_internal::SerializeVector( - city.postal_code.city_regexes); + const std::string local_languages_json = + sqlite_export_service_internal::SerializeVector(city.local_languages); + const std::string city_regex_json = + sqlite_export_service_internal::SerializeVector( + city.postal_code.city_regexes); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kCityCityBindIndex, - .value = city.city, - .action = "Failed to bind SQLite city name"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kCityStateProvinceBindIndex, - .value = city.state_province, - .action = "Failed to bind SQLite city state/province"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kCityIso31662BindIndex, - .value = city.iso3166_2, - .action = "Failed to bind SQLite city ISO 3166-2 code"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kCityCountryBindIndex, - .value = city.country, - .action = "Failed to bind SQLite city country"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kCityIso31661BindIndex, - .value = city.iso3166_1, - .action = "Failed to bind SQLite city ISO 3166-1 code"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kCityLanguagesBindIndex, - .value = local_languages_json, - .action = "Failed to bind SQLite city languages"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal:: - kCityPostalCodeCountryFormatRegexBindIndex, - .value = city.postal_code.country_format_regex, - .action = "Failed to bind SQLite city postal-code format regex"}); - sqlite_export_service_internal::Bind( - insert_city_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal:: - kCityPostalCodeCityRegexJsonBindIndex, - .value = city_regex_json, - .action = "Failed to bind SQLite city postal-code city regexes"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kCityCityBindIndex, + .value = city.city, + .action = "Failed to bind SQLite city name"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kCityStateProvinceBindIndex, + .value = city.state_province, + .action = "Failed to bind SQLite city state/province"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kCityIso31662BindIndex, + .value = city.iso3166_2, + .action = "Failed to bind SQLite city ISO 3166-2 code"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kCityCountryBindIndex, + .value = city.country, + .action = "Failed to bind SQLite city country"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kCityIso31661BindIndex, + .value = city.iso3166_1, + .action = "Failed to bind SQLite city ISO 3166-1 code"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kCityLanguagesBindIndex, + .value = local_languages_json, + .action = "Failed to bind SQLite city languages"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal:: + kCityPostalCodeCountryFormatRegexBindIndex, + .value = city.postal_code.country_format_regex, + .action = "Failed to bind SQLite city postal-code format regex"}); + sqlite_export_service_internal::Bind( + insert_city_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal:: + kCityPostalCodeCityRegexJsonBindIndex, + .value = city_regex_json, + .action = "Failed to bind SQLite city postal-code city regexes"}); - sqlite_export_service_internal::StepStatement( - db_handle_, insert_city_stmt_, "Failed to insert SQLite city row"); + sqlite_export_service_internal::StepStatement( + db_handle_, insert_city_stmt_, "Failed to insert SQLite city row"); - const sqlite3_int64 city_id = - sqlite_export_service_internal::LastInsertRowId(db_handle_); - city_cache_.emplace(city_key, city_id); - sqlite_export_service_internal::ResetStatement(insert_city_stmt_); + const sqlite3_int64 city_id = + sqlite_export_service_internal::LastInsertRowId(db_handle_); + city_cache_.emplace(city_key, city_id); + sqlite_export_service_internal::ResetStatement(insert_city_stmt_); - return city_id; + return city_id; } uint64_t SqliteExportService::ProcessRecord(const BreweryRecord& brewery) { - if (db_handle_ == nullptr || !transaction_open_) { - throw std::runtime_error("SQLite export service is not initialized"); - } + if (db_handle_ == nullptr || !transaction_open_) { + throw std::runtime_error("SQLite export service is not initialized"); + } - const sqlite3_int64 city_id = ResolveCityId(brewery.address.city); + const sqlite3_int64 city_id = ResolveCityId(brewery.address.city); - sqlite_export_service_internal::Bind( - insert_brewery_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kBreweryEnglishNameBindIndex, - .value = brewery.brewery.name_en, - .action = "Failed to bind SQLite brewery English name"}); + sqlite_export_service_internal::Bind( + insert_brewery_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = + sqlite_export_service_internal::kBreweryEnglishNameBindIndex, + .value = brewery.brewery.name_en, + .action = "Failed to bind SQLite brewery English name"}); - sqlite_export_service_internal::Bind( - insert_brewery_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal:: - kBreweryEnglishDescriptionBindIndex, - .value = brewery.brewery.description_en, - .action = "Failed to bind SQLite brewery English description"}); + sqlite_export_service_internal::Bind( + insert_brewery_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal:: + kBreweryEnglishDescriptionBindIndex, + .value = brewery.brewery.description_en, + .action = "Failed to bind SQLite brewery English description"}); - sqlite_export_service_internal::Bind( - insert_brewery_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kBreweryLocalNameBindIndex, - .value = brewery.brewery.name_local, - .action = "Failed to bind SQLite brewery local name"}); + sqlite_export_service_internal::Bind( + insert_brewery_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kBreweryLocalNameBindIndex, + .value = brewery.brewery.name_local, + .action = "Failed to bind SQLite brewery local name"}); - sqlite_export_service_internal::Bind( - insert_brewery_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = - sqlite_export_service_internal::kBreweryLocalDescriptionBindIndex, - .value = brewery.brewery.description_local, - .action = "Failed to bind SQLite brewery local description"}); + sqlite_export_service_internal::Bind( + insert_brewery_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal:: + kBreweryLocalDescriptionBindIndex, + .value = brewery.brewery.description_local, + .action = "Failed to bind SQLite brewery local description"}); - sqlite_export_service_internal::StepStatement( - db_handle_, insert_brewery_stmt_, "Failed to insert SQLite brewery row"); + sqlite_export_service_internal::StepStatement( + db_handle_, insert_brewery_stmt_, "Failed to insert SQLite brewery row"); - const sqlite3_int64 brewery_id = - sqlite_export_service_internal::LastInsertRowId(db_handle_); + const sqlite3_int64 brewery_id = + sqlite_export_service_internal::LastInsertRowId(db_handle_); - sqlite_export_service_internal::ResetStatement(insert_brewery_stmt_); + sqlite_export_service_internal::ResetStatement(insert_brewery_stmt_); - sqlite_export_service_internal::Bind( - insert_brewery_address_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = - sqlite_export_service_internal::kBreweryAddressBreweryIdBindIndex, - .value = brewery_id, - .action = "Failed to bind SQLite brewery address brewery id"}); - sqlite_export_service_internal::Bind( - insert_brewery_address_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = - sqlite_export_service_internal::kBreweryAddressCityIdBindIndex, - .value = city_id, - .action = "Failed to bind SQLite brewery address city id"}); - sqlite_export_service_internal::Bind( - insert_brewery_address_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal:: - kBreweryAddressPostalCodeBindIndex, - .value = brewery.address.postal_code, - .action = "Failed to bind SQLite brewery address postal code"}); + sqlite_export_service_internal::Bind( + insert_brewery_address_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal:: + kBreweryAddressBreweryIdBindIndex, + .value = brewery_id, + .action = "Failed to bind SQLite brewery address brewery id"}); + sqlite_export_service_internal::Bind( + insert_brewery_address_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = + sqlite_export_service_internal::kBreweryAddressCityIdBindIndex, + .value = city_id, + .action = "Failed to bind SQLite brewery address city id"}); + sqlite_export_service_internal::Bind( + insert_brewery_address_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal:: + kBreweryAddressPostalCodeBindIndex, + .value = brewery.address.postal_code, + .action = "Failed to bind SQLite brewery address postal code"}); - sqlite_export_service_internal::StepStatement( - db_handle_, insert_brewery_address_stmt_, - "Failed to insert SQLite brewery address row"); + sqlite_export_service_internal::StepStatement( + db_handle_, insert_brewery_address_stmt_, + "Failed to insert SQLite brewery address row"); - sqlite_export_service_internal::ResetStatement(insert_brewery_address_stmt_); + sqlite_export_service_internal::ResetStatement(insert_brewery_address_stmt_); - return static_cast(brewery_id); + return static_cast(brewery_id); } diff --git a/tooling/pipeline/src/services/sqlite/process_user_record.cc b/tooling/pipeline/src/services/sqlite/process_user_record.cc index 3b3f369d..322fc382 100644 --- a/tooling/pipeline/src/services/sqlite/process_user_record.cc +++ b/tooling/pipeline/src/services/sqlite/process_user_record.cc @@ -9,94 +9,95 @@ #include "services/database/sqlite_export_service_helpers.h" uint64_t SqliteExportService::ProcessRecord(const UserRecord& user) { - if (db_handle_ == nullptr || !transaction_open_) { - throw std::runtime_error("SQLite export service is not initialized"); - } + if (db_handle_ == nullptr || !transaction_open_) { + throw std::runtime_error("SQLite export service is not initialized"); + } - const sqlite3_int64 city_id = ResolveCityId(user.address.city); + const sqlite3_int64 city_id = ResolveCityId(user.address.city); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserFirstNameBindIndex, - .value = user.user.first_name, - .action = "Failed to bind SQLite user first name"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserLastNameBindIndex, - .value = user.user.last_name, - .action = "Failed to bind SQLite user last name"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserGenderBindIndex, - .value = user.user.gender, - .action = "Failed to bind SQLite user gender"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserUsernameBindIndex, - .value = user.user.username, - .action = "Failed to bind SQLite user username"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserBioBindIndex, - .value = user.user.bio, - .action = "Failed to bind SQLite user bio"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserActivityWeightBindIndex, - .value = static_cast(user.user.activity_weight), - .action = "Failed to bind SQLite user activity weight"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserEmailBindIndex, - .value = user.email, - .action = "Failed to bind SQLite user email"}); - sqlite_export_service_internal::Bind( - insert_user_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserDateOfBirthBindIndex, - .value = user.date_of_birth, - .action = "Failed to bind SQLite user date of birth"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserFirstNameBindIndex, + .value = user.user.first_name, + .action = "Failed to bind SQLite user first name"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserLastNameBindIndex, + .value = user.user.last_name, + .action = "Failed to bind SQLite user last name"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserGenderBindIndex, + .value = user.user.gender, + .action = "Failed to bind SQLite user gender"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserUsernameBindIndex, + .value = user.user.username, + .action = "Failed to bind SQLite user username"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserBioBindIndex, + .value = user.user.bio, + .action = "Failed to bind SQLite user bio"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = + sqlite_export_service_internal::kUserActivityWeightBindIndex, + .value = static_cast(user.user.activity_weight), + .action = "Failed to bind SQLite user activity weight"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserEmailBindIndex, + .value = user.email, + .action = "Failed to bind SQLite user email"}); + sqlite_export_service_internal::Bind( + insert_user_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserDateOfBirthBindIndex, + .value = user.date_of_birth, + .action = "Failed to bind SQLite user date of birth"}); - sqlite_export_service_internal::StepStatement( - db_handle_, insert_user_stmt_, "Failed to insert SQLite user row"); + sqlite_export_service_internal::StepStatement( + db_handle_, insert_user_stmt_, "Failed to insert SQLite user row"); - const sqlite3_int64 user_id = - sqlite_export_service_internal::LastInsertRowId(db_handle_); + const sqlite3_int64 user_id = + sqlite_export_service_internal::LastInsertRowId(db_handle_); - sqlite_export_service_internal::ResetStatement(insert_user_stmt_); + sqlite_export_service_internal::ResetStatement(insert_user_stmt_); - sqlite_export_service_internal::Bind( - insert_user_address_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserAddressUserIdBindIndex, - .value = user_id, - .action = "Failed to bind SQLite user address user id"}); - sqlite_export_service_internal::Bind( - insert_user_address_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = sqlite_export_service_internal::kUserAddressCityIdBindIndex, - .value = city_id, - .action = "Failed to bind SQLite user address city id"}); - sqlite_export_service_internal::Bind( - insert_user_address_stmt_, - sqlite_export_service_internal::BoundParam{ - .index = - sqlite_export_service_internal::kUserAddressPostalCodeBindIndex, - .value = user.address.postal_code, - .action = "Failed to bind SQLite user address postal code"}); + sqlite_export_service_internal::Bind( + insert_user_address_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserAddressUserIdBindIndex, + .value = user_id, + .action = "Failed to bind SQLite user address user id"}); + sqlite_export_service_internal::Bind( + insert_user_address_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = sqlite_export_service_internal::kUserAddressCityIdBindIndex, + .value = city_id, + .action = "Failed to bind SQLite user address city id"}); + sqlite_export_service_internal::Bind( + insert_user_address_stmt_, + sqlite_export_service_internal::BoundParam{ + .index = + sqlite_export_service_internal::kUserAddressPostalCodeBindIndex, + .value = user.address.postal_code, + .action = "Failed to bind SQLite user address postal code"}); - sqlite_export_service_internal::StepStatement( - db_handle_, insert_user_address_stmt_, - "Failed to insert SQLite user address row"); + sqlite_export_service_internal::StepStatement( + db_handle_, insert_user_address_stmt_, + "Failed to insert SQLite user address row"); - sqlite_export_service_internal::ResetStatement(insert_user_address_stmt_); + sqlite_export_service_internal::ResetStatement(insert_user_address_stmt_); - return static_cast(user_id); + return static_cast(user_id); } diff --git a/tooling/pipeline/src/services/sqlite/sqlite_export_service.cc b/tooling/pipeline/src/services/sqlite/sqlite_export_service.cc index 73d11eb4..3d902aa8 100644 --- a/tooling/pipeline/src/services/sqlite/sqlite_export_service.cc +++ b/tooling/pipeline/src/services/sqlite/sqlite_export_service.cc @@ -12,7 +12,7 @@ SqliteExportService::SqliteExportService(const ApplicationOptions& options) output_path_(options.pipeline.output_path) {} SqliteExportService::~SqliteExportService() { - if (db_handle_ != nullptr) { - RollbackAndCloseNoThrow(); - } + if (db_handle_ != nullptr) { + RollbackAndCloseNoThrow(); + } }