24#include <com/sun/star/sdbc/DataType.hpp>
26#include <rtl/ustrbuf.hxx>
28using namespace css::sdbc;
32OUString lcl_DataTypetoFbTypeName(sal_Int32
eType)
37 case DataType::BINARY:
39 case DataType::VARCHAR:
40 case DataType::VARBINARY:
42 case DataType::TINYINT:
43 case DataType::SMALLINT:
45 case DataType::INTEGER:
47 case DataType::BIGINT:
49 case DataType::NUMERIC:
51 case DataType::DECIMAL:
53 case DataType::BOOLEAN:
55 case DataType::LONGVARCHAR:
56 case DataType::LONGVARBINARY:
65 case DataType::TIMESTAMP:
67 case DataType::DOUBLE:
69 return "DOUBLE PRECISION";
78OUString lcl_getTypeModifier(sal_Int32
eType)
85 case DataType::LONGVARCHAR:
87 case DataType::LONGVARBINARY:
88 return "SUB_TYPE -9546";
89 case DataType::BINARY:
90 case DataType::VARBINARY:
91 return "CHARACTER SET OCTETS";
104 if (sPrimaryKeys.empty())
107 rSql.append(
",PRIMARY KEY(");
108 auto it = sPrimaryKeys.cbegin();
109 while (it != sPrimaryKeys.end())
113 if (it != sPrimaryKeys.end())
122 const std::vector<ColumnDefinition>& rColumns =
getColumnDef();
123 for (
const auto&
col : rColumns)
130 OUStringBuffer sSql(128);
134 auto columnIter = rColumns.cbegin();
135 while (columnIter != rColumns.end())
137 sSql.append(
" " + columnIter->getName() +
" "
138 + lcl_DataTypetoFbTypeName(columnIter->getDataType()));
140 std::vector<sal_Int32> params{ columnIter->getParams() };
142 if (columnIter->getDataType() == DataType::NUMERIC
143 || columnIter->getDataType() == DataType::DECIMAL)
146 if (params.at(0) > 18)
151 if (!params.empty() && columnIter->getDataType() != DataType::TIMESTAMP)
154 auto it = params.cbegin();
155 while (it != params.end())
159 if (it != params.end())
166 OUString sModifier = lcl_getTypeModifier(columnIter->getDataType());
167 if (!sModifier.isEmpty())
168 sSql.append(
" " + sModifier);
170 if (columnIter->isAutoIncremental())
175 sSql.append(
" GENERATED BY DEFAULT AS IDENTITY (START WITH "
176 + OUString::number(columnIter->getStartValue() - 1) +
")");
178 else if (!columnIter->isNullable())
179 sSql.append(
" NOT NULL");
181 if (columnIter->isCaseInsensitive())
182 sSql.append(
" COLLATE UNICODE_CI");
184 const OUString& sDefaultVal = columnIter->getDefault();
185 if (!sDefaultVal.isEmpty())
187 sSql.append(
" DEFAULT ");
188 if (sDefaultVal.equalsIgnoreAsciiCase(
"NOW"))
189 sSql.append(
"'NOW'");
191 sSql.append(sDefaultVal);
195 if (columnIter != rColumns.end())
202 return sSql.makeStringAndClear();
std::vector< OUString > const & getPrimaryKeys() const
OUString const & getTableName() const
const std::vector< ColumnDefinition > & getColumnDef() const
void appendPrimaryKeyPart(rtl::OUStringBuffer &rSql) const
virtual OUString compose() const override
Compose the result of the parser to statements of Firebird dialect.
void ensureProperTableLengths() const
RttiCompleteObjectLocator col
void ensureFirebirdTableLength(std::u16string_view sName)