Akonadi::Server::DbIntrospector

#include <dbintrospector.h>

Inherited by Akonadi::Server::DbIntrospectorMySql, Akonadi::Server::DbIntrospectorPostgreSql, and Akonadi::Server::DbIntrospectorSqlite.

Classes

class  ForeignKey
 

Public Types

typedef QSharedPointer< DbIntrospectorPtr
 

Public Member Functions

virtual QVector< ForeignKeyforeignKeyConstraints (const QString &tableName)
 
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)
 

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 26 of file dbintrospector.h.

Constructor & Destructor Documentation

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

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

Returns an introspector instance for a given database.

Definition at line 22 of file dbintrospector.cpp.

QVector< 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 96 of file dbintrospector.cpp.

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.

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.

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 reimplmentation is not necessary if you reimplement hasIndex() The default implementation asserts.

Definition at line 102 of file dbintrospector.cpp.

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.

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.

Member Data Documentation

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

The database connection we are introspecting.

Definition at line 103 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-2020 The KDE developers.
Generated on Sun Jul 12 2020 23:17:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.