From 92675471277168f2b4d3b6c3de68fb7a39ccd524 Mon Sep 17 00:00:00 2001 From: Jacyking <791026912@qq.com> Date: Mon, 8 Apr 2024 16:58:59 +0800 Subject: [PATCH 1/4] fix pg complier error on clang --- ormpp/postgresql.hpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ormpp/postgresql.hpp b/ormpp/postgresql.hpp index 41fd69cf..a8727c68 100644 --- a/ormpp/postgresql.hpp +++ b/ormpp/postgresql.hpp @@ -64,7 +64,7 @@ class postgresql { bool ping() { return (PQstatus(con_) == CONNECTION_OK); } template - constexpr auto create_datatable(Args &&...args) { + bool create_datatable(Args &&...args) { std::string sql = generate_createtb_sql(std::forward(args)...); #ifdef ORMPP_ENABLE_LOG std::cout << sql << std::endl; @@ -200,8 +200,8 @@ class postgresql { } template - constexpr std::enable_if_t, std::vector> - query_s(const std::string &sql, Args &&...args) { + std::enable_if_t, std::vector> query_s( + const std::string &sql, Args &&...args) { static_assert(iguana::is_tuple::value); #ifdef ORMPP_ENABLE_LOG std::cout << sql << std::endl; @@ -289,7 +289,7 @@ class postgresql { } template - constexpr std::enable_if_t, std::vector> query( + std::enable_if_t, std::vector> query( const Arg &s, Args &&...args) { static_assert(iguana::is_tuple::value); constexpr auto SIZE = std::tuple_size_v; @@ -342,7 +342,7 @@ class postgresql { } // just support execute string sql without placeholders - auto execute(const std::string &sql) { + bool execute(const std::string &sql) { #ifdef ORMPP_ENABLE_LOG std::cout << sql << std::endl; #endif @@ -649,8 +649,8 @@ class postgresql { } template - constexpr void set_param_values(std::vector> ¶m_values, - T &&value) { + void set_param_values(std::vector> ¶m_values, + T &&value) { using U = std::remove_const_t>; if constexpr (is_optional_v::value) { if (value.has_value()) { @@ -667,7 +667,10 @@ class postgresql { } else if constexpr (std::is_integral_v && !iguana::is_int64_v) { std::vector temp(20, 0); - if constexpr (iguana::is_char_type::value) { + if constexpr (std::is_same_v) { + temp.front() = value; + } + else if constexpr (iguana::is_char_type::value) { itoa_fwd(value, temp.data()); } else { From 74cbd12a1a08ff7a8d001a793aeeca4f53d9adbe Mon Sep 17 00:00:00 2001 From: Jacyking <791026912@qq.com> Date: Mon, 8 Apr 2024 17:27:09 +0800 Subject: [PATCH 2/4] fix pg complier error on clang --- .github/workflows/ci-mysql.yml | 8 ++++---- .github/workflows/ci-pgsql.yml | 11 ++++++----- .github/workflows/ci-sqlite.yml | 8 ++++---- .github/workflows/code-coverage.yml | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index d4d666de..ab60ecbf 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -25,13 +25,13 @@ jobs: database: test_ormppdb - name: Configure cmake - run: cmake -B${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_MYSQL=ON + run: cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_MYSQL=ON - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{ matrix.configuration }} + run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{ github.workspace }}/build env: CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C ${{ matrix.configuration }} -j `nproc` -V \ No newline at end of file + run: ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index de6e471c..a4ff2bdb 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -5,12 +5,13 @@ on: [ push, pull_request ] jobs: build-and-test: - name: ${{ matrix.os }} (${{ matrix.configuration }}) + name: ${{ matrix.os }} (${{ matrix.configuration }}) (${{ matrix.compiler }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: + compiler: [ gcc, clang ] configuration: [ Debug, Release ] os: [ ubuntu-latest ] # macos-latest, ubuntu-latest, windows-latest @@ -34,13 +35,13 @@ jobs: uses: actions/checkout@v2 - name: Configure cmake - run: cmake -B${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_PG=ON + run: cmake -B${{ github.workspace }}/build -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_PG=ON - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{ matrix.configuration }} + run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{ github.workspace }}/build env: CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C ${{ matrix.configuration }} -j `nproc` -V \ No newline at end of file + run: ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file diff --git a/.github/workflows/ci-sqlite.yml b/.github/workflows/ci-sqlite.yml index 95c803a8..c3ae9d52 100644 --- a/.github/workflows/ci-sqlite.yml +++ b/.github/workflows/ci-sqlite.yml @@ -19,13 +19,13 @@ jobs: uses: actions/checkout@v2 - name: Configure cmake - run: cmake -B${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_SQLITE3=ON + run: cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_SQLITE3=ON - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{ matrix.configuration }} + run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{ github.workspace }}/build env: CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C ${{ matrix.configuration }} -j `nproc` -V \ No newline at end of file + run: ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 8ad7f0ec..8113febb 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -23,13 +23,13 @@ jobs: run: mysql -uroot -e'show databases;' - name: Configure cmake - run: cmake -B${{github.workspace}}/build -DCOVERAGE_TEST=ON -DENABLE_MYSQL=ON -DCMAKE_BUILD_TYPE=Debug + run: cmake -B${{ github.workspace }}/build -DCOVERAGE_TEST=ON -DENABLE_MYSQL=ON -DCMAKE_BUILD_TYPE=Debug - name: Build - run: cmake --build ${{github.workspace}}/build --config Debug + run: cmake --build ${{ github.workspace }}/build --config Debug - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{ github.workspace }}/build env: CTEST_OUTPUT_ON_FAILURE: 1 run: ctest -C Debug -j `nproc` -V From d2b469ffa9ed0f1b61539e8e4706564375560d7d Mon Sep 17 00:00:00 2001 From: Jacyking <791026912@qq.com> Date: Mon, 8 Apr 2024 17:33:18 +0800 Subject: [PATCH 3/4] fix pg complier error on clang --- .github/workflows/ci-mysql.yml | 8 ++++---- .github/workflows/ci-pgsql.yml | 21 ++++++++++++++++----- .github/workflows/ci-sqlite.yml | 8 ++++---- .github/workflows/clang-format.yml | 4 ++-- .github/workflows/code-coverage.yml | 10 +++++----- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index ab60ecbf..b4ec6ea3 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -25,13 +25,13 @@ jobs: database: test_ormppdb - name: Configure cmake - run: cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_MYSQL=ON + run : cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_MYSQL=ON - name: Build - run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} + run : cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} - name: Test working-directory: ${{ github.workspace }}/build - env: + env : CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file + run : ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index a4ff2bdb..f581a6d0 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -11,9 +11,17 @@ jobs: strategy: fail-fast: false matrix: - compiler: [ gcc, clang ] configuration: [ Debug, Release ] os: [ ubuntu-latest ] # macos-latest, ubuntu-latest, windows-latest + include: + - os: ubuntu-latest + compiler: gcc + cc: g++ + cxx: g++ + - os: ubuntu-latest + compiler: clang + cc: clang++ + cxx: clang++ services: postgres: @@ -35,13 +43,16 @@ jobs: uses: actions/checkout@v2 - name: Configure cmake - run: cmake -B${{ github.workspace }}/build -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_PG=ON + env : + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + run : cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_PG=ON - name: Build - run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} + run : cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} - name: Test working-directory: ${{ github.workspace }}/build - env: + env : CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file + run : ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file diff --git a/.github/workflows/ci-sqlite.yml b/.github/workflows/ci-sqlite.yml index c3ae9d52..1910ef7c 100644 --- a/.github/workflows/ci-sqlite.yml +++ b/.github/workflows/ci-sqlite.yml @@ -19,13 +19,13 @@ jobs: uses: actions/checkout@v2 - name: Configure cmake - run: cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_SQLITE3=ON + run : cmake -B${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_SQLITE3=ON - name: Build - run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} + run : cmake --build ${{ github.workspace }}/build --config ${{ matrix.configuration }} - name: Test working-directory: ${{ github.workspace }}/build - env: + env : CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file + run : ctest -C ${{ matrix.configuration }} -j 1 -V \ No newline at end of file diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index fd179a31..63bfffde 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -13,10 +13,10 @@ jobs: fetch-depth: 0 - name: install clang-format - run: sudo apt install clang-format + run : sudo apt install clang-format - name: check-diff - run: | + run : | diff=`git-clang-format --diff HEAD^` if ! [[ "$diff" = "no modified files to format" || "$diff" = "clang-format did not modify any files" ]]; then echo "The diff you sent is not formatted correctly." diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 8113febb..bead43f0 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -20,19 +20,19 @@ jobs: database: test_ormppdb - name: Verify MySQL - run: mysql -uroot -e'show databases;' + run : mysql -uroot -e'show databases;' - name: Configure cmake - run: cmake -B${{ github.workspace }}/build -DCOVERAGE_TEST=ON -DENABLE_MYSQL=ON -DCMAKE_BUILD_TYPE=Debug + run : cmake -B${{ github.workspace }}/build -DCOVERAGE_TEST=ON -DENABLE_MYSQL=ON -DCMAKE_BUILD_TYPE=Debug - name: Build - run: cmake --build ${{ github.workspace }}/build --config Debug + run : cmake --build ${{ github.workspace }}/build --config Debug - name: Test working-directory: ${{ github.workspace }}/build - env: + env : CTEST_OUTPUT_ON_FAILURE: 1 - run: ctest -C Debug -j `nproc` -V + run : ctest -C Debug -j `nproc` -V - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 \ No newline at end of file From a3c3bd345241fa452a6708858e422b349ac61845 Mon Sep 17 00:00:00 2001 From: Jacyking <791026912@qq.com> Date: Mon, 8 Apr 2024 17:36:09 +0800 Subject: [PATCH 4/4] fix pg complier error on clang --- .github/workflows/ci-pgsql.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index f581a6d0..d873b3a2 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -11,16 +11,17 @@ jobs: strategy: fail-fast: false matrix: + compiler: [ gcc, clang ] configuration: [ Debug, Release ] os: [ ubuntu-latest ] # macos-latest, ubuntu-latest, windows-latest include: - os: ubuntu-latest compiler: gcc - cc: g++ + cc: gcc cxx: g++ - os: ubuntu-latest compiler: clang - cc: clang++ + cc: clang cxx: clang++ services: