Skip to content

Commit

Permalink
Merge pull request #42 from IvanKuchin/development
Browse files Browse the repository at this point in the history
Bugfix: DB throws an error when pull out BT-list, if SOW-list is empty
  • Loading branch information
IvanKuchin authored Apr 21, 2022
2 parents 4c62622 + 694b986 commit cdd74bb
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/pd/utilities_timecard3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,16 @@ static auto __GetBTList(const string &sow_where_statement, const string &sow_lim
auto sow_ids = GetValuesFromDB(sow_statement, db);

return
"\"sow\":[" + GetSOWInJSONFormat("SELECT * FROM `contracts_sow` WHERE `id` IN (" + join(sow_ids, ",") + ");", db, user, true, false, false, true) + "],"
"\"bt\":[" + GetBTsInJSONFormat(
"SELECT * FROM `bt` WHERE "
"`contract_sow_id` IN (" + join(sow_ids, ",") + ")"
+ bt_where_statement +
";", db, user, isExtended) + "]"
"\"sow\":[" + (sow_ids.size() ? GetSOWInJSONFormat("SELECT * FROM `contracts_sow` WHERE `id` IN (" + join(sow_ids, ",") + ");", db, user, true, false, false, true)
: "")
+ "],"
"\"bt\":[" + (sow_ids.size() ? GetBTsInJSONFormat(
"SELECT * FROM `bt` WHERE "
"`contract_sow_id` IN (" + join(sow_ids, ",") + ")"
+ bt_where_statement +
";", db, user, isExtended)
: "")
+ "]"
;
}

Expand Down Expand Up @@ -793,15 +797,20 @@ static auto __GetTimecardList(const string &sow_where_statement, const string &s
auto sow_ids = GetValuesFromDB(sow_statement, db);

return
"\"sow\":[" + (sow_ids.size() ? GetSOWInJSONFormat("SELECT * FROM `contracts_sow` WHERE `id` IN (" + join(sow_ids, ",") + ");", db, user, false, false, false, true) : "") + "],"
"\"timecards\":[" + (sow_ids.size() ?
GetTimecardsInJSONFormat(
"SELECT * FROM `timecards` WHERE "
"`contract_sow_id` IN (" + join(sow_ids, ",") + ")"
+ timecard_where_statement +
";", db, user)
: "") + "],"
"\"holiday_calendar\":[" + (sow_ids.size() ? GetHolidayCalendarInJSONFormat("SELECT * FROM `holiday_calendar` WHERE `agency_company_id` IN (SELECT `agency_company_id` FROM `contracts_sow` WHERE " + sow_where_statement + ");", db, user) : "") + "]"
"\"sow\":[" + (sow_ids.size() ? GetSOWInJSONFormat("SELECT * FROM `contracts_sow` WHERE `id` IN (" + join(sow_ids, ",") + ");", db, user, false, false, false, true)
: "")
+ "],"
"\"timecards\":[" + (sow_ids.size() ?
GetTimecardsInJSONFormat(
"SELECT * FROM `timecards` WHERE "
"`contract_sow_id` IN (" + join(sow_ids, ",") + ")"
+ timecard_where_statement +
";", db, user)
: "")
+ "],"
"\"holiday_calendar\":[" + (sow_ids.size() ? GetHolidayCalendarInJSONFormat("SELECT * FROM `holiday_calendar` WHERE `agency_company_id` IN (SELECT `agency_company_id` FROM `contracts_sow` WHERE " + sow_where_statement + ");", db, user)
: "")
+ "]"
;
}

Expand Down

0 comments on commit cdd74bb

Please sign in to comment.