[Kexi] IDENTITY issues in Sybase
Jarosław Staniek
js at iidea.pl
Tue Jan 1 15:18:11 CET 2008
Sharan Rao said the following, On 2007-12-31 22:07:
> Reviewing the code again, is passing only FieldList object enough ?
> The tablename can be obtained from one of the fields in the FieldList.
> But this would also lead to calculation of the tableName from the
> FieldList object three times in most insertRecord() functions.
> 1. Normal calculation in insertRecord()
> 2. in drv_beforeInsert()
> 3. in drv_afterInsert()
Sharan, thanks for the patch; it's mostly OK.
First note, could you please change spaces to tabs in the indentation?
(even if we plan to switch to spaces soon I hope)
* Move Connection::drv_beforeInsert(), etc. to the header file for efficiency.
You'll need to put Q_UNUSED(table);, etc. there to avoid warnings about
unused args.
* Check results of calling these methods, i.e.
if (!drv_beforeInsert(...))
return false;
* commit cursor.cpp change (removal of my commentout) as a separate checkin.
* In SybaseConnection::drv_beforeInsert() you could put instead:
+bool KexiDB::SybaseConnection::drv_beforeInsert( const QString& table,
FieldList& fields )
+{
+
+ if ( fields.autoIncrementFields()->isEmpty() )
+ return true;
// explicit insertion into IDENTITY fields !!
return drv_executeSQL( QString::fromLatin1( "SET IDENTITY_INSERT %1 ON"
).arg( table ) );
+}
Same for other 3 methods.
BTW, don't we need escape the table name?
--
regards / pozdrawiam, Jaroslaw Staniek
Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
KDE Libraries for MS Windows (http://windows.kde.org)
More information about the Kexi
mailing list