SQL/OCI: add maximumIdentifierLength()
A table name or identifier must not be longer than 30 (< Oracle 12.2) or 128 bytes (sadly not characters). Change-Id: I49192afaf908e12f5cfd20c754640b6117b03a71 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
f49f3f2f94
commit
1981ebe8ad
@ -2759,4 +2759,11 @@ QString QOCIDriver::escapeIdentifier(const QString &identifier, IdentifierType t
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QOCIDriver::maximumIdentifierLength(IdentifierType type) const
|
||||||
|
{
|
||||||
|
Q_D(const QOCIDriver);
|
||||||
|
Q_UNUSED(type);
|
||||||
|
return d->serverVersion > 12 ? 128 : 30;
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -58,6 +58,7 @@ public:
|
|||||||
bool trimStrings) const override;
|
bool trimStrings) const override;
|
||||||
QVariant handle() const override;
|
QVariant handle() const override;
|
||||||
QString escapeIdentifier(const QString &identifier, IdentifierType) const override;
|
QString escapeIdentifier(const QString &identifier, IdentifierType) const override;
|
||||||
|
int maximumIdentifierLength(IdentifierType type) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool beginTransaction() override;
|
bool beginTransaction() override;
|
||||||
|
@ -45,16 +45,13 @@ static QString qGetHostName()
|
|||||||
return hostname;
|
return hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString fixupTableName(const QString &tableName, QSqlDatabase db)
|
inline QString fixupTableName(const QString &tableName, const QSqlDatabase &db)
|
||||||
{
|
{
|
||||||
QString tbName = tableName;
|
QString tbName = tableName;
|
||||||
// On Oracle we are limited to 30 character tablenames
|
// Oracle & Interbase/Firebird have a limit on the tablename length
|
||||||
QSqlDriverPrivate *d = static_cast<QSqlDriverPrivate *>(QObjectPrivate::get(db.driver()));
|
QSqlDriver *drv = db.driver();
|
||||||
if (d && d->dbmsType == QSqlDriver::Oracle)
|
if (drv)
|
||||||
tbName.truncate(30);
|
tbName.truncate(drv->maximumIdentifierLength(QSqlDriver::TableName));
|
||||||
// On Interbase we are limited to 31 character tablenames
|
|
||||||
if (d && d->dbmsType == QSqlDriver::Interbase)
|
|
||||||
tbName.truncate(31);
|
|
||||||
return tbName;
|
return tbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user