From acd9f66f2834c16650d37109650ed47e491a0241 Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Thu, 15 Aug 2013 10:02:26 +0100 Subject: 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 Tested-by: Fridrich Strba --- connectivity/source/commontools/dbtools2.cxx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index bf9fad695f08..055a3bd16356 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 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 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 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) -- cgit