Akonadi::Server::DbIntrospector

Search for usage in LXR

#include <dbintrospector.h>

Classes

class  ForeignKey
 

Public Types

using Ptr = QSharedPointer<DbIntrospector>
 

Public Member Functions

virtual QList< ForeignKeyforeignKeyConstraints (const QString &tableName)
 
virtual QString getAutoIncrementValueQuery (const QString &tableName, const QString &columnName)=0
 
virtual bool hasColumn (const QString &tableName, const QString &columnName)
 
virtual bool hasIndex (const QString &tableName, const QString &indexName)
 
virtual bool hasTable (const QString &tableName)
 
virtual bool isTableEmpty (const QString &tableName)
 
virtual QString updateAutoIncrementValueQuery (const QString &tableName, const QString &columnName, qint64 value)=0
 

Static Public Member Functions

static DbIntrospector::Ptr createInstance (const QSqlDatabase &database)
 

Protected Member Functions

 DbIntrospector (const QSqlDatabase &database)
 
virtual QString hasIndexQuery (const QString &tableName, const QString &indexName)
 

Protected Attributes

QSqlDatabase m_database
 

Detailed Description

Methods for introspecting the current state of a database schema.

I.e. this is about the structure of a database, not its content.

Definition at line 24 of file dbintrospector.h.

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ ~DbIntrospector()

DbIntrospector::~DbIntrospector ( )
virtual

Definition at line 43 of file dbintrospector.cpp.

◆ DbIntrospector()

DbIntrospector::DbIntrospector ( const QSqlDatabase & database)
protected

Creates a new database introspector, call from subclass.

Parameters
databaseThe database to introspect.

Definition at line 38 of file dbintrospector.cpp.

Member Function Documentation

◆ createInstance()

DbIntrospector::Ptr DbIntrospector::createInstance ( const QSqlDatabase & database)
static

Returns an introspector instance for a given database.

Definition at line 22 of file dbintrospector.cpp.

◆ foreignKeyConstraints()

QList< DbIntrospector::ForeignKey > DbIntrospector::foreignKeyConstraints ( const QString & tableName)
virtual

Returns the foreign key constraints on table tableName.

The default implementation returns an empty list, so any backend supporting referential integrity should reimplement this.

Definition at line 97 of file dbintrospector.cpp.

◆ getAutoIncrementValueQuery()

virtual QString Akonadi::Server::DbIntrospector::getAutoIncrementValueQuery ( const QString & tableName,
const QString & columnName )
pure virtual

Returns query to retrieve the next autoincrement value for tableName.

columnName.

◆ hasColumn()

bool DbIntrospector::hasColumn ( const QString & tableName,
const QString & columnName )
virtual

Check whether table tableName has a column named columnName.

The default implementation should work with all backends.

Definition at line 61 of file dbintrospector.cpp.

◆ hasIndex()

bool DbIntrospector::hasIndex ( const QString & tableName,
const QString & indexName )
virtual

Returns true of the given table has an index with the given name.

The default implementation performs the query returned by hasIndexQuery().

See also
hasIndexQuery()
Exceptions
DbExceptionon database errors.

Definition at line 52 of file dbintrospector.cpp.

◆ hasIndexQuery()

QString DbIntrospector::hasIndexQuery ( const QString & tableName,
const QString & indexName )
protectedvirtual

Returns a query string to determine if tableName has an index indexName.

The query is expected to have one boolean result row/column. This is used by the default implementation of hasIndex() only, thus reimplementation is not necessary if you reimplement hasIndex() The default implementation asserts.

Definition at line 103 of file dbintrospector.cpp.

◆ hasTable()

bool DbIntrospector::hasTable ( const QString & tableName)
virtual

Returns true if table tableName exists.

The default implementation relies on QSqlDatabase::tables(). Usually this does not need to be reimplemented.

Definition at line 47 of file dbintrospector.cpp.

◆ isTableEmpty()

bool DbIntrospector::isTableEmpty ( const QString & tableName)
virtual

Check whether table tableName is empty, ie.

does not contain any rows. The default implementation should work for all backends.

Exceptions
DbExceptionon database errors.

Definition at line 83 of file dbintrospector.cpp.

◆ updateAutoIncrementValueQuery()

virtual QString Akonadi::Server::DbIntrospector::updateAutoIncrementValueQuery ( const QString & tableName,
const QString & columnName,
qint64 value )
pure virtual

Returns query to update the next autoincrement value for tableName.

columnName to value value.

Member Data Documentation

◆ m_database

QSqlDatabase Akonadi::Server::DbIntrospector::m_database
protected

The database connection we are introspecting.

Definition at line 111 of file dbintrospector.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.