<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 1: Not handling required fields</title><link href="https://sourceforge.net/p/qsqlcodegen/bugs/1/" rel="alternate"/><link href="https://sourceforge.net/p/qsqlcodegen/bugs/1/feed.atom" rel="self"/><id>https://sourceforge.net/p/qsqlcodegen/bugs/1/</id><updated>2009-04-07T11:22:39Z</updated><subtitle>Recent changes to 1: Not handling required fields</subtitle><entry><title>Not handling required fields</title><link href="https://sourceforge.net/p/qsqlcodegen/bugs/1/" rel="alternate"/><published>2009-04-07T11:22:39Z</published><updated>2009-04-07T11:22:39Z</updated><author><name>Nurhat Uca</name><uri>https://sourceforge.net/u/nurhatuca/</uri></author><id>https://sourceforge.nete53341aba25292c47a9f03296671f85676ae3d2e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Michael,&lt;br /&gt;
First of all, thank you for redistributing this code.  It is really very useful tool. &lt;br /&gt;
I will write some improvements and bugs below.&lt;/p&gt;
&lt;p&gt;/***********************************************************************/&lt;br /&gt;
-&amp;gt;handling required fields. Changed following functions in records.cpp&lt;/p&gt;
&lt;p&gt;RecordBase::RecordBase(const QString&amp;amp; table, quint32 fieldCount) :&lt;br /&gt;
_table(table), _xmlDoc(NULL)&lt;br /&gt;
{&lt;br /&gt;
_recordData.resize(fieldCount);&lt;/p&gt;
&lt;p&gt;for (quint32 i(0); i &amp;lt; fieldCount; i++)&lt;br /&gt;
{&lt;br /&gt;
if (i == 0)&lt;br /&gt;
{&lt;br /&gt;
_recordData[i]._type = eInteger;&lt;br /&gt;
_recordData[i]._value = QVariant((quint32) 0);&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
_recordData[i]._type = eString;&lt;br /&gt;
//_recordData[i]._value = QVariant();//do not initialize&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;_recordData[i]._changed = false;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
void RecordBase::SetFieldDataType(quint32 index, const QString&amp;amp; fieldName,&lt;br /&gt;
ColumnType type)&lt;br /&gt;
{&lt;br /&gt;
_recordData[index]._field = fieldName;&lt;br /&gt;
_recordData[index]._type = type;&lt;br /&gt;
if(index==0)//set id&lt;br /&gt;
{&lt;br /&gt;
_recordData[index]._value = 0;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;/*&lt;br /&gt;
//donot initialize data&lt;br /&gt;
switch (type)&lt;br /&gt;
{&lt;br /&gt;
case eInteger:&lt;br /&gt;
_recordData[index]._value = 0;&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eDateTime:&lt;br /&gt;
_recordData[index]._value = QDateTime::currentDateTime();&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eDate:&lt;br /&gt;
_recordData[index]._value = QDate::currentDate();&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eTime:&lt;br /&gt;
_recordData[index]._value = QTime::currentTime();&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eQUuid:&lt;br /&gt;
_recordData[index]._value = EncodeGuid(QUuid());&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eReal:&lt;br /&gt;
_recordData[index]._value = QVariant((double) 0.0);&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eBool:&lt;br /&gt;
_recordData[index]._value = QVariant(false);&lt;br /&gt;
break;&lt;/p&gt;
&lt;p&gt;case eString:&lt;br /&gt;
case eUnknown:&lt;br /&gt;
default:&lt;br /&gt;
_recordData[index]._value = QVariant("");&lt;br /&gt;
break;&lt;br /&gt;
}*/&lt;br /&gt;
}&lt;br /&gt;
/***********************************************************************/&lt;br /&gt;
- &amp;gt; In a few places, you are assigning minus values to quint32. So it gives compilation warnings.&lt;br /&gt;
-&amp;gt;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.&lt;br /&gt;
-&amp;gt; I added following line to ODBCDatabase.cpp and SqliteDatabase.cpp to get rid of connection is inuse exception when closing application.&lt;br /&gt;
To do that we should add _database = QSqlDatabase(); before QSqlDatabase::removeDatabase(_connectionName); line.&lt;br /&gt;
That is all i discovered for now. If i find anything else, i will let you know.&lt;/p&gt;
&lt;p&gt;Thanks again..&lt;br /&gt;
Nurhat&lt;/p&gt;
&lt;p&gt;Nurhat&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>