[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    kexi patch
From:       Adam Pigg <adam () piggz ! fsnet ! co ! uk>
Date:       2003-09-01 21:41:12
[Download RAW message or body]

Hi

The attached patch lets kexi queries work with my postgresql driver.  It calls 
db->escapeName() for every table/field to that the case is preserved.  I 
think it should work with mysql but i cant test it.  Ive also added brackets 
() round where clauses to make the sql look nicer.

Cya

PiggZ
-- 
adampigg.9p.org.uk
adam@piggz.fsnet.co.uk
adam@adampigg.9p.org.uk

["kexiquerydesignerguieditor.cpp.diff" (text/x-diff)]

? kexiaddparamwidget.cpp
? kexiaddparamwidget.h
? kexiparameterlisteditor.cpp
? kexiparameterlisteditor.h
Index: kexiquerydesignerguieditor.cpp
===================================================================
RCS file: /home/kde/koffice/kexi/plugins/queries/kexiquerydesignerguieditor.cpp,v
retrieving revision 1.38
diff -u -r1.38 kexiquerydesignerguieditor.cpp
--- kexiquerydesignerguieditor.cpp	6 Aug 2003 07:37:39 -0000	1.38
+++ kexiquerydesignerguieditor.cpp	1 Sep 2003 21:37:08 -0000
@@ -258,7 +258,7 @@
 			QString field = cItem->getValue(1).toString();
 			QString table = (*m_sourceList.at(tableID));
 
-			query += table + "." + field;
+			query += m_db->escapeName(table) + "." + m_db->escapeName(field);
 
 
 			int iCount;
@@ -279,7 +279,7 @@
 			involvedFields.insert(table, field);
 
 			Condition condition;
-			condition.field = table + "." + field;
+			condition.field = m_db->escapeName(table) + "." + m_db->escapeName(field);
 			condition.andCondition = cItem->getValue(3).toString();
 			condition.orCondition = cItem->getValue(4).toString();
 
@@ -327,9 +327,9 @@
 						isSrcTable = false;
 
 						JoinField jf;
-						jf.sourceField = (*itRel).rcvTable;
-						jf.eqLeft = (*itRel).srcTable + "." + (*itRel).srcField;
-						jf.eqRight = (*itRel).rcvTable + "." + (*itRel).rcvField;
+						jf.sourceField = m_db->escapeName((*itRel).rcvTable);
+						jf.eqLeft = m_db->escapeName((*itRel).srcTable) + "." + m_db->escapeName((*itRel).srcField);
+						jf.eqRight = m_db->escapeName((*itRel).rcvTable) + "." + m_db->escapeName((*itRel).rcvField);
 						joinFields.append(jf);
 					}
 
@@ -354,7 +354,7 @@
 	}
 
 	query += " FROM ";
-	query += maxTable;
+	query += m_db->escapeName(maxTable);
 
 	QStringList joined;
 	for(JoinFields::Iterator itJ = joinFields.begin(); itJ != joinFields.end(); itJ++)
@@ -378,6 +378,7 @@
 	}
 
 	int conditionCount = 0;
+	bool openedWhere = false;
 	for(ConditionList::Iterator itC = conditions.begin(); itC != conditions.end(); itC++)
 	{
 		if(!(*itC).andCondition.isEmpty())
@@ -385,19 +386,24 @@
 			if(conditionCount != 0)
 				query += " AND ";
 			else
-				query += " WHERE ";
+			{
+				query += " WHERE(";
+				openedWhere = true;
+			}
 
 			QString ccondition = (*itC).andCondition;
 
-			query += (*itC).field + " " + ccondition;
+			query += "(" + (*itC).field + " " + ccondition + ")";
 			conditionCount++;
 		}
 		if(!(*itC).orCondition.isEmpty())
 		{
-			query += " OR " + (*itC).field + " " + (*itC).orCondition;
+			query += " OR (" + (*itC).field + " " + (*itC).orCondition + ")";
 			conditionCount++;
 		}
 	}
+	if (openedWhere)
+		query += ")";
 
 	//ok, we are trying to get the conditions
 


_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic