From 917d7e811a3c02dc5dad108e2b8ad72c4dd6476c Mon Sep 17 00:00:00 2001 From: uuiid <957714080@qq.com> Date: Fri, 22 Aug 2025 09:38:17 +0800 Subject: [PATCH 1/2] fix: https://github.com/fnc12/sqlite_orm/issues/1446 --- dev/result_set_iterator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/result_set_iterator.h b/dev/result_set_iterator.h index 567e841c9..125a07fe6 100644 --- a/dev/result_set_iterator.h +++ b/dev/result_set_iterator.h @@ -42,7 +42,8 @@ namespace sqlite_orm::internal { using iterator_category = std::input_iterator_tag; #endif using difference_type = ptrdiff_t; - using value_type = column_result_proxy_t; + // using value_type = column_result_proxy_t; + using value_type = decltype(make_row_extractor(std::declval()).extract(nullptr, 0)); public: result_set_iterator(const db_objects_type& dbObjects, statement_finalizer stmt) : From da2368c12dc123e2c3bfc8e7b40883811ded08ff Mon Sep 17 00:00:00 2001 From: uuiid <957714080@qq.com> Date: Fri, 22 Aug 2025 10:00:41 +0800 Subject: [PATCH 2/2] fix: https://github.com/fnc12/sqlite_orm/issues/1446 --- include/sqlite_orm/sqlite_orm.h | 3 +- tests/unique_cases/issue1446.cpp | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/unique_cases/issue1446.cpp diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index b14df85aa..c60492b5d 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -16447,7 +16447,8 @@ namespace sqlite_orm::internal { using iterator_category = std::input_iterator_tag; #endif using difference_type = ptrdiff_t; - using value_type = column_result_proxy_t; + // using value_type = column_result_proxy_t; + using value_type = decltype(make_row_extractor(std::declval()).extract(nullptr, 0)); public: result_set_iterator(const db_objects_type& dbObjects, statement_finalizer stmt) : diff --git a/tests/unique_cases/issue1446.cpp b/tests/unique_cases/issue1446.cpp new file mode 100644 index 000000000..d39ae9d03 --- /dev/null +++ b/tests/unique_cases/issue1446.cpp @@ -0,0 +1,60 @@ +#include +#include + +#if SQLITE_VERSION_NUMBER >= 3006019 +using namespace sqlite_orm; + +#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED +#ifdef SQLITE_ORM_DEFAULT_COMPARISONS_SUPPORTED + +TEST_CASE("issue1446") { + struct Employee { + int m_empno; + std::string m_ename; + std::string m_job; + std::optional m_mgr; + std::string m_hiredate; + double m_salary; + std::optional m_commission; + int m_depno; + }; + + struct Department { + int m_deptno; + std::string m_deptname; + std::string m_loc; + }; + + using namespace sqlite_orm; + + auto storage = make_storage("", + make_table("Emp", + make_column("empno", &Employee::m_empno, primary_key().autoincrement()), + make_column("ename", &Employee::m_ename), + make_column("job", &Employee::m_job), + make_column("mgr", &Employee::m_mgr), + make_column("hiredate", &Employee::m_hiredate), + make_column("salary", &Employee::m_salary), + make_column("comm", &Employee::m_commission), + make_column("depno", &Employee::m_depno), + foreign_key(&Employee::m_depno).references(&Department::m_deptno)), + make_table("Dept", + make_column("deptno", &Department::m_deptno, primary_key().autoincrement()), + make_column("deptname", &Department::m_deptname), + make_column("loc", &Department::m_loc, null()))); + storage.sync_schema(true); + storage.insert(Department{10, "Accounts", "New York"}); + storage.insert(Employee{1, "Paul", "Salesman", 2, "2002-02-12", 20000.0, 0.0, 1}); + storage.insert(Employee{2, "Allen", "Salesman", 2, "2002-02-12", 20000.0, 0.0, 1}); + for (auto&& [obj, obj2, col]: + storage.iterate(select(columns(object(true), object(true), &Department::m_deptno), + from(), + join(on(c(&Employee::m_depno) == c(&Department::m_deptno)))))) { + STATIC_REQUIRE(std::is_same_v); + STATIC_REQUIRE(std::is_same_v); + STATIC_REQUIRE(std::is_same_v); + } +} +#endif +#endif +#endif \ No newline at end of file