Menu

#1 Not handling required fields

open
nobody
None
5
2009-04-07
2009-04-07
Nurhat Uca
No

Hi Michael,
First of all, thank you for redistributing this code. It is really very useful tool.
I will write some improvements and bugs below.

/***********************************************************************/
->handling required fields. Changed following functions in records.cpp

RecordBase::RecordBase(const QString& table, quint32 fieldCount) :
_table(table), _xmlDoc(NULL)
{
_recordData.resize(fieldCount);

for (quint32 i(0); i < fieldCount; i++)
{
if (i == 0)
{
_recordData[i]._type = eInteger;
_recordData[i]._value = QVariant((quint32) 0);
}
else
{
_recordData[i]._type = eString;
//_recordData[i]._value = QVariant();//do not initialize
}

_recordData[i]._changed = false;
}
}
void RecordBase::SetFieldDataType(quint32 index, const QString& fieldName,
ColumnType type)
{
_recordData[index]._field = fieldName;
_recordData[index]._type = type;
if(index==0)//set id
{
_recordData[index]._value = 0;
}

/*
//donot initialize data
switch (type)
{
case eInteger:
_recordData[index]._value = 0;
break;

case eDateTime:
_recordData[index]._value = QDateTime::currentDateTime();
break;

case eDate:
_recordData[index]._value = QDate::currentDate();
break;

case eTime:
_recordData[index]._value = QTime::currentTime();
break;

case eQUuid:
_recordData[index]._value = EncodeGuid(QUuid());
break;

case eReal:
_recordData[index]._value = QVariant((double) 0.0);
break;

case eBool:
_recordData[index]._value = QVariant(false);
break;

case eString:
case eUnknown:
default:
_recordData[index]._value = QVariant("");
break;
}*/
}
/***********************************************************************/
- > In a few places, you are assigning minus values to quint32. So it gives compilation warnings.
->Changed encode/decoding functions for time and date variables. I used Qt::ISODate format for handling date and time values. I think it is better than handling as TextDate.
-> I added following line to ODBCDatabase.cpp and SqliteDatabase.cpp to get rid of connection is inuse exception when closing application.
To do that we should add _database = QSqlDatabase(); before QSqlDatabase::removeDatabase(_connectionName); line.
That is all i discovered for now. If i find anything else, i will let you know.

Thanks again..
Nurhat

Nurhat

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.