--- src/include/pgObject.h.orig Sat Sep 20 02:11:20 2003 +++ src/include/pgObject.h Sat Sep 20 02:17:58 2003 @@ -247,10 +247,12 @@ wxString GetFormattedDefinition(); wxString GetDefinition() const { return definition; } + wxString GetCondition() const { return condition; } void iSetDefinition(const wxString& s) { definition=s; } + void iSetCondition(const wxString& s) { condition=s; } protected: - wxString definition; + wxString definition, condition; }; #endif --- src/include/pgRule.h.orig Sat Sep 20 02:29:39 2003 +++ src/include/pgRule.h Sat Sep 20 02:30:04 2003 @@ -34,8 +34,6 @@ wxString GetEvent() const { return event; } void iSetEvent(const wxString& s) { event=s; } - wxString GetCondition() const { return condition; } - void iSetCondition(const wxString& s) { condition=s; } wxString GetAction() const { return action; } void iSetAction(const wxString& s) { action=s; } bool GetDoInstead() const { return doInstead; } @@ -50,7 +48,7 @@ pgObject *Refresh(wxTreeCtrl *browser, const wxTreeItemId item); private: - wxString event, condition, action, quotedFullTable; + wxString event, action, quotedFullTable; bool doInstead; }; --- src/schema/pgRule.cpp.orig Sat Sep 20 02:50:55 2003 +++ src/schema/pgRule.cpp Sat Sep 20 03:19:40 2003 @@ -56,7 +56,20 @@ { CreateListColumns(properties); int pos=0; - wxString def=GetDefinition().Left(250); + wxString def=GetFormattedDefinition(); + + if (!def.IsEmpty()) + { + int doPos=def.Find(wxT(" DO INSTEAD ")); + if (doPos > 0) + def = def.Mid(doPos + 12).Strip(wxString::both); + else + { + doPos = def.Find(wxT(" DO ")); + if (doPos > 0) + def = def.Mid(doPos+4).Strip(wxString::both); + } + } InsertListItem(properties, pos++, _("Name"), GetName()); InsertListItem(properties, pos++, _("OID"), GetOid()); --- src/schema/pgObject.cpp.orig Sat Sep 20 02:01:17 2003 +++ src/schema/pgObject.cpp Sat Sep 20 03:18:23 2003 @@ -589,9 +589,11 @@ wxString pgRuleObject::GetFormattedDefinition() { + // It hasn't been used to extract it from definition. + // // pgsql 7.4 does formatting itself - if (!GetDatabase()->GetPrettyOption().IsEmpty()) - return GetDefinition(); + // if (!GetDatabase()->GetPrettyOption().IsEmpty()) + // return GetDefinition(); //////////////////////////////// // ok, this code looks weird. It's necessary, because somebody (NOT the running code) @@ -604,16 +606,27 @@ sqlTokens[0].special = SQLTK_NORMAL; sqlTokens[0].doBreak = true; - wxString fc, token; + wxString fc, token, cond_str; queryTokenizer tokenizer(GetDefinition()); int indent=0; int position=0; // col position. updated, but not used at the moment. bool wasOn=false; + int conditionN=0; // used at the condition. while (tokenizer.HasMoreTokens()) { token=tokenizer.GetNextToken(); + if (!token.compare(wxT("WHERE"))) + conditionN++; + else + { + if (!token.compare(wxT("DO"))) + conditionN = 9; + if (conditionN == 1) + cond_str += token + wxT(" "); + } + gotToken: wxString trailingChars; @@ -702,6 +715,9 @@ position += trailingChars.Length() + 1; } } + + iSetCondition(cond_str); + return fc; }