Project

General

Profile

QueryModel: geometry inconsistent with database

Added by John Harris about 13 years ago

Koen, Wim, et.al.,

Again, thanks much for Wt. I'm really making progress learning it.


New question. I created a small database with sqlite3, populated it with 1000 records, and connected it to a WTableView via QueryModel. So far so good. It general, works great. The problem is, when I grab the slider on the right hand side, and drag it up and down vigorously, my app gets an exception raised:

127.0.1.1 - - [2011-Apr-26 12:25:51.227313] "POST /?wtd=HBCoauAKOI1y8FzL HTTP/1.1" 200 42
127.0.1.1 - - [2011-Apr-26 12:30:51.227491] "POST /?wtd=HBCoauAKOI1y8FzL HTTP/1.1" 200 42
127.0.1.1 - - [2011-Apr-26 12:32:34.732110] "POST /?wtd=HBCoauAKOI1y8FzL HTTP/1.1" 200 20
[2011-Apr-26 12:32:34.732259] 23280 [/ HBCoauAKOI1y8FzL] [fatal] "QueryModel: geometry inconsistent with database"
MyApplication dead
[2011-Apr-26 12:32:34.732643] 23280 [/ HBCoauAKOI1y8FzL] [notice] "Session destroyed (#sessions = 2)"
[2011-Apr-26 12:32:34.732682] 23280 [/ mNLlu3O8tyJidR4o] [notice] "Timeout: expiring"
MyApplication dead
[2011-Apr-26 12:32:34.733141] 23280 [/ mNLlu3O8tyJidR4o] [notice] "Session destroyed (#sessions = 1)"
[2011-Apr-26 12:32:34.734848] 23280 [/ cKTyQJqoOZFaYoaH] [notice] "Session created (#sessions = 2)"
Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Ubuntu/10.04 Chromium/10.0.648.205 Chrome/10.0.648.205 Safari/534.16
[2011-Apr-26 12:32:34.735036] 23280 [/ cKTyQJqoOZFaYoaH] [notice] "Signal from dead session, sending reload."
[2011-Apr-26 12:32:34.735185] 23280 [/ cKTyQJqoOZFaYoaH] [notice] "Session destroyed (#sessions = 1)"
127.0.1.1 - - [2011-Apr-26 12:32:34.735360] "POST /?wtd=HBCoauAKOI1y8FzL HTTP/1.1" 200 49
[2011-Apr-26 12:32:34.737627] 23280 [/ L1hfmrqsHvx90oFF] [notice] "Session created (#sessions = 2)" 
Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Ubuntu/10.04 Chromium/10.0.648.205 Chrome/10.0.648.205 Safari/534.16 
127.0.1.1 - - [2011-Apr-26 12:32:34.738305] "GET / HTTP/1.1" 200 1672
127.0.1.1 - - [2011-Apr-26 12:32:34.855764] "GET /?wtd=L1hfmrqsHvx90oFF&request=style HTTP/1.1" 200 67

Code of app:

#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WEnvironment>
#include <Wt/WTableView>

using namespace Wt;

#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/backend/Sqlite3>
#include <Wt/Dbo/QueryModel>

namespace dbo = Wt::Dbo;

#include <string>
using namespace std;

// DataBase definition.

class User {
public:
  enum Role {
    Visitor = 0,
    Admin = 1,
    Alien = 42
  };

  std::string name;
  std::string password;
  Role        role;
  int         karma;

  template<class Action>
  void persist(Action& a)
  {
    dbo::field(a, name,     "name");
    dbo::field(a, password, "password");
    dbo::field(a, role,     "role");
    dbo::field(a, karma,    "karma");
  }
};

void create_database (void)
{
  dbo::Session session;
  dbo::backend::Sqlite3 sqlite3 ("MyDB.sql3");
  session.setConnection (sqlite3);
  session.mapClass<User> ("user");

  session.createTables();

  { 
    dbo::Transaction transaction(session);
    for (int i = 0; i < 1000; i += 1)
      {
    User *user = new User();
    user->name = "Joe" + boost::lexical_cast<std::string>(i);
    user->password = "Secret";
    user->role = User::Visitor;
    user->karma = 42;

    dbo::ptr<User> userPtr = session.add (user);
      }
    transaction.commit();
  }
}

class mainWindow : public WContainerWidget
{
public:
  mainWindow (dbo::Session & session, WContainerWidget *parent=0)
    : WContainerWidget (parent)
  {
    dbo::QueryModel< dbo::ptr<User> > *model = new dbo::QueryModel< dbo::ptr<User> >();
    model->setQuery(session.find<User>());
    model->addAllFieldsAsColumns();

    WTableView *view = new WTableView (this);
    view->resize(800, 300);
    view->setSelectionMode(SingleSelection);
    view->setModel(model);
  }
};

class MyApplication : public WApplication
{
private:
  dbo::Session session;
  dbo::backend::Sqlite3 sqlite3;
public:
  MyApplication (WEnvironment const & env) 
    : WApplication (env), sqlite3 ("MyDB.sql3")
  {
    session.setConnection (sqlite3);
    session.mapClass<User>("user");

    root () -> addWidget (new mainWindow (session, root ()));
  }
  ~MyApplication (void) { std::cout << "MyApplication dead" << std::endl; }
};


WApplication * createApplication (WEnvironment const & env)
{ return new MyApplication (env); }

int main(int argc, char **argv)
{
  create_database ();
  return WRun (argc, argv, & createApplication);
}

cmake file:

ADD_EXECUTABLE(dbo.wt dbo.C)
TARGET_LINK_LIBRARIES(dbo.wt wthttp wt wtdbo wtdbosqlite3)
#set(CMAKE_CXX_FLAGS "-Wall -ggdb -DNDEBUG")        # Maximize debugging
set(CMAKE_CXX_FLAGS "-Wall -ggdb")              # Maximize debugging

Versions:

witty: 3.1.8-1~lucid~pgquiles1

boost: 1.40.0-4ubuntu4

sqlite3: 3.6.22-1

OS: Ubuntu 10.04 & 10.10

Arch: intel x86 & x86_64

And again, thanks much,

- john


Replies (5)

RE: QueryModel: geometry inconsistent with database - Added by Koen Deforche about 13 years ago

Hey John,

I can't reproduce this with git head. I believe this issue may have been fixed in Wt 3.1.9 ?

Regards

koen

RE: QueryModel: geometry inconsistent with database - Added by John Harris about 13 years ago

Koen,

I just tried 3.1.9 --- works great! It "pages" somewhat faster than 3.1.8 as well.

My bad for not trying latest version --- I'll be sure to do that before posting.

U-da'Man!

- john

RE: QueryModel: geometry inconsistent with database - Added by John Harris about 13 years ago

For some stress testing, I cranked up the number of records in the database. First I went from 1,000 to 1,000,000. Changed the number in the for loop. This worked when I used Google's Chrome browser, but I only got the column headers under firefox, no data displayed. (No IE testing done). Then I cranked it up to 10,000,000 and got the same results with both browsers.

Wt 3.1.9

For what I'm doing this is not a problem. I'm just reporting.

- john

RE: QueryModel: geometry inconsistent with database - Added by Koen Deforche about 13 years ago

Hey,

I believe it is because we set the height of a div to a value that is not supported by the browser (too big). I would need to investigate if there is a workaround.

(On the other hand, are you really going to let users scroll through a table of 1M rows ?)

Regards,

koen

RE: QueryModel: geometry inconsistent with database - Added by Koen Deforche about 13 years ago

Hey,

Yes, I checked and indeed there is a maximum height in Firefox, as per : https://wiki.mozilla.org/Mozilla2:Units.

There doesn't seem a trivial workaround though (as it does not depend on the unit).

Regards,

koen

    (1-5/5)