LCOV - code coverage report
Current view: top level - backenddb - update_template.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 17 17
Test Date: 2026-09-04 23:42:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2022-2024 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :    You should have received a copy of the GNU General Public License along with
      14              :    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : /**
      17              :  * @file src/backenddb/update_template.c
      18              :  * @brief Implementation of the update_template function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include <taler/taler_pq_lib.h>
      23              : #include "merchant-database/update_template.h"
      24              : #include "helper.h"
      25              : 
      26              : 
      27              : enum GNUNET_DB_QueryStatus
      28            8 : TALER_MERCHANTDB_update_template (
      29              :   struct TALER_MERCHANTDB_PostgresContext *pg,
      30              :   const char *instance_id,
      31              :   const char *template_id,
      32              :   const struct TALER_MERCHANTDB_TemplateDetails *td)
      33              : {
      34            8 :   struct GNUNET_PQ_QueryParam params[] = {
      35            8 :     GNUNET_PQ_query_param_string (template_id),
      36            8 :     GNUNET_PQ_query_param_string (td->template_description),
      37            8 :     (NULL == td->otp_id)
      38            3 :     ? GNUNET_PQ_query_param_null ()
      39            8 :     : GNUNET_PQ_query_param_string (td->otp_id),
      40            8 :     TALER_PQ_query_param_json (td->template_contract),
      41            8 :     (NULL == td->editable_defaults)
      42            8 :     ? GNUNET_PQ_query_param_null ()
      43            8 :     : TALER_PQ_query_param_json (td->editable_defaults),
      44              :     GNUNET_PQ_query_param_end
      45              :   };
      46              :   enum GNUNET_DB_QueryStatus qs;
      47              : 
      48            8 :   GNUNET_assert (NULL != pg->current_merchant_id);
      49            8 :   GNUNET_assert (0 == strcmp (instance_id,
      50              :                               pg->current_merchant_id));
      51            8 :   TMH_PQ_prepare_anon (pg,
      52              :                        "WITH otp AS ("
      53              :                        "   SELECT otp_serial"
      54              :                        "     FROM merchant_otp_devices"
      55              :                        "    WHERE otp_id=$3)"
      56              :                        "UPDATE merchant_template SET"
      57              :                        " template_description=$2"
      58              :                        ",otp_device_id="
      59              :                        "  COALESCE((SELECT otp_serial"
      60              :                        "            FROM otp), NULL)"
      61              :                        ",template_contract=$4::TEXT::JSONB"
      62              :                        ",editable_defaults=$5::TEXT::JSONB"
      63              :                        " WHERE template_id=$1");
      64            8 :   qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
      65              :                                            "",
      66              :                                            params);
      67            8 :   GNUNET_PQ_cleanup_query_params_closures (params);
      68            8 :   return qs;
      69              : }
        

Generated by: LCOV version 2.0-1