Всем привет. Есть таблицы в базе со следующей структурой
CREATE TABLE anketa
(
id bigserial NOT NULL,
productid integer,
serialnumber text,
firstname text,
lastname text,
email text,
phone text,
dilerid integer,
credate timestamp without time zone,
"version" text,
"comment" text,
validdate date,
ordern text,
activateevery integer DEFAULT 0,
company text,
CONSTRAINT fkdid FOREIGN KEY (dilerid)
REFERENCES diler (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fkproductid FOREIGN KEY (productid)
REFERENCES product (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
CREATE TABLE product
(
"name" text NOT NULL,
"comment" text,
id serial NOT NULL,
CONSTRAINT id PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
CREATE TABLE diler
(
id bigserial NOT NULL,
"name" text,
"comment" text,
CONSTRAINT dilerid PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
есть код который отображает эти данные в отдельном диалоге
editAnketaModel->setTable("anketa");
//берем только нашу анкету
editAnketaModel->setFilter("anketa.id ="+QString::number(anketaid));
editAnketaModel->setRelation(editAnketaModel->fieldIndex("productid"),QSqlRelation("product","id","name"));
editAnketaModel->setRelation(editAnketaModel->fieldIndex("dilerid"),QSqlRelation("diler","id","name"));
// editAnketaModel->setHeaderData(7,Qt::Horizontal,"diler");
editAnketaModel->select();
ui->tableView->setModel(editAnketaModel);
//создаем модель продукта
QSqlTableModel *productRelationModel=editAnketaModel->relationModel(1);
ui->EditProductProduct->setModel(productRelationModel);
ui->EditProductProduct->setModelColumn(productRelationModel->fieldIndex("name"));
//создаем модель партнера
QSqlTableModel *dilerRelationModel=editAnketaModel->relationModel(7);
ui->EditProductDiler->setModel(dilerRelationModel);
ui->EditProductDiler->setModelColumn(dilerRelationModel->fieldIndex("name"));
mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
mapper->setModel(editAnketaModel);
mapper->setItemDelegate( new QSqlRelationalDelegate(this));
mapper->addMapping(ui->EditProductProduct,1);
mapper->addMapping(ui->EditProductDiler,7);
mapper->addMapping(ui->EditProductSerial,2);
mapper->addMapping(ui->EditProductFirstname,3);
mapper->addMapping(ui->EditProductLastName,4);
mapper->addMapping(ui->EditProductEmail,5);
mapper->addMapping(ui->EditProductPhone,6);
mapper->addMapping(ui->EditProductVersion,9);
mapper->addMapping(ui->EditProductComment,10);
mapper->addMapping(ui->EditProductValidDate,11);
mapper->addMapping(ui->EditProductOrder,12);
mapper->addMapping(ui->EditProductActEvery,13);
mapper->addMapping(ui->EditProductCompany,14);
mapper->setCurrentIndex(0);
Данные отображаются верно , однако после редактирования при попытке вставить их обратно возникает ошибка.
"ERROR: column "product_name_2" does not exist
LINE 1: ...=$1, "email"=$2, "dilerid"=$3 WHERE "id" = $4 AND "product_n...
^
QPSQL: Unable to prepare statement"
Лог Postgresql
2010-10-13 20:24:50 MSD STATEMENT: PREPARE qpsqlpstmt_1 AS UPDATE anketa SET "productid"=$1, "email"=$2, "dilerid"=$3 WHERE "id" = $4 AND "product_name_2" = $5 AND "serialnumber" = $6 AND "firstname" = $7 AND "lastname" = $8 AND "email" = $9 AND "phone" = $10 AND "name" = $11 AND "credate" = $12 AND "version" = $13 AND "comment" = $14 AND "validdate" = $15 AND "ordern" = $16 AND "activateevery" = $17 AND "company" IS NULL
непонятно откуда берется колонка product_name_2