connectivity/source/commontools/dbtools2.cxx | 26 ++++++++++++++++++++------ include/connectivity/dbtools.hxx | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-)
New commits: commit acd9f66f2834c16650d37109650ed47e491a0241 Author: Andrzej J.R. Hunt <andr...@ahunt.org> Date: Thu Aug 15 10:02:26 2013 +0100 Split type-description out of createStandardColumnPart. createStandardColumnPart returns a string that is usable in table creation, the type descriptor (e.g. CHAR(N)) is also useful in column-type altering statements, hence this is split into a separate function. This is needed primarily in the firebird driver where column-type alter statements are in a different form to most dbs. Change-Id: If44554f979f6dd14bf679455978f3f0b44784bf5 Reviewed-on: https://gerrit.libreoffice.org/5432 Reviewed-by: Fridrich Strba <fridr...@documentfoundation.org> Tested-by: Fridrich Strba <fridr...@documentfoundation.org> diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index bf9fad6..055a3bd 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -60,7 +60,7 @@ namespace dbtools using namespace connectivity; using namespace comphelper; -OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const OUString& _sCreatePattern) +OUString createStandardTypePart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const OUString& _sCreatePattern) { Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData(); @@ -72,11 +72,6 @@ OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,cons sal_Int32 nPrecision = 0; sal_Int32 nScale = 0; - const OUString sQuoteString = xMetaData->getIdentifierQuoteString(); - OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); - - aSql.appendAscii(" "); - nDataType = nPrecision = nScale = 0; sal_Bool bIsAutoIncrement = sal_False; xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sTypeName; @@ -85,6 +80,8 @@ OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,cons xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale; xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bIsAutoIncrement; + OUStringBuffer aSql; + // check if the user enter a specific string to create autoincrement values OUString sAutoIncrementValue; Reference<XPropertySetInfo> xPropInfo = xColProp->getPropertySetInfo(); @@ -180,6 +177,23 @@ OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,cons return aSql.makeStringAndClear(); } + +OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const OUString& _sCreatePattern) +{ + Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData(); + + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + + const OUString sQuoteString = xMetaData->getIdentifierQuoteString(); + OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); + + aSql.appendAscii(" "); + + aSql.append(createStandardTypePart(xColProp, _xConnection, _pHelper, _sCreatePattern)); + + return aSql.makeStringAndClear(); +} + // ----------------------------------------------------------------------------- OUString createStandardCreateStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const OUString& _sCreatePattern) diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx index 4242373..8064355 100644 --- a/include/connectivity/dbtools.hxx +++ b/include/connectivity/dbtools.hxx @@ -645,6 +645,22 @@ namespace dbtools OUString createStandardKeyStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection); + /** creates the standard sql statement for the type part of a create or alter table statement. + @param _pHelper + Allow to add special SQL constructs. + @param descriptor + The descriptor of the column. + @param _xConnection + The connection. + @param _pHelper + Allow to add special SQL constructs. + */ + OOO_DLLPUBLIC_DBTOOLS + OUString createStandardTypePart( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor + ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection + ,ISQLStatementHelper* _pHelper = NULL + ,const OUString& _sCreatePattern = OUString()); + /** creates the standard sql statement for the column part of a create table statement. @param _pHelper Allow to add special SQL constructs. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits