sensenet
sensenet copied to clipboard
[Bug] Incremental naming does not work in a SQL environment
Repro steps
- create a Memo
- try to create another, with the same name --> the system should create a new one with a postfix: mymemo (2)
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.
Checked on Api.Sql.Admin: works well.