22#include "drivermanager.h"
23#include "lookupfieldschema.h"
33#include <kstaticdeleter.h>
34#include <tdemessagebox.h>
36#include <kiconloader.h>
45 TQMap< uint, TypeGroupList > tlist;
46 TQMap< uint, TQStringList > nlist;
47 TQMap< uint, TQStringList > slist;
48 TQMap< uint, Field::Type > def_tlist;
51static KStaticDeleter<TypeCache> KexiDB_typeCacheDeleter;
52TypeCache *KexiDB_typeCache = 0;
56 KexiDB_typeCacheDeleter.setObject( KexiDB_typeCache,
new TypeCache() );
61 TQStringList name_list, str_list;
62 if (KexiDB_typeCache->tlist.find( tg )!=KexiDB_typeCache->tlist.end()) {
63 list = KexiDB_typeCache->tlist[ tg ];
64 name_list = KexiDB_typeCache->nlist[ tg ];
65 str_list = KexiDB_typeCache->slist[ tg ];
70 KexiDB_typeCache->tlist[ tg ] = list;
71 KexiDB_typeCache->nlist[ tg ] = name_list;
72 KexiDB_typeCache->slist[ tg ] = str_list;
76 KexiDB_typeCache->def_tlist[ Field::TextGroup ] =
Field::Text;
77 KexiDB_typeCache->def_tlist[ Field::IntegerGroup ] =
Field::Integer;
78 KexiDB_typeCache->def_tlist[ Field::FloatGroup ] =
Field::Double;
79 KexiDB_typeCache->def_tlist[ Field::BooleanGroup ] =
Field::Boolean;
80 KexiDB_typeCache->def_tlist[ Field::DateTimeGroup ] = Field::Date;
81 KexiDB_typeCache->def_tlist[ Field::BLOBGroup ] =
Field::BLOB;
86 if (!KexiDB_typeCache)
88 return KexiDB_typeCache->tlist[ typeGroup ];
93 if (!KexiDB_typeCache)
95 return KexiDB_typeCache->nlist[ typeGroup ];
100 if (!KexiDB_typeCache)
102 return KexiDB_typeCache->slist[ typeGroup ];
107 if (!KexiDB_typeCache)
109 return (typeGroup <= Field::LastTypeGroup) ? KexiDB_typeCache->def_tlist[ typeGroup ] :
Field::InvalidType;
115 if (!obj || !obj->
error()) {
116 if (
dynamic_cast<Cursor*
>(obj)) {
117 conn =
dynamic_cast<Cursor*
>(obj)->connection();
127 if (!obj || !obj->
error())
139 details +=
"<p><b><nobr>" +i18n(
"Message from server:") +
"</nobr></b><br>" + obj->
serverErrorMsg();
141 details +=
"<p><b><nobr>" +i18n(
"SQL statement:") + TQString(
"</nobr></b><br><tt>%1</tt>").arg(obj->
recentSQLString());
143 TQString serverResultName;
150 serverResultName = obj->previousServerResultName();
152 if (!serverResultName.isEmpty())
153 details += (TQString(
"<p><b><nobr>")+i18n(
"Server result name:")+
"</nobr></b><br>"+serverResultName);
154 if (!details.isEmpty()
157 details += (TQString(
"<p><b><nobr>")+i18n(
"Server result number:")+
"</nobr></b><br>"+TQString::number(serverResult));
160 if (!details.isEmpty() && !details.startsWith(
"<qt>")) {
161 if (details.startsWith(
"<p>"))
162 details = TQString::fromLatin1(
"<qt>")+details;
164 details = TQString::fromLatin1(
"<qt><p>")+details;
181 if (
true!=conn.
querySingleRecord(TQString(
"select o_id from kexi__objects where lower(o_name)='%1' and o_type=%2")
182 .arg(objName.lower()).arg(objType), data))
185 int id = data[0].toInt(&ok);
197 KexiDBWarn <<
"TableOrQuery(FieldList &tableOrQuery) : "
198 " tableOrQuery is neither table nor query!" << endl;
203 , m_table(table ? conn->tableSchema(TQString(name)) : 0)
204 , m_query(table ? 0 : conn->querySchema(TQString(name)))
207 KexiDBWarn <<
"TableOrQuery(Connection *conn, const TQCString& name, bool table) : "
208 "no table specified!" << endl;
209 if (!
table && !m_query)
210 KexiDBWarn <<
"TableOrQuery(Connection *conn, const TQCString& name, bool table) : "
211 "no query specified!" << endl;
215 : m_table(dynamic_cast<
TableSchema*>(&tableOrQuery))
216 , m_query(dynamic_cast<
QuerySchema*>(&tableOrQuery))
219 KexiDBWarn <<
"TableOrQuery(FieldList &tableOrQuery) : "
220 " tableOrQuery is nether table nor query!" << endl;
228 KexiDBWarn <<
"TableOrQuery(Connection *conn, int id) : no table or query found for id=="
229 <<
id <<
"!" << endl;
237 KexiDBWarn <<
"TableOrQuery(TableSchema* table) : no table specified!" << endl;
245 KexiDBWarn <<
"TableOrQuery(QuerySchema* query) : no query specified!" << endl;
265 KexiDBWarn <<
"TableOrQuerySchema::column() : no query or table specified!" << endl;
266 return QueryColumnInfo::Vector();
272 return m_table->name().latin1();
274 return m_query->name().latin1();
283 return sdata->caption().isEmpty() ? sdata->name() : sdata->caption();
321 return m_query->
debug();
336class ConnectionTestThread :
public TQThread {
341 ConnectionTestDialog* m_dlg;
345ConnectionTestThread::ConnectionTestThread(ConnectionTestDialog* dlg,
const KexiDB::ConnectionData& connData)
346 : m_dlg(dlg), m_connData(connData)
350void ConnectionTestThread::run()
355 if (!drv || manager.
error()) {
357 m_dlg->
error(&manager);
361 if (!conn || drv->
error()) {
385ConnectionTestDialog::ConnectionTestDialog(TQWidget* parent,
388 : KProgressDialog(parent,
"testconn_dlg",
389 i18n(
"Test Connection"), i18n(
"<qt>Testing connection to <b>%1</b> database server...</qt>")
390 .arg(data.serverInfoString(true)), true )
391 , m_thread(new ConnectionTestThread(this, data))
393 , m_msgHandler(&msgHandler)
396 , m_stopWaiting(false)
398 showCancelButton(
true);
399 progressBar()->setPercentageVisible(
false);
400 progressBar()->setTotalSteps(0);
401 connect(&m_timer, TQ_SIGNAL(timeout()),
this, TQ_SLOT(slotTimeout()));
403 resize(250, height());
406ConnectionTestDialog::~ConnectionTestDialog()
409 m_thread->terminate();
413int ConnectionTestDialog::exec()
417 const int res = KProgressDialog::exec();
423void ConnectionTestDialog::slotTimeout()
426 bool notResponding =
false;
427 if (m_elapsedTime >= 1000*5) {
428 m_stopWaiting =
true;
429 notResponding =
true;
432 m_timer.disconnect(
this);
438 m_msgHandler->showErrorMessage(m_errorObj);
441 else if (notResponding) {
442 KMessageBox::sorry(0,
443 i18n(
"<qt>Test connection to <b>%1</b> database server failed. The server is not responding.</qt>")
444 .arg(m_connData.serverInfoString(
true)),
445 i18n(
"Test Connection"));
448 KMessageBox::information(0,
449 i18n(
"<qt>Test connection to <b>%1</b> database server established successfully.</qt>")
450 .arg(m_connData.serverInfoString(
true)),
451 i18n(
"Test Connection"));
459 progressBar()->setProgress( m_elapsedTime );
464 KexiDBDbg <<
"ConnectionTestDialog::error()" << endl;
465 m_stopWaiting =
true;
477void ConnectionTestDialog::slotCancel()
480 m_thread->terminate();
481 m_timer.disconnect(
this);
483 KProgressDialog::slotCancel();
489 ConnectionTestDialog dlg(parent, data, msgHandler);
496 TQString selectSql( TQString::fromLatin1(
"SELECT COUNT() FROM (") + sql +
")" );
505 KexiDBWarn <<
"KexiDB::rowsCount(const KexiDB::TableSchema&): no tableSchema.connection() !" << endl;
510 TQString::fromLatin1(
"SELECT COUNT(*) FROM ")
521 KexiDBWarn <<
"KexiDB::rowsCount(const KexiDB::QuerySchema&): no querySchema.connection() !" << endl;
526 TQString::fromLatin1(
"SELECT COUNT(*) FROM (")
535 if (tableOrQuery.
table())
537 if (tableOrQuery.
query())
544 if (tableOrQuery.
table())
546 if (tableOrQuery.
query())
553 TQMap<TQString,TQString> m;
558 m[
"port"] = TQString::number(data.
port);
562 m[
"savePassword"] = TQString::number((
int)data.
savePassword);
574 data.
port = map[
"port"].toInt();
584 TQString& tableName, TQString& fieldName,
587 const int id =
string.find(
'.');
589 tableName = TQString();
591 return !fieldName.isEmpty();
593 if (
id<=0 ||
id==
int(
string.length()-1))
595 tableName =
string.left(
id);
596 fieldName =
string.mid(
id+1);
597 return !tableName.isEmpty() && !fieldName.isEmpty();
609 if (decimalPlaces < 0) {
610 TQString s( TQString::number(value,
'f', 10 ));
611 uint i = s.length()-1;
612 while (i>0 && s[i]==
'0')
616 s = s.left(i+1).replace(
'.', TDEGlobal::locale()->decimalSymbol());
619 if (decimalPlaces == 0)
620 return TQString::number((
int)value);
621 return TDEGlobal::locale()->formatNumber(value, decimalPlaces);
627 KexiDBWarn <<
"KexiDB::intToFieldType(): invalid type " << type << endl;
633static bool setIntToFieldType(
Field& field,
const TQVariant& value )
636 const int intType = value.toInt(&ok);
638 KexiDBWarn <<
"KexiDB::setFieldProperties(): invalid type" << endl;
646static KStaticDeleter< TQAsciiDict<char> > KexiDB_builtinFieldPropertiesDeleter;
648TQAsciiDict<char>* KexiDB_builtinFieldProperties = 0;
652 if (!KexiDB_builtinFieldProperties) {
653 KexiDB_builtinFieldPropertiesDeleter.setObject( KexiDB_builtinFieldProperties,
new TQAsciiDict<char>(499) );
654#define ADD(name) KexiDB_builtinFieldProperties->insert(name, (char*)1)
658 ADD(
"autoIncrement");
670 ADD(
"visibleDecimalPlaces");
674 return KexiDB_builtinFieldProperties->find( propertyName );
679 TQMapConstIterator<TQCString, TQVariant> it;
680 if ( (it = values.find(
"type")) != values.constEnd() ) {
681 if (!setIntToFieldType(field, *it))
685#define SET_BOOLEAN_FLAG(flag, value) { \
686 constraints |= KexiDB::Field::flag; \
688 constraints ^= KexiDB::Field::flag; \
693 if ( (it = values.find(
"primaryKey")) != values.constEnd() )
694 SET_BOOLEAN_FLAG(PrimaryKey, (*it).toBool());
695 if ( (it = values.find(
"indexed")) != values.constEnd() )
696 SET_BOOLEAN_FLAG(Indexed, (*it).toBool());
697 if ( (it = values.find(
"autoIncrement")) != values.constEnd()
699 SET_BOOLEAN_FLAG(AutoInc, (*it).toBool());
700 if ( (it = values.find(
"unique")) != values.constEnd() )
701 SET_BOOLEAN_FLAG(Unique, (*it).toBool());
702 if ( (it = values.find(
"notNull")) != values.constEnd() )
703 SET_BOOLEAN_FLAG(NotNull, (*it).toBool());
704 if ( (it = values.find(
"allowEmpty")) != values.constEnd() )
705 SET_BOOLEAN_FLAG(NotEmpty, !(*it).toBool());
709 if ( (it = values.find(
"unsigned")) != values.constEnd()) {
710 options |= KexiDB::Field::Unsigned;
712 options ^= KexiDB::Field::Unsigned;
714 field.setOptions( options );
716 if ( (it = values.find(
"name")) != values.constEnd())
717 field.
setName( (*it).toString() );
718 if ( (it = values.find(
"caption")) != values.constEnd())
720 if ( (it = values.find(
"description")) != values.constEnd())
722 if ( (it = values.find(
"length")) != values.constEnd())
723 field.
setLength( (*it).isNull() ? 0 : (*it).toUInt(&ok) );
726 if ( (it = values.find(
"precision")) != values.constEnd())
727 field.
setPrecision( (*it).isNull() ? 0 : (*it).toUInt(&ok) );
730 if ( (it = values.find(
"defaultValue")) != values.constEnd())
732 if ( (it = values.find(
"width")) != values.constEnd())
733 field.
setWidth( (*it).isNull() ? 0 : (*it).toUInt(&ok) );
736 if ( (it = values.find(
"visibleDecimalPlaces")) != values.constEnd()
743 typedef TQMap<TQCString, TQVariant> PropertiesMap;
744 foreach( PropertiesMap::ConstIterator, it, values ) {
750#undef SET_BOOLEAN_FLAG
754static KStaticDeleter< TQAsciiDict<char> > KexiDB_extendedPropertiesDeleter;
756TQAsciiDict<char>* KexiDB_extendedProperties = 0;
760 if (!KexiDB_extendedProperties) {
761 KexiDB_extendedPropertiesDeleter.setObject( KexiDB_extendedProperties,
new TQAsciiDict<char>(499,
false) );
762#define ADD(name) KexiDB_extendedProperties->insert(name, (char*)1)
763 ADD(
"visibleDecimalPlaces");
765 ADD(
"rowSourceType");
766 ADD(
"rowSourceValues");
768 ADD(
"visibleColumn");
770 ADD(
"showColumnHeaders");
773 ADD(
"displayWidget");
776 return KexiDB_extendedProperties->find( propertyName );
781#define SET_BOOLEAN_FLAG(flag, value) { \
782 constraints |= KexiDB::Field::flag; \
784 constraints ^= KexiDB::Field::flag; \
785 field.setConstraints( constraints ); \
788#define GET_INT(method) { \
789 const uint ival = value.toUInt(&ok); \
792 field.method( ival ); \
796 if (propertyName.isEmpty())
802 if (
"visibleDecimalPlaces" == propertyName
805 GET_INT( setVisibleDecimalPlaces );
808 if (!field.
table()) {
809 KexiDBWarn << TQString(
"KexiDB::setFieldProperty() Cannot set \"%1\" property - no table assinged for field!")
810 .arg(propertyName.data()) << endl;
814 const bool hasLookup = lookup != 0;
818 if (!hasLookup && lookup)
827 if (
"type" == propertyName )
828 return setIntToFieldType(field, value);
831 if (
"primaryKey" == propertyName )
832 SET_BOOLEAN_FLAG(PrimaryKey, value.toBool());
833 if (
"indexed" == propertyName )
834 SET_BOOLEAN_FLAG(Indexed, value.toBool());
835 if (
"autoIncrement" == propertyName
837 SET_BOOLEAN_FLAG(AutoInc, value.toBool());
838 if (
"unique" == propertyName )
839 SET_BOOLEAN_FLAG(Unique, value.toBool());
840 if (
"notNull" == propertyName )
841 SET_BOOLEAN_FLAG(NotNull, value.toBool());
842 if (
"allowEmpty" == propertyName )
843 SET_BOOLEAN_FLAG(NotEmpty, !value.toBool());
846 if (
"unsigned" == propertyName ) {
847 options |= KexiDB::Field::Unsigned;
849 options ^= KexiDB::Field::Unsigned;
850 field.setOptions( options );
854 if (
"name" == propertyName ) {
855 if (value.toString().isEmpty())
857 field.
setName( value.toString() );
860 if (
"caption" == propertyName ) {
864 if (
"description" == propertyName ) {
868 if (
"length" == propertyName )
869 GET_INT( setLength );
870 if (
"precision" == propertyName )
871 GET_INT( setPrecision );
872 if (
"defaultValue" == propertyName ) {
876 if (
"width" == propertyName )
883 KexiDBWarn <<
"KexiDB::setFieldProperty() property \"" << propertyName <<
"\" not found!" << endl;
885#undef SET_BOOLEAN_FLAG
891 TQCString valueType = node.nodeName().latin1();
892 if (valueType.isEmpty() || valueType!=
"number") {
897 const TQString text( TQDomNode(node).toElement().text() );
898 int val = text.toInt(ok);
904 TQCString valueType = node.nodeName().latin1();
905 if (valueType!=
"string") {
910 return TQDomNode(node).toElement().text();
915 TQCString valueType = node.nodeName().latin1();
916 if (valueType.isEmpty())
918 const TQString text( TQDomNode(node).toElement().text() );
920 if (valueType ==
"string") {
923 else if (valueType ==
"cstring") {
924 return TQCString(text.latin1());
926 else if (valueType ==
"number") {
927 if (text.find(
'.')!=-1) {
928 double val = text.toDouble(&ok);
933 const int val = text.toInt(&ok);
936 const TQ_LLONG valLong = text.toLongLong(&ok);
941 else if (valueType ==
"bool") {
942 return TQVariant(text.lower()==
"true" || text==
"1");
945 KexiDBWarn <<
"loadPropertyValueFromDom(): unknown type '" << valueType <<
"'" << endl;
950 const TQString& elementName,
int value)
952 TQDomElement el( doc.createElement(elementName) );
953 parentEl.appendChild( el );
954 TQDomElement numberEl( doc.createElement(
"number") );
955 el.appendChild( numberEl );
956 numberEl.appendChild( doc.createTextNode( TQString::number(value) ) );
961 const TQString& elementName,
bool value)
963 TQDomElement el( doc.createElement(elementName) );
964 parentEl.appendChild( el );
965 TQDomElement numberEl( doc.createElement(
"bool") );
966 el.appendChild( numberEl );
967 numberEl.appendChild( doc.createTextNode(
968 value ? TQString::fromLatin1(
"true") : TQString::fromLatin1(
"false") ) );
973static KStaticDeleter< TQValueVector<TQVariant> > KexiDB_emptyValueForTypeCacheDeleter;
974TQValueVector<TQVariant> *KexiDB_emptyValueForTypeCache = 0;
978 if (!KexiDB_emptyValueForTypeCache) {
979 KexiDB_emptyValueForTypeCacheDeleter.setObject( KexiDB_emptyValueForTypeCache,
981#define ADD(t, value) (*KexiDB_emptyValueForTypeCache)[t]=value;
995 const TQVariant val( KexiDB_emptyValueForTypeCache->at(
1000 if (type==Field::Date)
1001 return TQDate::currentDate();
1002 if (type==Field::DateTime)
1003 return TQDateTime::currentDateTime();
1004 if (type==Field::Time)
1005 return TQTime::currentTime();
1007 KexiDBWarn <<
"KexiDB::emptyValueForType() no value for type "
1013static KStaticDeleter< TQValueVector<TQVariant> > KexiDB_notEmptyValueForTypeCacheDeleter;
1014TQValueVector<TQVariant> *KexiDB_notEmptyValueForTypeCache = 0;
1018 if (!KexiDB_notEmptyValueForTypeCache) {
1019 KexiDB_notEmptyValueForTypeCacheDeleter.setObject( KexiDB_notEmptyValueForTypeCache,
1021#define ADD(t, value) (*KexiDB_notEmptyValueForTypeCache)[t]=value;
1024 if (i==Field::Date || i==Field::DateTime || i==Field::Time)
1027 ADD(i, TQVariant(TQString(
"")));
1033 TQBuffer buffer( ba );
1034 buffer.open( IO_WriteOnly );
1035 TQPixmap pm(SmallIcon(
"document-new"));
1036 pm.save( &buffer,
"PNG" );
1044 const TQVariant val( KexiDB_notEmptyValueForTypeCache->at(
1049 if (type==Field::Date)
1050 return TQDate::currentDate();
1051 if (type==Field::DateTime)
1052 return TQDateTime::currentDateTime();
1053 if (type==Field::Time)
1054 return TQTime::currentTime();
1056 KexiDBWarn <<
"KexiDB::notEmptyValueForType() no value for type "
1063 const int size = array.size();
1066 int escaped_length = size*2;
1068 escaped_length += 2;
1070 escaped_length += 3;
1072 str.reserve(escaped_length);
1073 if (str.capacity() < (uint)escaped_length) {
1074 KexiDBWarn <<
"KexiDB::Driver::escapeBLOB(): no enough memory (cannot allocate "<<
1075 escaped_length<<
" chars)" << endl;
1079 str = TQString::fromLatin1(
"X'");
1081 str = TQString::fromLatin1(
"0x");
1083 str = TQString::fromLatin1(
"'");
1085 int new_length = str.length();
1090 for (
int i = 0; i < size; i++) {
1091 const unsigned char val = array[i];
1092 if (val<32 || val>=127 || val==39 || val==92) {
1093 str[new_length++] =
'\\';
1094 str[new_length++] =
'\\';
1095 str[new_length++] =
'0' + val/64;
1096 str[new_length++] =
'0' + (val % 64) / 8;
1097 str[new_length++] =
'0' + val % 8;
1100 str[new_length++] = val;
1105 for (
int i = 0; i < size; i++) {
1106 const unsigned char val = array[i];
1107 str[new_length++] = (val/16) < 10 ? (
'0'+(val/16)) : (
'A'+(val/16)-10);
1108 str[new_length++] = (val%16) < 10 ? (
'0'+(val%16)) : (
'A'+(val%16)-10);
1112 str[new_length++] =
'\'';
1120 for (
int pass=0; pass<2; pass++) {
1122 const char* s = data;
1123 const char* end = s + length;
1125 KexiDBDbg <<
"processBinaryData(): real size == " << output << endl;
1126 array.resize(output);
1129 for (
int input=0; s < end; output++) {
1131 if (s[0]==
'\\' && (s+1)<end) {
1135 array[output] =
'\'';
1138 else if (s[1]==
'\\') {
1140 array[output] =
'\\';
1143 else if ((input+3)<length) {
1145 array[output] = char( (
int(s[1]-
'0')*8+
int(s[2]-
'0'))*8+
int(s[3]-
'0') );
1149 KexiDBDrvWarn <<
"processBinaryData(): no octal value after backslash" << endl;
1155 array[output] = s[0];
1166 if (v.type()==TQVariant::ByteArray)
1168 return v.toString();
1177 if (TQVariant::Invalid==type) {
1181 if (type==TQVariant::ByteArray) {
1182 const uint len = s.length();
1183 TQByteArray ba(len/2 + len%2);
1184 for (uint i=0; i<(len-1); i+=2) {
1185 int c = s.mid(i,2).toInt(&ok, 16);
1187 KexiDBWarn <<
"KexiDB::stringToVariant(): Error in digit " << i << endl;
1195 TQVariant result(s);
1196 if (!result.cast( type )) {
1224 minValue = (int)-0x07FFFFFFF;
1225 maxValue = (int)(0x080000000-1);
1231 KexiDBDbg << TQString(
"ROW DATA (%1 columns):").arg(rowData.count()) << endl;
1232 foreach(RowData::ConstIterator, it, rowData)
1233 KexiDBDbg <<
"- " << (*it) << endl;
1254 return i18n(
"Number");
1257 return i18n(
"Image");
1262#include "utils_p.moc"
bool savePassword
True if password should be saved to a file for the connection.
TQString caption
The caption of the connection.
TQString localSocketFileName
Name of local (named) socket file.
TQString description
The additional description for the connection.
TQString userName
Username used for the connection.
TQString password
Password used for the connection.
TQString driverName
the name of the driver that should be used to create a connection
unsigned short int port
Port used for the remote connection.
TQString hostName
Host name used for the remote connection.
bool useLocalSocketFile
True if local socket file should be used instead of TCP/IP port.
Database specific connection data, e.g. host, port.
void setFileName(const TQString &fn)
Set the filename used by the connection.
TQString fileName() const
Get the filename used by the connection.
Provides database connection, allowing queries and data modification.
TableSchema * tableSchema(int tableId)
TQString selectStatement(QuerySchema &querySchema, const TQValueList< TQVariant > ¶ms, const SelectStatementOptions &options=SelectStatementOptions()) const
QuerySchema * querySchema(int queryId)
tristate querySingleNumber(const TQString &sql, int &number, uint column=0, bool addLimitTo1=true)
bool useTemporaryDatabaseIfNeeded(TQString &tmpdbName)
tristate querySingleRecord(const TQString &sql, RowData &data, bool addLimitTo1=true)
bool connect()
Connects to driver with given parameters.
Provides database cursor functionality.
Database driver management, e.g. finding and loading drivers.
Driver * driver(const TQString &name)
Generic database abstraction.
TQString escapeIdentifier(const TQString &str, int options=EscapeDriver|EscapeAsNecessary) const
Driver-specific identifier escaping (e.g. for a table name, db name, etc.)
Connection * createConnection(ConnectionData &conn_data, int options=0)
TQString typeName() const
bool isAutoIncrementAllowed() const
void setName(const TQString &name)
void setDescription(const TQString &description)
void setCaption(const TQString &caption)
void setVisibleDecimalPlaces(int p)
TQString typeString() const
void setConstraints(uint c)
void setPrecision(uint p)
void setDefaultValue(const TQVariant &def)
bool isFPNumericType() const
bool isIntegerType() const
void setCustomProperty(const TQCString &propertyName, const TQVariant &value)
Sets value value for custom property propertyName.
bool isNumericType() const
TypeGroup typeGroup() const
virtual TableSchema * table() const
static TQString typeGroupName(uint typeGroup)
Provides information about lookup field's setup.
static bool setProperty(LookupFieldSchema &lookup, const TQCString &propertyName, const TQVariant &value)
virtual TQString serverResultName()
TQString msgTitle() const
virtual TQString serverErrorMsg()
virtual int serverResult()
const TQString recentSQLString() const
int previousServerResult() const
const TQString & errorMsg() const
Helper class that assigns additional information for the column in a query.
KexiDB::QuerySchema provides information about database query.
virtual TQString debugString()
Connection * connection() const
virtual Field * field(const TQString &name, bool expanded=true)
@ Default
All fields are returned even if duplicated.
@ Unique
Unique list of fields is returned.
QueryColumnInfo::Vector fieldsExpanded(FieldsExpandedOptions options=Default)
QueryColumnInfo * columnInfo(const TQString &identifier, bool expanded=true)
TQString desc
error message and detailed description, both empty by default
TableSchema * m_table
and we still want name() and acptionOrName() work.
TQCString m_name
the name is kept here because m_table and m_table can be 0
Field * field(const TQString &name)
QueryColumnInfo * columnInfo(const TQString &name)
const QueryColumnInfo::Vector columns(bool unique=false)
QuerySchema * query() const
TableSchema * table() const
Connection * connection() const
TableOrQuerySchema(Connection *conn, const TQCString &name)
TQString captionOrName() const
Connection * connection() const
LookupFieldSchema * lookupFieldSchema(const Field &field) const
TQString debugString(bool includeTableName)
bool setLookupFieldSchema(const TQString &fieldName, LookupFieldSchema *lookupFieldSchema)
High-level database connectivity library with database backend drivers.
KEXI_DB_EXPORT TQDomElement saveBooleanElementToDom(TQDomDocument &doc, TQDomElement &parentEl, const TQString &elementName, bool value)
KEXI_DB_EXPORT bool isDefaultValueAllowed(Field *field)
KEXI_DB_EXPORT TQVariant stringToVariant(const TQString &s, TQVariant::Type type, bool &ok)
KEXI_DB_EXPORT void connectionTestDialog(TQWidget *parent, const ConnectionData &data, MessageHandler &msgHandler)
KEXI_DB_EXPORT bool supportsVisibleDecimalPlacesProperty(Field::Type type)
KEXI_DB_EXPORT TQVariant emptyValueForType(Field::Type type)
KEXI_DB_EXPORT TQString simplifiedTypeName(const Field &field)
int rowCount(Connection &conn, const TQString &sql)
KEXI_DB_EXPORT Field::Type maximumForIntegerTypes(Field::Type t1, Field::Type t2)
KEXI_DB_EXPORT TQStringList typeStringsForGroup(Field::TypeGroup typeGroup)
KEXI_DB_EXPORT TQVariant loadPropertyValueFromDom(const TQDomNode &node)
KEXI_DB_EXPORT TQVariant notEmptyValueForType(Field::Type type)
KEXI_DB_EXPORT TQString escapeBLOB(const TQByteArray &array, BLOBEscapingType type)
KEXI_DB_EXPORT bool setFieldProperty(Field &field, const TQCString &propertyName, const TQVariant &value)
KEXI_DB_EXPORT bool isBuiltinTableFieldProperty(const TQCString &propertyName)
KEXI_DB_EXPORT Field::Type intToFieldType(int type)
KEXI_DB_EXPORT void fromMap(const TQMap< TQString, TQString > &map, ConnectionData &data)
KEXI_DB_EXPORT bool isExtendedTableFieldProperty(const TQCString &propertyName)
TQValueVector< TQVariant > RowData
structure for storing single record with type information
KEXI_DB_EXPORT TQStringList typeNamesForGroup(Field::TypeGroup typeGroup)
KEXI_DB_EXPORT const TypeGroupList typesForGroup(Field::TypeGroup typeGroup)
KEXI_DB_EXPORT bool setFieldProperties(Field &field, const TQMap< TQCString, TQVariant > &values)
KEXI_DB_EXPORT TQString loadStringPropertyValueFromDom(const TQDomNode &node, bool *ok)
KEXI_DB_EXPORT TQMap< TQString, TQString > toMap(const ConnectionData &data)
KEXI_DB_EXPORT int loadIntPropertyValueFromDom(const TQDomNode &node, bool *ok)
KEXI_DB_EXPORT int fieldCount(TableOrQuerySchema &tableOrQuery)
KEXI_DB_EXPORT TQString formatNumberForVisibleDecimalPlaces(double value, int decimalPlaces)
KEXI_DB_EXPORT TQString variantToString(const TQVariant &v)
KEXI_DB_EXPORT TQByteArray pgsqlByteaToByteArray(const char *data, int length)
BLOBEscapingType
Escaping types used in escapeBLOB().
@ BLOBEscapeXHex
escaping like X'1FAD', used by sqlite (hex numbers)
@ BLOBEscapeOctal
escaping like 'zk\000$x', used by pgsql
@ BLOBEscape0xHex
escaping like 0x1FAD, used by mysql (hex numbers)
@ BLOBEscapeHex
escaping like 1FAD without quotes or prefixes
KEXI_DB_EXPORT bool splitToTableAndFieldParts(const TQString &string, TQString &tableName, TQString &fieldName, SplitToTableAndFieldPartsOptions option=FailIfNoTableOrFieldName)
KEXI_DB_EXPORT void getLimitsForType(Field::Type type, int &minValue, int &maxValue)
KEXI_DB_EXPORT int idForObjectName(Connection &conn, const TQString &objName, int objType)
KEXI_DB_EXPORT void debugRowData(const RowData &rowData)
KEXI_DB_EXPORT TQDomElement saveNumberElementToDom(TQDomDocument &doc, TQDomElement &parentEl, const TQString &elementName, int value)
SplitToTableAndFieldPartsOptions
Used in splitToTableAndFieldParts().
@ SetFieldNameIfNoTableName
see splitToTableAndFieldParts()
KEXI_DB_EXPORT void getHTMLErrorMesage(Object *obj, TQString &msg, TQString &details)
KEXI_DB_EXPORT Field::Type defaultTypeForGroup(Field::TypeGroup typeGroup)