LCOV - code coverage report
Current view: top level - core/sql - SPSqlUpdate.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 32 38 84.2 %
Date: 2024-05-12 00:16:13 Functions: 13 17 76.5 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2017-2022 Roman Katuntsev <sbkarr@stappler.org>
       3             : Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       4             : 
       5             : Permission is hereby granted, free of charge, to any person obtaining a copy
       6             : of this software and associated documentation files (the "Software"), to deal
       7             : in the Software without restriction, including without limitation the rights
       8             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       9             : copies of the Software, and to permit persons to whom the Software is
      10             : furnished to do so, subject to the following conditions:
      11             : 
      12             : The above copyright notice and this permission notice shall be included in
      13             : all copies or substantial portions of the Software.
      14             : 
      15             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      18             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      20             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      21             : THE SOFTWARE.
      22             : **/
      23             : 
      24             : // Excluded from documentation/codegen tool
      25             : ///@ SP_EXCLUDE
      26             : 
      27             : #ifndef STAPPLER_SQL_SPSQLUPDATE_HPP_
      28             : #define STAPPLER_SQL_SPSQLUPDATE_HPP_
      29             : 
      30             : #include "SPSql.h"
      31             : 
      32             : namespace STAPPLER_VERSIONIZED stappler::sql {
      33             : 
      34             : template <typename Binder, typename Interface>
      35             : template <typename ... Args>
      36        3075 : auto Query<Binder, Interface>::Update::where(Args && ... args) -> UpdateWhere {
      37        3075 :         this->query->stream << " WHERE";
      38        3075 :         UpdateWhere q(this->query);
      39        3075 :         q.where(sql::Operator::And, forward<Args>(args)...);
      40        3075 :         return q;
      41             : };
      42             : 
      43             : template <typename Binder, typename Interface>
      44           0 : auto Query<Binder, Interface>::Update::where() -> UpdateWhere {
      45           0 :         this->query->stream << " WHERE";
      46           0 :         return UpdateWhere(this->query);
      47             : }
      48             : 
      49             : template <typename Binder, typename Interface>
      50             : auto Query<Binder, Interface>::Update::returning() -> Returning {
      51             :         this->query->stream << " RETURNING";
      52             :         return Returning(this->query);
      53             : }
      54             : 
      55             : template <typename Binder, typename Interface>
      56        2575 : auto Query<Binder, Interface>::UpdateWhere::returning() -> Returning {
      57        2575 :         this->query->stream << " RETURNING";
      58        2575 :         return Returning(this->query);
      59             : }
      60             : 
      61             : template <typename Binder, typename Interface>
      62        3050 : auto Query<Binder, Interface>::update(const StringView & field) -> Update {
      63        3050 :         stream << "UPDATE " << field << " SET";
      64        3050 :         target = field;
      65        3050 :         return Update(this);
      66             : }
      67             : 
      68             : template <typename Binder, typename Interface>
      69          25 : auto Query<Binder, Interface>::update(const StringView &field, const StringView &alias) -> Update {
      70          25 :         stream << "UPDATE " << field << " AS " << alias << " SET";
      71          25 :         target = field;
      72          25 :         return Update(this);
      73             : }
      74             : 
      75             : 
      76             : template <typename Binder, typename Interface>
      77             : template <typename ... Args>
      78         400 : auto Query<Binder, Interface>::Delete::where(Args && ... args) -> DeleteWhere {
      79         400 :         this->query->stream << " WHERE";
      80         400 :         DeleteWhere q(this->query);
      81         400 :         q.where(sql::Operator::And, forward<Args>(args)...);
      82         400 :         return q;
      83             : };
      84             : 
      85             : template <typename Binder, typename Interface>
      86           0 : auto Query<Binder, Interface>::Delete::where() -> DeleteWhere {
      87           0 :         this->query->stream << " WHERE";
      88           0 :         return DeleteWhere(this->query);
      89             : }
      90             : 
      91             : template <typename Binder, typename Interface>
      92             : auto Query<Binder, Interface>::Delete::returning() -> Returning {
      93             :         this->query->stream << " RETURNING";
      94             :         return Returning(this->query);
      95             : }
      96             : 
      97             : template <typename Binder, typename Interface>
      98          25 : auto Query<Binder, Interface>::DeleteWhere::returning() -> Returning {
      99          25 :         this->query->stream << " RETURNING";
     100          25 :         return Returning(this->query);
     101             : }
     102             : 
     103             : template <typename Binder, typename Interface>
     104         375 : auto Query<Binder, Interface>::remove(const StringView & field) -> Delete {
     105         375 :         stream << "DELETE FROM " << field;
     106         375 :         target = field;
     107         375 :         return Delete(this);
     108             : }
     109             : 
     110             : template <typename Binder, typename Interface>
     111          25 : auto Query<Binder, Interface>::remove(const StringView &field, const StringView &alias) -> Delete {
     112          25 :         stream << "DELETE FROM " << field << " AS " << alias;
     113          25 :         target = field;
     114          25 :         return Delete(this);
     115             : }
     116             : 
     117             : }
     118             : 
     119             : #endif /* STAPPLER_SQL_SPSQLUPDATE_HPP_ */

Generated by: LCOV version 1.14