Overview
Features
Download
Documentation
Community
Add-Ons & Services

TypeHandler - parameter count mismatch

Please post support and help requests here.

TypeHandler - parameter count mismatch

Postby roggan87 » 19 Jul 2013, 21:44

Hi!

First off, thanks for a fantastic library, it fits our needs perfectly!

I have an SQLite database with a table. To that table I have an object with a TypeHandler. The thing is that I would like to return one more column on select than on insert. This is since I want to put the results of the select statement into a map where the rowid is the identifier. However it would make no sense to insert a rowid, since it should be given automatically.

Any ideas on how I could avoid the parameter count mismatch  error?

(sorry for not providing code, I haven't got it here, but please ask if I should clarify something)

Thanks,
Robert
roggan87
 
Posts: 13
Joined: 05 May 2011, 12:42

Re: TypeHandler - parameter count mismatch

Postby roggan87 » 31 Jul 2013, 01:07

Okay, some code example:

Code: Select all
   // Setup
   session <<"CREATE TABLE IF NOT EXISTS rows "
         <<"(col1 TEXT, col2 TEXT)", now;

   // Insert
   Row row = Row("first", "second");
   session <<"INSERT INTO rows VALUES(:col1, :col2)", use(row), now;

   // Select
   vector<Row> rows;
   session <<"SELECT rowid, col1, col2 FROM rows;", into(rows), now;


Note how I don't want to insert any rowid, since it is automatically increased. I do want to extract it on select though, since the rowid will be used as id for the object. It seems really hard to achieve this, to extract more columns than are inserted. When making the TypeHandler template, I have to specify exactly how many fields to be handled, like this:

Code: Select all
template <>
class TypeHandler<Row>
{
public:
   static size_t size()
   {
      return 3;
   }
   ...


That is however hard to say. Is there any way to workaround this issue?
roggan87
 
Posts: 13
Joined: 05 May 2011, 12:42


Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests

cron