Hello! You can add a default constructor to class db_mail_acc, providing default values for fields.
Or you can use boost::optional<WDateTime> as field type to explicitly tell Dbo to set this field to Null, if not provided. http://www.webtoolkit.eu/wt/doc/reference/html/structWt_1_1Dbo_1_1sql__value__traits.html PS. I have not test it with postgres, but default-constructed WDateTime seems to be ok for Sqlite3. On Wed, Feb 29, 2012 at 04:06, Denis Talakevich <denis.talakev...@onat.edu.ua> wrote: > I can't find how to form insert where can assign default values for some > fields > > class db_mail_acc { > public: > int domain_id,quota; > bool active; > std::string username,password; > std::string description; > std::string create_date; > template<class Action> > void persist(Action& a) > { > dbo::field(a,username,"username"); > dbo::field(a,password,"password"); > dbo::field(a,domain_id,"domain_id"); > dbo::field(a,quota,"quota"); > dbo::field(a,create_date,"create_date"); > dbo::field(a,active,"active"); > dbo::field(a,description,"description"); > } > }; > > db_mail_acc *new_acc = new db_mail_acc() ; > new_acc->username=e_uname->text().toUTF8(); > new_acc->password=e_pass->text().toUTF8(); > new_acc->domain_id=dom_n; > new_acc->quota=quota_n; > new_acc->active=act_n; > new_acc->description=e_desc->text().toUTF8(); > dbo::ptr<db_mail_acc> new_acc_Ptr = session.add(new_acc) ; > > will return : insert into "email"."se_email_accounts" ("username", > "password", "domain_id", "quota", "active", "create_date", "description") > values ($1, $2, $3, $4, $5, $6, $7) returning "id" > LOG: duration: 0.648 ms parse SQL0x2b8b020035702E2F: insert into > "email"."se_email_accounts" ("username", "password", "domain_id", "quota", > "active", "create_date", "description") values ($1, $2, $3, $4, $5, $6, $7) > returning "id" > DEBUG: bind <unnamed> to SQL0x2b8b020035702E2F > LOG: statement: rollback transaction > LOG: duration: 0.122 ms > [2012-Feb-29 00:01:01.766384] 3651 [/ vKu4us12WJvjR93Z] [error] "Wt: Error > during event handling: ERROR: invalid input syntax for type timestamp with > time zone: """" > " > [2012-Feb-29 00:01:01.773664] 3651 [/ vKu4us12WJvjR93Z] [error] "Wt: Fatal > error: ERROR: invalid input syntax for type timestamp with time zone: """" > > because new_acc->create_date is empty. Using WDateTime doesn't solve > problem. > > i can add default value by ignoring field only by cloning class class > db_mail_acc with deleting dbo::field(a,create_date,"create_date"); > > but this is not an option > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > witty-interest mailing list > witty-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/witty-interest > ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ witty-interest mailing list witty-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/witty-interest