summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-03-26 10:02:26 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-03-26 08:04:42 +0000
commitb6dc6712aef820c2d296101961b163d665633d9a (patch)
treea3a34b52edab9ea8c7dcd008d4b89416b1250c44 /dbaccess
parentced4a9221329b88484f90ab6d00d797f024585bb (diff)
Simplify FbCreateStmtParser::compose
Change-Id: I7b593cdfc4ee32897314d95d71c9dcecc8bb9a8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149614 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/filter/hsqldb/fbcreateparser.cxx33
1 files changed, 12 insertions, 21 deletions
diff --git a/dbaccess/source/filter/hsqldb/fbcreateparser.cxx b/dbaccess/source/filter/hsqldb/fbcreateparser.cxx
index 1740998c62d2..5d4244f8085b 100644
--- a/dbaccess/source/filter/hsqldb/fbcreateparser.cxx
+++ b/dbaccess/source/filter/hsqldb/fbcreateparser.cxx
@@ -29,12 +29,6 @@ using namespace css::sdbc;
namespace
{
-void lcl_appendWithSpace(OUStringBuffer& sBuff, std::u16string_view sStr)
-{
- sBuff.append(" ");
- sBuff.append(sStr);
-}
-
OUString lcl_DataTypetoFbTypeName(sal_Int32 eType)
{
switch (eType)
@@ -110,8 +104,7 @@ void FbCreateStmtParser::appendPrimaryKeyPart(OUStringBuffer& rSql) const
if (sPrimaryKeys.empty())
return; // no primary key specified
- rSql.append(",");
- rSql.append("PRIMARY KEY(");
+ rSql.append(",PRIMARY KEY(");
auto it = sPrimaryKeys.cbegin();
while (it != sPrimaryKeys.end())
{
@@ -135,15 +128,14 @@ OUString FbCreateStmtParser::compose() const
{
ensureProperTableLengths();
OUStringBuffer sSql(128);
- sSql.append("CREATE TABLE " + getTableName());
+ sSql.append("CREATE TABLE " + getTableName() + " ("); // column declaration
- lcl_appendWithSpace(sSql, u"("); // column declaration
auto& rColumns = getColumnDef();
auto columnIter = rColumns.cbegin();
while (columnIter != rColumns.end())
{
- lcl_appendWithSpace(sSql, columnIter->getName());
- lcl_appendWithSpace(sSql, lcl_DataTypetoFbTypeName(columnIter->getDataType()));
+ sSql.append(" " + columnIter->getName() + " "
+ + lcl_DataTypetoFbTypeName(columnIter->getDataType()));
std::vector<sal_Int32> params{ columnIter->getParams() };
@@ -173,31 +165,30 @@ OUString FbCreateStmtParser::compose() const
// special modifiers here, based on type (e.g. charset, subtype)
OUString sModifier = lcl_getTypeModifier(columnIter->getDataType());
if (!sModifier.isEmpty())
- lcl_appendWithSpace(sSql, sModifier);
+ sSql.append(" " + sModifier);
if (columnIter->isAutoIncremental())
{
- lcl_appendWithSpace(sSql, u"GENERATED BY DEFAULT AS IDENTITY (START WITH ");
-
// start with 0:
// HSQLDB: first value will be 0.
// Firebird: first value will be 1.
- sSql.append(OUString::number(columnIter->getStartValue() - 1) + ")");
+ sSql.append(" GENERATED BY DEFAULT AS IDENTITY (START WITH "
+ + OUString::number(columnIter->getStartValue() - 1) + ")");
}
else if (!columnIter->isNullable())
- lcl_appendWithSpace(sSql, u"NOT NULL");
+ sSql.append(" NOT NULL");
if (columnIter->isCaseInsensitive())
- lcl_appendWithSpace(sSql, u"COLLATE UNICODE_CI");
+ sSql.append(" COLLATE UNICODE_CI");
const OUString& sDefaultVal = columnIter->getDefault();
if (!sDefaultVal.isEmpty())
{
- lcl_appendWithSpace(sSql, u"DEFAULT");
+ sSql.append(" DEFAULT ");
if (sDefaultVal.equalsIgnoreAsciiCase("NOW"))
- lcl_appendWithSpace(sSql, u"\'NOW\'"); // Fb likes it single quoted
+ sSql.append("'NOW'"); // Fb likes it single quoted
else
- lcl_appendWithSpace(sSql, sDefaultVal);
+ sSql.append(sDefaultVal);
}
++columnIter;