| | | 1 | | using Microsoft.EntityFrameworkCore; |
| | | 2 | | using Npgsql; |
| | | 3 | | |
| | | 4 | | namespace Anichron.Testing.Data; |
| | | 5 | | |
| | | 6 | | public static class DatabaseErrors |
| | | 7 | | { |
| | | 8 | | public static DbUpdateException UniqueViolation(string? constraintName = null) |
| | 51 | 9 | | => Violation(PostgresErrorCodes.UniqueViolation, constraintName); |
| | | 10 | | |
| | | 11 | | // PostgresException.ConstraintName has no setter, so only the full constructor can set it. |
| | | 12 | | public static DbUpdateException Violation(string sqlState, string? constraintName = null) |
| | 58 | 13 | | => new("duplicate key", new PostgresException( |
| | 58 | 14 | | "duplicate key", "ERROR", "ERROR", sqlState, |
| | 58 | 15 | | null, null, 0, 0, null, null, null, null, null, null, |
| | 58 | 16 | | constraintName, null, null, null)); |
| | | 17 | | } |