[Libreoffice-commits] .: 3 commits - dbaccess/source wizards/com
Lionel Elie Mamane
lmamane at kemper.freedesktop.org
Thu Jul 12 14:38:23 PDT 2012
dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 1
wizards/com/sun/star/wizards/db/SQLQueryComposer.java | 43 +++++++++++------
2 files changed, 30 insertions(+), 14 deletions(-)
New commits:
commit 3d3b3f656f92790225b89aa31ee61163fb2fc7e5
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jul 12 23:28:10 2012 +0200
errors to stderr
Change-Id: I01756622dd7700d3918d156f118cd69c8a15879a
diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index c191dc4..c443840 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -67,7 +67,7 @@ public class SQLQueryComposer
}
catch (Exception exception)
{
- exception.printStackTrace(System.out);
+ exception.printStackTrace(System.err);
}
}
@@ -140,7 +140,7 @@ public class SQLQueryComposer
}
catch (Exception exception)
{
- exception.printStackTrace(System.out);
+ exception.printStackTrace(System.err);
}
}
@@ -171,7 +171,7 @@ public class SQLQueryComposer
}
catch (Exception e)
{
- e.printStackTrace(System.out);
+ e.printStackTrace(System.err);
}
}
}
@@ -327,7 +327,7 @@ public class SQLQueryComposer
}
catch (Exception exception)
{
- exception.printStackTrace(System.out);
+ exception.printStackTrace(System.err);
displaySQLErrorDialog(exception, _xParentWindow);
return false;
}
@@ -425,7 +425,7 @@ public class SQLQueryComposer
}
catch (Exception typeexception)
{
- typeexception.printStackTrace(System.out);
+ typeexception.printStackTrace(System.err);
}
}
commit ede56437f9641cad698b97b2dd14b0c1c37dfcce
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jul 12 23:23:03 2012 +0200
fdo#50800 populate composedCommandNames ASAP, not at call of getFromClause
In particular com/sun/star/wizards/ui/FilterComponent calls getSelectClause before calling getFromClause, and then all hell breaks loose: composedCommandNames is empty, thus cannot find the proper Alias column name, thus the column names in the select list were not properly escaped, ...
We have just made getFromClause quadratic instead of linear, but:
1) I do not think this would be a problem (small datastructures)
2) If it is, rather use a hashmap or something like that, wich will also make getSelectClause faster
Also make the fallback case of "unknown table" more robust: escape the table name (if any) and column name!
Change-Id: I474adc51fc6378d836bd5865d9eb9505983dcbc5
diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index 973fe7f..c191dc4 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -59,7 +59,7 @@ public class SQLQueryComposer
{
try
{
- this.CurDBMetaData = _CurDBMetaData;
+ setDBMetaData(_CurDBMetaData);
xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, CurDBMetaData.DBConnection);
final Object oQueryComposer = xMSF.createInstance("com.sun.star.sdb.SingleSelectQueryComposer");
m_xQueryAnalyzer = UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, oQueryComposer);
@@ -227,6 +227,7 @@ public class SQLQueryComposer
public void setDBMetaData(QueryMetaData _oDBMetaData)
{
this.CurDBMetaData = _oDBMetaData;
+ updateComposedCommandNames();
}
private PropertyValue[][] replaceConditionsByAlias(PropertyValue _filterconditions[][])
@@ -250,22 +251,30 @@ public class SQLQueryComposer
return m_xQueryAnalyzer.getQuery();
}
- public StringBuilder getFromClause()
+ private void updateComposedCommandNames()
{
- StringBuilder sFromClause = new StringBuilder("FROM");
composedCommandNames.clear();
String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
for (int i = 0; i < sCommandNames.length; i++)
{
- CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]); //(setComposedCommandName)
+ CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]);
curCommandName.setAliasName(getuniqueAliasName(curCommandName.getTableName()));
+ composedCommandNames.add(curCommandName);
+ }
+ }
+
+ public StringBuilder getFromClause()
+ {
+ StringBuilder sFromClause = new StringBuilder("FROM");
+ String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
+ for (int i = 0; i < sCommandNames.length; i++)
+ {
+ CommandName curCommandName = getComposedCommandByDisplayName(sCommandNames[i]);
sFromClause.append(" ").append(curCommandName.getComposedName()).append(" ").append(quoteName(curCommandName.getAliasName()));
if (i < sCommandNames.length - 1)
{
sFromClause.append(", ");
}
- // fill composedCommandNames
- composedCommandNames.add(curCommandName);
}
return sFromClause;
}
@@ -327,13 +336,19 @@ public class SQLQueryComposer
private String getComposedAliasFieldName(String _fieldname)
{
FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname);
- CommandName curComposedCommandName = getComposedCommandByDisplayName(CurFieldColumn.getCommandName());
+ final String curCommandName = CurFieldColumn.getCommandName();
+ final String curFieldName = CurFieldColumn.getFieldName();
+ CommandName curComposedCommandName = getComposedCommandByDisplayName(curCommandName);
if (curComposedCommandName == null)
{
- return _fieldname;
+ //return _fieldname;
+ if ( curCommandName.length() > 0 )
+ return quoteName(curCommandName) + "." + quoteName(curFieldName);
+ else
+ return quoteName(CurFieldColumn.getFieldName());
}
String curAliasName = curComposedCommandName.getAliasName();
- return quoteName(curAliasName) + "." + quoteName(CurFieldColumn.getFieldName());
+ return quoteName(curAliasName) + "." + quoteName(curFieldName);
}
private CommandName getComposedCommandByAliasName(String _AliasName)
commit 607e4857bf5c3a1a11092cf6c1aabb96d54852ef
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jul 12 18:10:14 2012 +0200
debug unexpected exception
Change-Id: I404072caf6ddab0ed833586066507c7d332fcea4
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index b3bea65..5c09efc 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -614,6 +614,7 @@ void SAL_CALL OSingleSelectQueryComposer::setElementaryQuery( const ::rtl::OUStr
{
(void)e;
OSL_FAIL( "OSingleSelectQueryComposer::setElementaryQuery: there should be no error anymore for the additive statement!" );
+ DBG_UNHANDLED_EXCEPTION();
// every part of the additive statement should have passed other tests already, and should not
// be able to cause any errors ... me thinks
}
More information about the Libreoffice-commits
mailing list