Anonymous avatar Anonymous committed ff9c26c

dba33h: #i114246# use correct table name

Comments (0)

Files changed (2)

dbaccess/source/core/api/KeySet.cxx

     m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) );
 }
 void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable
-                                                   ,const Reference<XDatabaseMetaData>& /*i_xMeta*/
+                                                   ,const Reference<XDatabaseMetaData>& i_xMeta
                                                    ,const Reference<XNameAccess>& i_xQueryColumns)
 {
     // first ask the database itself for the best columns which can be used
 
     const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW);
     const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns();
-    ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames),true);
-    ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames),true);
-
     // locate parameter in select columns
     Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
     Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
         Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
         xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
     }
-    ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,m_sUpdateTableName,(*m_pParameterNames),true);
+
+    if ( m_sUpdateTableName.getLength() )
+    {
+        ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames),true);
+        ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames),true);
+        ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,m_sUpdateTableName,(*m_pParameterNames),true);
+    }
+    else
+    {
+        ::rtl::OUString sCatalog,sSchema,sTable;
+	    Reference<XPropertySet> xTableProp(i_aTable,UNO_QUERY);
+        Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME);
+	    aCatalog >>= sCatalog;
+	    xTableProp->getPropertyValue(PROPERTY_SCHEMANAME)	>>= sSchema;
+	    xTableProp->getPropertyValue(PROPERTY_NAME)			>>= sTable;
+        const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
+        ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true);
+        ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true);
+        ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true);
+    }
 
     SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
     SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
 			::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT ");
 			sStmt += sMaxStmt;
 			sStmt += ::rtl::OUString::createFromAscii("FROM ");
-			sStmt += m_aSelectComposedTableName;
+			::rtl::OUString sCatalog,sSchema,sTable;
+			::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+			sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable );
+			//sStmt += m_aSelectComposedTableName;
 			try
 			{
 				// now fetch the autoincrement values

dbaccess/source/core/api/KeySet.hxx

 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>					m_xRow;
 		::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >	m_xComposer;
 		::rtl::OUString																	m_sUpdateTableName;
-		::rtl::OUString																	m_aSelectComposedTableName;
         ::std::vector< ::rtl::OUString >						m_aFilterColumns;
 		
 		sal_Bool m_bRowCountFinal;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.