[odb-users] ODB exception on insert (ODB 2.4.0)

Craig Burton rccraigb at gmail.com
Sun Jun 7 17:09:05 EDT 2020


Hi,

I am encountering the following exception upon attempting to insert a
derived class that inherits from two classes, one defined as polymorphic,
the other as abstract:

   1136 (21S01): Column count doesn't match value count at row 1

The insert statement is reproducible and is generated as follows:

  const char access::object_traits_impl< ::PersistentDerived, id_mysql
>::persist_statement[] =
  "INSERT INTO `PersistentDerived` "
  "(`id`, "
  "`mDerived`) "
  "VALUES "
  "(?, ?, ?)";

Perhaps I am defining the persistence mapping incorrectly, or this issue
has been addressed in 2.5, but I thought I would check.

The class definitions that reproduce this behavior are as follows:

(file abstract.hxx)
===================
#include <iostream>
#include <odb/core.hxx>


#pragma db object polymorphic
class PersistentBase
{
public:
   PersistentBase() {}
   virtual ~PersistentBase() {}
protected:
   friend class odb::access;

   #pragma db id auto
   unsigned long id_;

   std::string mBase;
};

#pragma db object abstract
class AbstractBase
{
public:
   AbstractBase() {}
   virtual ~AbstractBase() {}
protected:
   friend class odb::access;

   std::string mAbstractBase;
};

#pragma db object
class PersistentDerived
 : public PersistentBase, AbstractBase
{
public:
   PersistentDerived() {}
   ~PersistentDerived() {}
protected:
   friend class odb::access;

   std::string mDerived;
};

This command was used to compile:

odb --database mysql --generate-schema --generate-query --generate-session
abstract.hxx

Thank you in advance for taking a look.
Craig


More information about the odb-users mailing list