Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dev/aggregate_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ namespace sqlite_orm {
operator std::string() const {
return "COUNT";
}

};

struct count_asterisk_without_type {
operator std::string() const {
return "COUNT";
}
};

template<class T>
Expand Down Expand Up @@ -104,7 +109,7 @@ namespace sqlite_orm {
return {t};
}

inline aggregate_functions::count_asterisk_t<void> count() {
inline aggregate_functions::count_asterisk_without_type count() {
return {};
}

Expand Down
5 changes: 5 additions & 0 deletions dev/column_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ namespace sqlite_orm {
using type = std::shared_ptr<typename column_result_t<T>::type>;
};

template<>
struct column_result_t<aggregate_functions::count_asterisk_without_type, void> {
using type = int;
};

template<class T>
struct column_result_t<distinct_t<T>, void> {
using type = typename column_result_t<T>::type;
Expand Down
16 changes: 16 additions & 0 deletions dev/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ namespace sqlite_orm {
this->operator++();
}

iterator_t(const iterator_t &) = default;

iterator_t(iterator_t&&) = default;

iterator_t& operator=(iterator_t&&) = default;

iterator_t& operator=(const iterator_t&) = default;

~iterator_t() {
if(this->stmt){
statement_finalizer f{*this->stmt};
Expand Down Expand Up @@ -600,6 +608,10 @@ namespace sqlite_orm {

template<class T>
std::string string_from_expression(const aggregate_functions::count_asterisk_t<T> &f, bool /*noTableName*/ = false, bool /*escape*/ = false) {
return this->string_from_expression(aggregate_functions::count_asterisk_without_type{});
}

std::string string_from_expression(const aggregate_functions::count_asterisk_without_type &f, bool /*noTableName*/ = false, bool /*escape*/ = false) {
std::stringstream ss;
ss << static_cast<std::string>(f) << "(*) ";
return ss.str();
Expand Down Expand Up @@ -1699,6 +1711,10 @@ namespace sqlite_orm {
}
}

std::set<std::pair<std::string, std::string>> parse_table_name(const aggregate_functions::count_asterisk_without_type &c) {
return {};
}

template<class T>
std::set<std::pair<std::string, std::string>> parse_table_name(const asterisk_t<T> &ast) {
auto tableName = this->impl.template find_table_name<T>();
Expand Down
30 changes: 28 additions & 2 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3010,7 +3010,12 @@ namespace sqlite_orm {
operator std::string() const {
return "COUNT";
}

};

struct count_asterisk_without_type {
operator std::string() const {
return "COUNT";
}
};

template<class T>
Expand Down Expand Up @@ -3080,7 +3085,7 @@ namespace sqlite_orm {
return {t};
}

inline aggregate_functions::count_asterisk_t<void> count() {
inline aggregate_functions::count_asterisk_without_type count() {
return {};
}

Expand Down Expand Up @@ -4431,6 +4436,11 @@ namespace sqlite_orm {
using type = std::shared_ptr<typename column_result_t<T>::type>;
};

template<>
struct column_result_t<aggregate_functions::count_asterisk_without_type, void> {
using type = int;
};

template<class T>
struct column_result_t<distinct_t<T>, void> {
using type = typename column_result_t<T>::type;
Expand Down Expand Up @@ -6034,6 +6044,14 @@ namespace sqlite_orm {
this->operator++();
}

iterator_t(const iterator_t &) = default;

iterator_t(iterator_t&&) = default;

iterator_t& operator=(iterator_t&&) = default;

iterator_t& operator=(const iterator_t&) = default;

~iterator_t() {
if(this->stmt){
statement_finalizer f{*this->stmt};
Expand Down Expand Up @@ -6525,6 +6543,10 @@ namespace sqlite_orm {

template<class T>
std::string string_from_expression(const aggregate_functions::count_asterisk_t<T> &f, bool /*noTableName*/ = false, bool /*escape*/ = false) {
return this->string_from_expression(aggregate_functions::count_asterisk_without_type{});
}

std::string string_from_expression(const aggregate_functions::count_asterisk_without_type &f, bool /*noTableName*/ = false, bool /*escape*/ = false) {
std::stringstream ss;
ss << static_cast<std::string>(f) << "(*) ";
return ss.str();
Expand Down Expand Up @@ -7624,6 +7646,10 @@ namespace sqlite_orm {
}
}

std::set<std::pair<std::string, std::string>> parse_table_name(const aggregate_functions::count_asterisk_without_type &c) {
return {};
}

template<class T>
std::set<std::pair<std::string, std::string>> parse_table_name(const asterisk_t<T> &ast) {
auto tableName = this->impl.template find_table_name<T>();
Expand Down