[Kexi] IDENTITY issues in Sybase

Sharan Rao sharanrao at gmail.com
Tue Jan 1 21:35:33 CET 2008


On Tuesday 01 Jan 2008 7:48:11 pm Jarosław Staniek wrote:
> 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?

Attached new patch with discussed changes.

Cheers!
 Sharan Rao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ASE-fix2
Type: text/x-diff
Size: 14987 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kexi/attachments/20080102/e91ee6de/attachment.bin 


More information about the Kexi mailing list