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

List:       kde-commits
Subject:    branches/koffice/1.6/koffice/kexi/kexidb
From:       Jaroslaw Staniek <js () iidea ! pl>
Date:       2007-04-05 11:03:38
Message-ID: 1175771018.371472.30333.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 650732 by staniek:

KexiDB
- SQL parser can work recursively now (needed when multiple parsers are used 
  in the same thread, removed possible crash)

2.0: merged



 M  +3 -1      connection.cpp  
 M  +5 -0      connection.h  
 M  +7 -1      parser/parser.cpp  
 M  +2 -2      parser/parser_p.cpp  
 M  +0 -1      parser/parser_p.h  
 M  +1 -1      queryschema.cpp  
 M  +11 -0     utils.cpp  
 M  +7 -0      utils.h  


--- branches/koffice/1.6/koffice/kexi/kexidb/connection.cpp #650731:650732
@@ -56,6 +56,7 @@
 Connection::SelectStatementOptions::SelectStatementOptions()
  : identifierEscaping(Driver::EscapeDriver|Driver::EscapeAsNecessary)
  , alsoRetrieveROWID(false)
+ , addVisibleLookupColumns(true)
 {
 }
 
@@ -1139,7 +1140,8 @@
 					sql += (QString::fromLatin1(" AS ") + aliasString);
 //! @todo add option that allows to omit "AS" keyword
 			}
-			LookupFieldSchema *lookupFieldSchema = f->table() ? f->table()->lookupFieldSchema( *f ) : 0;
+			LookupFieldSchema *lookupFieldSchema = (options.addVisibleLookupColumns && f->table())
+				? f->table()->lookupFieldSchema( *f ) : 0;
 			if (lookupFieldSchema && lookupFieldSchema->boundColumn()>=0) {
 				// Lookup field schema found
 				// Now we also need to fetch "visible" value from the lookup table, not only the value of binding.
--- branches/koffice/1.6/koffice/kexi/kexidb/connection.h #650731:650732
@@ -678,6 +678,11 @@
 
 				//! True if ROWID should be also retrieved. False by default.
 				bool alsoRetrieveROWID : 1;
+
+				/*! True if relations (LEFT OUTER JOIN) for visible lookup columns should be added. 
+				 True by default. This is set to false when user-visible statement is generated 
+				 e.g. for the Query Designer. */
+				bool addVisibleLookupColumns : 1;
 		};
 
 		/*! \return "SELECT ..." statement's string needed for executing query 
--- branches/koffice/1.6/koffice/kexi/kexidb/parser/parser.cpp #650731:650732
@@ -118,7 +118,13 @@
 	init();
 	clear();
 	d->statement = statement;
-	return parseData(this, statement.utf8());
+
+	KexiDB::Parser *oldParser = parser;
+	KexiDB::Field *oldField = field;
+	bool res = parseData(this, statement.utf8());
+	parser = oldParser;
+	field = oldField;
+	return res;
 }
 
 void
--- branches/koffice/1.6/koffice/kexi/kexidb/parser/parser_p.cpp #650731:650732
@@ -29,8 +29,8 @@
 
 using namespace KexiDB;
 
-Parser *parser;
-Field *field;
+Parser *parser = 0;
+Field *field = 0;
 //bool requiresTable;
 QPtrList<Field> fieldList;
 int current = 0;
--- branches/koffice/1.6/koffice/kexi/kexidb/parser/parser_p.h #650731:650732
@@ -81,7 +81,6 @@
 
 extern KexiDB::Parser *parser;
 extern KexiDB::Field *field;
-extern bool requiresTable;
 
 
 #endif
--- branches/koffice/1.6/koffice/kexi/kexidb/queryschema.cpp #650731:650732
@@ -431,7 +431,7 @@
 	}
 	else {
 		if (includeTableName) {
-			tableName = m_column->field->table()->name();
+			tableName = m_field->table()->name();
 			if (drv)
 				tableName = drv->escapeIdentifier(tableName, identifierEscaping);
 			tableName += ".";
--- branches/koffice/1.6/koffice/kexi/kexidb/utils.cpp #650731:650732
@@ -1248,4 +1248,15 @@
 	return KexiDB::maximumForIntegerTypes(t2, t1); //swap
 }
 
+QString KexiDB::simplifiedTypeName(const Field& field)
+{
+	if (field.isNumericType())
+		return futureI18n("Number"); //simplify
+	else if (field.type() == Field::BLOB)
+//! @todo support names of other BLOB subtypes
+		return futureI18n("Image"); //simplify
+
+	return field.typeGroupName();
+}
+
 #include "utils_p.moc"
--- branches/koffice/1.6/koffice/kexi/kexidb/utils.h #650731:650732
@@ -100,6 +100,13 @@
 	 'type' property when user selects type group for a field. */
 	KEXI_DB_EXPORT Field::Type defaultTypeForGroup(Field::TypeGroup typeGroup);
 
+	/*! \return a slightly simplified type name for \a field. 
+	 For BLOB type it returns i18n'd "Image" string or other, depending on the mime type.
+	 For numbers (either floating-point or integer) it returns i18n'd "Number: string.
+	 For other types it the same string as Field::typeGroupName() is returned. */
+//! @todo support names of other BLOB subtypes
+	KEXI_DB_EXPORT QString simplifiedTypeName(const Field& field);
+
 	/*! \return true if \a v represents an empty (but not null) value.
 	 Values of some types (as for strings) can be both empty and not null. */
 	inline bool isEmptyValue(Field *f, const QVariant &v) {
[prev in list] [next in list] [prev in thread] [next in thread] 

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