Skip to content

When using iterate (select (columns (object<>())), the type inference error in the compiled return occurs during the selection process #1446

@uuiid

Description

@uuiid

This test case will encounter errors during compilation

Revised plan (dev/result_set_iterator.h:45)

        // using value_type = column_result_proxy_t<ColResult>;
        using value_type = decltype(make_row_extractor<ColResult>(std::declval<db_objects_type>()).extract(nullptr, 0));

void fun() {
  struct Employee {
    int m_empno;
    std::string m_ename;
    std::string m_job;
    std::optional<int> m_mgr;
    std::string m_hiredate;
    double m_salary;
    std::optional<double> 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())
      )
  );

  for (auto&& [obj, col] : storage.iterate(select(
           columns(object<Employee>(true), object<Department>(true), &Department::m_deptno),
           join<Department>(on(c(&Employee::m_depno) == c(&Department::m_deptno))),

       ))) {
  }
}                       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions