mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* Added a convenient sql escaping method to TomahawkSqlQuery. It uses the sql drivers internal escaping mechanism.
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "database/TomahawkSqlQuery.h"
|
#include "database/TomahawkSqlQuery.h"
|
||||||
|
|
||||||
|
#include "database/Database.h"
|
||||||
|
#include "database/DatabaseImpl.h"
|
||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
@@ -42,6 +44,13 @@ TomahawkSqlQuery::TomahawkSqlQuery( const QSqlDatabase& db )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
TomahawkSqlQuery::escape( const QString& identifier, QSqlDriver::IdentifierType type )
|
||||||
|
{
|
||||||
|
return Database::instance()->impl()->database().driver()->escapeIdentifier( identifier, type );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TomahawkSqlQuery::exec( const QString& query )
|
TomahawkSqlQuery::exec( const QString& query )
|
||||||
{
|
{
|
||||||
@@ -114,7 +123,7 @@ TomahawkSqlQuery::showError()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TomahawkSqlQuery::isBusyError( const QSqlError& error )
|
TomahawkSqlQuery::isBusyError( const QSqlError& error ) const
|
||||||
{
|
{
|
||||||
const QString text = error.text().toLower();
|
const QString text = error.text().toLower();
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
// subclass QSqlQuery so that it prints the error msg if a query fails
|
// subclass QSqlQuery so that it prints the error msg if a query fails
|
||||||
|
|
||||||
|
#include <QSqlDriver>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
|
||||||
#define TOMAHAWK_QUERY_ANALYZE 1
|
#define TOMAHAWK_QUERY_ANALYZE 1
|
||||||
@@ -32,13 +33,15 @@ public:
|
|||||||
TomahawkSqlQuery();
|
TomahawkSqlQuery();
|
||||||
TomahawkSqlQuery( const QSqlDatabase& db );
|
TomahawkSqlQuery( const QSqlDatabase& db );
|
||||||
|
|
||||||
|
static QString escape( const QString& identifier, QSqlDriver::IdentifierType type = QSqlDriver::FieldName );
|
||||||
|
|
||||||
bool exec( const QString& query );
|
bool exec( const QString& query );
|
||||||
bool exec();
|
bool exec();
|
||||||
|
|
||||||
bool commitTransaction();
|
bool commitTransaction();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isBusyError( const QSqlError& error );
|
bool isBusyError( const QSqlError& error ) const;
|
||||||
|
|
||||||
void showError();
|
void showError();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user