KDbNativeStatementBuilder

Search for usage in LXR

KDbNativeStatementBuilder Class Reference

#include <KDbNativeStatementBuilder.h>

Public Member Functions

 KDbNativeStatementBuilder (KDbConnection *connection, KDb::IdentifierEscapingType dialect)
 
bool generateCreateTableStatement (KDbEscapedString *target, const KDbTableSchema &tableSchema) const
 
bool generateSelectStatement (KDbEscapedString *target, KDbQuerySchema *querySchema, const KDbSelectStatementOptions &options, const QList< QVariant > &parameters=QList< QVariant >()) const
 
bool generateSelectStatement (KDbEscapedString *target, KDbQuerySchema *querySchema, const QList< QVariant > &parameters=QList< QVariant >()) const
 
bool generateSelectStatement (KDbEscapedString *target, KDbTableSchema *tableSchema, const KDbSelectStatementOptions &options=KDbSelectStatementOptions()) const
 

Detailed Description

A builder for generating various types of native SQL statements.

The statement strings can be specific for the used connection and database driver, and thus generally not portable across connections.

Definition at line 29 of file KDbNativeStatementBuilder.h.

Constructor & Destructor Documentation

◆ KDbNativeStatementBuilder()

KDbNativeStatementBuilder::KDbNativeStatementBuilder ( KDbConnection connection,
KDb::IdentifierEscapingType  dialect 
)

Creates a new native builder object.

connection is required.

If dialect is KDbEscaping generated statement strings will be of KDbSQL dialect, else they will be specific to database connection or connection's database driver.

Definition at line 53 of file KDbNativeStatementBuilder.cpp.

Member Function Documentation

◆ generateCreateTableStatement()

bool KDbNativeStatementBuilder::generateCreateTableStatement ( KDbEscapedString target,
const KDbTableSchema tableSchema 
) const

Generates a native "CREATE TABLE ..." statement string that can be used for creation of tableSchema in the database. The statement is written to *target on success.

Returns
true on success. If target is nullptr, false is returned.
Todo:
warning: ^^^^^ this allows only one autonumber per table when AUTO_INCREMENT_REQUIRES_PK==true!
Todo:
here is automatically a single-field key created
Todo:
IS this ok for all engines?: if (!autoinc && !field->isPrimaryKey() && field->isNotNull())

Definition at line 446 of file KDbNativeStatementBuilder.cpp.

◆ generateSelectStatement() [1/2]

bool KDbNativeStatementBuilder::generateSelectStatement ( KDbEscapedString target,
KDbQuerySchema querySchema,
const KDbSelectStatementOptions options,
const QList< QVariant > &  parameters = QList<QVariant>() 
) const

Generates a native "SELECT ..." statement string that can be used for executing query defined by querySchema, params and options.

target and querySchema must not be 0. The statement is written to *target on success.

Returns
true on success.

Definition at line 423 of file KDbNativeStatementBuilder.cpp.

◆ generateSelectStatement() [2/2]

bool KDbNativeStatementBuilder::generateSelectStatement ( KDbEscapedString target,
KDbTableSchema tableSchema,
const KDbSelectStatementOptions options = KDbSelectStatementOptions() 
) const

Generates a native "SELECT ..." statement string that can be used for executing query defined by an functional equivalent of a "SELECT * FROM table_name" statement where table_name is tableSchema's name. params and options are used like in the toSelectStatement(KDbEscapedString*, KDbQuerySchema*, const KDbSelectStatementOptions&, const QList<QVariant>&) variant. target and querySchema must not be 0.

Returns
true on success.

Definition at line 439 of file KDbNativeStatementBuilder.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 04:06:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.