SenseNet / sensenet

Open Source Content Services Platform written in .NET
https://sensenet.com
GNU General Public License v2.0
173 stars 112 forks source link

[Bug] Incremental naming does not work in a SQL environment #1708

Closed tusmester closed 2 years ago

tusmester commented 2 years ago

Repro steps

Details

This works correctly in an InMemory database, pls test it using the SQL provider! (e.g. on the daily build test repository)

When incremental naming is allowed (for example on the Memo type), the system should add a number postfix to new content items if there is already a content in the db with the same name. For example: "memo" --> "memo(1)". This should work automatically, without notifying the caller.

The feature is based on the db layer throwing a NodeAlreadyExistsException. But this is handled differently in the inmem and sql databases. The SQL provider does not recognize this exception in its overwritten GetException method and it throws a common DataException instead.

https://github.com/SenseNet/sensenet/blob/c4af55d392639a7e3ca442360bd0c5398b99b62a/src/ContentRepository.MsSql/MsSqlDataProvider.cs#L359

Result: SavingAction.Execute cannot catch the NodeAlreadyExistsException because it is an inner exception, hidden inside a data exception.

kavics commented 2 years ago

Checked on Api.Sql.Admin: works well.