summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular/src/sql_pt_representation.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_regular/src/sql_pt_representation.cc')
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc62
1 files changed, 29 insertions, 33 deletions
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 49b7f2e7be..7193a06bdb 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -92,9 +92,8 @@ void SQLPTRepresentation::CheckPermissions(const PTString& app_id,
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectRpc)) {
- SDL_LOG_WARN(
-
- "Incorrect select statement from rpcs" << query.LastError().text());
+ SDL_LOG_WARN("Incorrect select statement from rpcs"
+ << query.LastError().text());
return;
}
query.Bind(0, app_id);
@@ -363,9 +362,8 @@ InitResult SQLPTRepresentation::Init(const PolicySettings* settings) {
utils::dbms::SQLQuery check_first_run(db());
if (check_first_run.Prepare(sql_pt::kIsFirstRun) &&
check_first_run.Next()) {
- SDL_LOG_INFO(
-
- "Selecting is first run " << check_first_run.GetBoolean(0));
+ SDL_LOG_INFO("Selecting is first run "
+ << check_first_run.GetBoolean(0));
if (check_first_run.GetBoolean(0)) {
utils::dbms::SQLQuery set_not_first_run(db());
set_not_first_run.Exec(sql_pt::kSetNotFirstRun);
@@ -387,13 +385,11 @@ InitResult SQLPTRepresentation::Init(const PolicySettings* settings) {
utils::dbms::SQLQuery query(db());
if (!query.Exec(sql_pt::kCreateSchema)) {
SDL_LOG_ERROR(
-
"Failed creating schema of database: " << query.LastError().text());
return InitResult::FAIL;
}
if (!query.Exec(sql_pt::kInsertInitData)) {
SDL_LOG_ERROR(
-
"Failed insert init data to database: " << query.LastError().text());
return InitResult::FAIL;
}
@@ -426,7 +422,6 @@ bool SQLPTRepresentation::Clear() {
}
if (!query.Exec(sql_pt::kInsertInitData)) {
SDL_LOG_ERROR(
-
"Failed insert init data to database: " << query.LastError().text());
return false;
}
@@ -441,13 +436,11 @@ bool SQLPTRepresentation::RefreshDB() {
}
if (!query.Exec(sql_pt::kCreateSchema)) {
SDL_LOG_ERROR(
-
"Failed creating schema of database: " << query.LastError().text());
return false;
}
if (!query.Exec(sql_pt::kInsertInitData)) {
SDL_LOG_ERROR(
-
"Failed insert init data to database: " << query.LastError().text());
return false;
}
@@ -2625,22 +2618,25 @@ policy_table::VehicleDataItem SQLPTRepresentation::PopulateVDIFromQuery(
*result.deprecated = query.GetBoolean(8);
}
if (!query.IsNull(9)) {
- *result.minvalue = query.GetInteger(9);
+ *result.defvalue = query.GetString(9);
}
if (!query.IsNull(10)) {
- *result.maxvalue = query.GetInteger(10);
+ *result.minvalue = query.GetInteger(10);
}
if (!query.IsNull(11)) {
- *result.minsize = query.GetUInteger(11);
+ *result.maxvalue = query.GetInteger(11);
}
if (!query.IsNull(12)) {
- *result.maxsize = query.GetUInteger(12);
+ *result.minsize = query.GetUInteger(12);
}
if (!query.IsNull(13)) {
- *result.minlength = query.GetUInteger(13);
+ *result.maxsize = query.GetUInteger(13);
}
if (!query.IsNull(14)) {
- *result.maxlength = query.GetUInteger(14);
+ *result.minlength = query.GetUInteger(14);
+ }
+ if (!query.IsNull(15)) {
+ *result.maxlength = query.GetUInteger(15);
}
result.params->mark_initialized();
@@ -2688,24 +2684,27 @@ bool SQLPTRepresentation::InsertVehicleDataItem(
vehicle_data_item.deprecated.is_initialized()
? query.Bind(8, *vehicle_data_item.deprecated)
: query.Bind(8);
- vehicle_data_item.minvalue.is_initialized()
- ? query.Bind(9, *vehicle_data_item.minvalue)
+ vehicle_data_item.defvalue.is_initialized()
+ ? query.Bind(9, *vehicle_data_item.defvalue)
: query.Bind(9);
- vehicle_data_item.maxvalue.is_initialized()
- ? query.Bind(10, *vehicle_data_item.maxvalue)
+ vehicle_data_item.minvalue.is_initialized()
+ ? query.Bind(10, *vehicle_data_item.minvalue)
: query.Bind(10);
- vehicle_data_item.minsize.is_initialized()
- ? query.Bind(11, static_cast<int64_t>(*vehicle_data_item.minsize))
+ vehicle_data_item.maxvalue.is_initialized()
+ ? query.Bind(11, *vehicle_data_item.maxvalue)
: query.Bind(11);
- vehicle_data_item.maxsize.is_initialized()
- ? query.Bind(12, static_cast<int64_t>(*vehicle_data_item.maxsize))
+ vehicle_data_item.minsize.is_initialized()
+ ? query.Bind(12, static_cast<int64_t>(*vehicle_data_item.minsize))
: query.Bind(12);
- vehicle_data_item.minlength.is_initialized()
- ? query.Bind(13, static_cast<int64_t>(*vehicle_data_item.minlength))
+ vehicle_data_item.maxsize.is_initialized()
+ ? query.Bind(13, static_cast<int64_t>(*vehicle_data_item.maxsize))
: query.Bind(13);
- vehicle_data_item.maxlength.is_initialized()
- ? query.Bind(14, static_cast<int64_t>(*vehicle_data_item.maxlength))
+ vehicle_data_item.minlength.is_initialized()
+ ? query.Bind(14, static_cast<int64_t>(*vehicle_data_item.minlength))
: query.Bind(14);
+ vehicle_data_item.maxlength.is_initialized()
+ ? query.Bind(15, static_cast<int64_t>(*vehicle_data_item.maxlength))
+ : query.Bind(15);
if (!query.Exec() || !query.Reset()) {
SDL_LOG_ERROR("Failed to insert vehicle data item: "
@@ -2740,7 +2739,6 @@ bool SQLPTRepresentation::InsertVehicleDataItem(
if (!query.Exec() || !query.Reset()) {
SDL_LOG_ERROR(
-
"Failed to insert to vehicle data item relations helper table: "
<< static_cast<std::string>(param.key)
<< ". Error: " << query.LastError().text());
@@ -2770,9 +2768,7 @@ SQLPTRepresentation::SelectCompositeVehicleDataItems() const {
if (!vdi.is_initialized()) {
return policy_table::VehicleDataItems();
}
- for (const auto& item : vdi) {
- result.push_back(item);
- }
+ std::copy(vdi.begin(), vdi.end(), std::back_inserter(result));
}
return result;