Skip to content

Commit

Permalink
Merge pull request #157 from Jacyking/master
Browse files Browse the repository at this point in the history
fix pg compiler error on clang
  • Loading branch information
Jacyking committed Apr 8, 2024
2 parents df340f6 + a3c3bd3 commit b40b27f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 32 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
working-directory: ${{ github.workspace }}/build
env :
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest -C ${{ matrix.configuration }} -j `nproc` -V
run : ctest -C ${{ matrix.configuration }} -j 1 -V
25 changes: 19 additions & 6 deletions .github/workflows/ci-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ 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
include:
- os: ubuntu-latest
compiler: gcc
cc: gcc
cxx: g++
- os: ubuntu-latest
compiler: clang
cc: clang
cxx: clang++

services:
postgres:
Expand All @@ -34,13 +44,16 @@ jobs:
uses: actions/checkout@v2

- name: Configure cmake
run: cmake -B${{github.workspace}}/build -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:
working-directory: ${{ github.workspace }}/build
env :
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest -C ${{ matrix.configuration }} -j `nproc` -V
run : ctest -C ${{ matrix.configuration }} -j 1 -V
10 changes: 5 additions & 5 deletions .github/workflows/ci-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
working-directory: ${{ github.workspace }}/build
env :
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest -C ${{ matrix.configuration }} -j `nproc` -V
run : ctest -C ${{ matrix.configuration }} -j 1 -V
4 changes: 2 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
working-directory: ${{ github.workspace }}/build
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
19 changes: 11 additions & 8 deletions ormpp/postgresql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class postgresql {
bool ping() { return (PQstatus(con_) == CONNECTION_OK); }

template <typename T, typename... Args>
constexpr auto create_datatable(Args &&...args) {
bool create_datatable(Args &&...args) {
std::string sql = generate_createtb_sql<T>(std::forward<Args>(args)...);
#ifdef ORMPP_ENABLE_LOG
std::cout << sql << std::endl;
Expand Down Expand Up @@ -200,8 +200,8 @@ class postgresql {
}

template <typename T, typename... Args>
constexpr std::enable_if_t<!iguana::is_reflection_v<T>, std::vector<T>>
query_s(const std::string &sql, Args &&...args) {
std::enable_if_t<!iguana::is_reflection_v<T>, std::vector<T>> query_s(
const std::string &sql, Args &&...args) {
static_assert(iguana::is_tuple<T>::value);
#ifdef ORMPP_ENABLE_LOG
std::cout << sql << std::endl;
Expand Down Expand Up @@ -289,7 +289,7 @@ class postgresql {
}

template <typename T, typename Arg, typename... Args>
constexpr std::enable_if_t<!iguana::is_reflection_v<T>, std::vector<T>> query(
std::enable_if_t<!iguana::is_reflection_v<T>, std::vector<T>> query(
const Arg &s, Args &&...args) {
static_assert(iguana::is_tuple<T>::value);
constexpr auto SIZE = std::tuple_size_v<T>;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -649,8 +649,8 @@ class postgresql {
}

template <typename T>
constexpr void set_param_values(std::vector<std::vector<char>> &param_values,
T &&value) {
void set_param_values(std::vector<std::vector<char>> &param_values,
T &&value) {
using U = std::remove_const_t<std::remove_reference_t<T>>;
if constexpr (is_optional_v<U>::value) {
if (value.has_value()) {
Expand All @@ -667,7 +667,10 @@ class postgresql {
}
else if constexpr (std::is_integral_v<U> && !iguana::is_int64_v<U>) {
std::vector<char> temp(20, 0);
if constexpr (iguana::is_char_type<U>::value) {
if constexpr (std::is_same_v<char, U>) {
temp.front() = value;
}
else if constexpr (iguana::is_char_type<U>::value) {
itoa_fwd(value, temp.data());
}
else {
Expand Down

0 comments on commit b40b27f

Please sign in to comment.