LCOV - code coverage report
Current view: top level - core/db - SPDbFieldExtensions.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2024-05-12 00:16:13 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2019-2022 Roman Katuntsev <sbkarr@stappler.org>
       3             : Copyright (c) 2023-2024 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             : #ifndef STAPPLER_DB_SPDBFIELDEXTENSIONS_H_
      25             : #define STAPPLER_DB_SPDBFIELDEXTENSIONS_H_
      26             : 
      27             : #include "SPDbField.h"
      28             : #include "SPSqlDriver.h"
      29             : 
      30             : namespace STAPPLER_VERSIONIZED stappler::db {
      31             : 
      32             : struct FieldIntArray : db::FieldCustom {
      33             :         static auto constexpr FIELD_NAME = StringView("INT[]");
      34             :         static bool registerForPostgres(CustomFieldInfo &);
      35             :         static bool registerForSqlite(CustomFieldInfo &);
      36             : 
      37             :         template <typename ... Args>
      38          75 :         FieldIntArray(String && n, Args && ... args) : FieldCustom(std::move(n), std::forward<Args>(args)...) { }
      39             : 
      40        5300 :         virtual StringView getDriverTypeName() const override { return FIELD_NAME; }
      41             : 
      42             :         virtual bool transformValue(const db::Scheme &, const Value &obj, Value &val, bool isCreate) const override;
      43             :         virtual bool isSimpleLayout() const override;
      44             : };
      45             : 
      46             : struct FieldBigIntArray : db::FieldCustom {
      47             :         static auto constexpr FIELD_NAME = StringView("BIGINT[]");
      48             :         static bool registerForPostgres(CustomFieldInfo &);
      49             :         static bool registerForSqlite(CustomFieldInfo &);
      50             : 
      51             :         template <typename ... Args>
      52          75 :         FieldBigIntArray(String && n, Args && ... args) : FieldCustom(std::move(n), std::forward<Args>(args)...) { }
      53             : 
      54        5300 :         virtual StringView getDriverTypeName() const override { return FIELD_NAME; }
      55             : 
      56             :         virtual bool transformValue(const db::Scheme &, const Value &obj, Value &val, bool isCreate) const override;
      57             :         virtual bool isSimpleLayout() const override;
      58             : };
      59             : 
      60             : struct FieldPoint : db::FieldCustom {
      61             :         static auto constexpr FIELD_NAME = StringView("POINT");
      62             :         static bool registerForPostgres(CustomFieldInfo &);
      63             :         static bool registerForSqlite(CustomFieldInfo &);
      64             : 
      65             :         template <typename ... Args>
      66          75 :         FieldPoint(String && n, Args && ... args) : FieldCustom(std::move(n), std::forward<Args>(args)...) { }
      67             : 
      68         100 :         virtual StringView getDriverTypeName() const override { return FIELD_NAME; }
      69             : 
      70             :         virtual bool transformValue(const db::Scheme &, const Value &obj, Value &val, bool isCreate) const override;
      71             :         virtual bool isSimpleLayout() const override;
      72             : };
      73             : 
      74             : struct FieldTextArray : db::FieldCustom {
      75             :         static auto constexpr FIELD_NAME = StringView("TEXT[]");
      76             :         static bool registerForPostgres(CustomFieldInfo &);
      77             :         static bool registerForSqlite(CustomFieldInfo &);
      78             : 
      79             :         template <typename ... Args>
      80         150 :         FieldTextArray(String && n, Args && ... args) : FieldCustom(std::move(n), std::forward<Args>(args)...) { }
      81             : 
      82        7850 :         virtual StringView getDriverTypeName() const override { return FIELD_NAME; }
      83             : 
      84             :         virtual bool transformValue(const db::Scheme &, const Value &obj, Value &val, bool isCreate) const override;
      85             :         virtual bool isSimpleLayout() const override;
      86             : };
      87             : 
      88             : }
      89             : 
      90             : #endif /* STAPPLER_DB_SPDBFIELDEXTENSIONS_H_ */

Generated by: LCOV version 1.14