Hey,

2010/11/1 Sohail Somani <[email protected]>:
> I've come across a problem however. My code does something like this:
>
> myapp::createTables(); // hand-written sql via execute
> session->mapClass<T>("T"); // Wt's map type to table T, created above
>
> The problem seems to be that I cannot map classes after executing the
> SQL as I get the message:
>
>   Cannot map tables after schema was initialized.

So that is definitely as intended -- you need to do all your mapping beforehand.

> Fine, so I change the code to:
>
> session->mapClass<T>("T"); // Wt's map type to table T, created later
> myapp::createTables(); // hand-written sql via execute
>
> Now the problem seems to be that Wt is actually doing a createTables()
> in the mapClass call as I now get the message:
>
>   table T already exists

This is the code for mapClass():

template <class C>
void Session::mapClass(const char *tableName)
{
  if (schemaInitialized_)
    throw std::logic_error("Cannot map tables after schema was initialized.");

  Mapping<C> *mapping = new Mapping<C>();
  mapping->tableName = tableName;

  classRegistry_[&typeid(C)] = mapping;
  tableRegistry_[tableName] = mapping;
}

As you can see, it merely registers the mapping in a two std::map's --
no SQL at all. There must be another reason that your table T already
exists.

> So I'm stuck. What is the correct method of writing your own sql to
> create tables?

What you are trying to do should work, ASFAIK. The "table T already
exists" is an SQL error, right ? Can you enable SQL printing using
"connection->setProperty("show-queries", "true");" to diagnose the
problem ?

Regards,
koen

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to