So I have no idea what changed. But this morning, I hit compile and it just 
worked.

I have no idea why anything is different.

Now, i manualyl created the table is there a way  to tell the DBO layer to add 
IF NOT EXISTS to the create table statements?



________________________________
 From: Jason H <[email protected]>
To: Koen Deforche <[email protected]>; "[email protected]" 
<[email protected]> 
Sent: Wednesday, March 26, 2014 8:56 AM
Subject: Re: [Wt-interest] Why : fatal error: Table postalCodes is missing a    
natural id defined with Wt::Dbo::id()"
 


The one in the subject. :-)

"fatal error: Table postalCodes is missing a natural id defined with 
Wt::Dbo::id()"



The only other code I have is:
dbo::backend::Sqlite3sqlite3("test1.db");
session.setConnection(sqlite3);
sqlite3.setProperty("show-queries","true");
session.mapClass<PostalCode>("postalCodes");
session.createTables();
And that is in my application class.

Also please note there is a small error in the docs:
http://www.webtoolkit.eu/wt/doc/tutorial/dbo.html#_specifying_a_natural_primary_key

"For example, the code below changes the primary key for the User table to a 
string (his username) which maps onto a varchar (20)field user_name:" <-- 
should be user_id


________________________________
 From: Koen Deforche <[email protected]>
To: Jason H <[email protected]>; "[email protected]" 
<[email protected]> 
Cc: Nagaev Boris <[email protected]> 
Sent: Wednesday, March 26, 2014 3:45 AM
Subject: Re: [Wt-interest] Why : fatal error: Table postalCodes is missing a 
natural id defined with Wt::Dbo::id()"
 


Hey Jason,

That at least looks like it should work. What is the error you get?

Regards,
koen



2014-03-25 19:19 GMT+01:00 Jason H <[email protected]>:

Thanks. I've tried everything, including hat. My current is not working but 
here it is:
>
>
>classPostalCode
>{
>public:
>std::stringcode;
>std::stringstate;
>std::stringcity;
>
>
>template<classAction>
>voidpersist(Action&a)
>{
>dbo::id(a,code,"code");
>dbo::field(a,state,"state");
>dbo::field(a,city,"city");
>}
>};
>
>
>namespaceWt{
>namespaceDbo{
>
>
>template<>
>structdbo_traits<PostalCode>:publicdbo_default_traits{
>typedefstd::stringIdType;
>staticconstchar*surrogateIdField(){
>return0;
>}
>staticconstchar*versionField(){
>return0;
>}
>
>
>staticIdTypeinvalidId(){
>returnIdType();
>}
>};
>
>
>}
>}
>
>
>
>________________________________
> From: Nagaev Boris <[email protected]>
>To: Jason H <[email protected]>; witty-interest 
><[email protected]> 
>Sent: Tuesday, March 25, 2014 2:10 PM
>Subject: Re: [Wt-interest] Why : fatal error: Table postalCodes is missing a 
>natural id defined with Wt::Dbo::id()"
> 
>
>Hello,
>
>try to remove
>    dbo::field(a, code,  "code");
>
>You should not call dbo::field with field, used as ID.
>
>
>Regards,
>Boris Nagaev
>
>
>
>On Tue, Mar 25, 2014 at 9:36 PM, Jason H <[email protected]> wrote:
>>
>> This is my first experience using the Dbo module.
>>
>>
>> I don't know why it is giving me an error. The schema is (code text primary 
>> key, state text, city text) (SQLite3)
>>
>>
>>
>> class PostalCode
>>
>> {
>>
>> public:
>>
>> std::string code;
>>
>> std::string state;
>>
>> std::string city;
>>
>>
>> template<class Action>
>>
>> void persist(Action& a)
>>
>> {
>>
>> dbo::id   (a, code,  "code");
>>
>> dbo::field(a, code,  "code");
>>
>> dbo::field(a, state, "state");
>>
>> dbo::field(a, city,  "city");
>>
>> }
>>
>> };
>>
>>
>> namespace Wt {
>>
>> namespace Dbo {
>>
>>
>> template<>
>>
>> struct dbo_traits<PostalCode> : public dbo_default_traits {
>>
>> static const char *surrogateIdField() {
>>
>> return "code";
>>
>> }
>>
>> static const char *versionField() {
>>
>> return 0;
>>
>> }
>>
>> typedef std::string IdType;
>>
>>
>> static IdType invalidId() {
>>
>>  return std::string();
>>
>> }
>>
>> };
>>
>>
>> }
>>
>> }
>>
>>
>> ------------------------------------------------------------------------------
>> Learn Graph Databases - Download FREE O'Reilly Book
>> "Graph Databases" is the definitive new guide to graph databases and their
>> applications. Written by three acclaimed leaders in the field,
>> this first edition is now available. Download your free book today!
>> http://p.sf.net/sfu/13534_NeoTech
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>>
>
>
>
>
>
>------------------------------------------------------------------------------
>Learn Graph Databases - Download FREE O'Reilly Book
>"Graph Databases" is the definitive new guide to graph databases and their
>applications. Written by three acclaimed leaders in the field,
>this first edition is now available. Download your free book today!
>http://p.sf.net/sfu/13534_NeoTech
>_______________________________________________
>witty-interest mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>




------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech

_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to