Search for usage in LXR

#include <dbintrospector.h>

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


class  ForeignKey

Public Types

using Ptr = QSharedPointer< DbIntrospector >

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

Constructor & Destructor Documentation

◆ DbIntrospector()

DbIntrospector::DbIntrospector ( const QSqlDatabase database)

Creates a new database introspector, call from subclass.

databaseThe database to introspect.

Definition at line 37 of file dbintrospector.cpp.

Member Function Documentation

◆ createInstance()

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

Returns an introspector instance for a given database.

Definition at line 21 of file dbintrospector.cpp.

◆ foreignKeyConstraints()

QVector< DbIntrospector::ForeignKey > DbIntrospector::foreignKeyConstraints ( const QString tableName)

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

◆ hasColumn()

bool DbIntrospector::hasColumn ( const QString tableName,
const QString columnName 

Check whether table tableName has a column named columnName.

The default implementation should work with all backends.

Definition at line 60 of file dbintrospector.cpp.

◆ hasIndex()

bool DbIntrospector::hasIndex ( const QString tableName,
const QString indexName 

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

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

See also
DbExceptionon database errors.

Definition at line 51 of file dbintrospector.cpp.

◆ hasIndexQuery()

QString DbIntrospector::hasIndexQuery ( const QString tableName,
const QString indexName 

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

◆ hasTable()

bool DbIntrospector::hasTable ( const QString tableName)

Returns true if table tableName exists.

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

Definition at line 46 of file dbintrospector.cpp.

◆ isTableEmpty()

bool DbIntrospector::isTableEmpty ( const QString tableName)

Check whether table tableName is empty, ie.

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

DbExceptionon database errors.

Definition at line 82 of file dbintrospector.cpp.

Member Data Documentation

◆ m_database

QSqlDatabase Akonadi::Server::DbIntrospector::m_database

The database connection we are introspecting.

Definition at line 101 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-2022 The KDE developers.
Generated on Tue Aug 16 2022 04:00:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.