File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 15
15
use Closure ;
16
16
use Doctrine \DBAL \Driver \PDO \SQLite \Driver ;
17
17
use Doctrine \DBAL \Driver \PDO \SQLite \Driver as DoctrineDriver ;
18
+ use Exception ;
18
19
use Hyperf \Database \Connection ;
19
20
use Hyperf \Database \Query \Grammars \Grammar as HyperfQueryGrammar ;
20
21
use Hyperf \Database \Query \Processors \Processor ;
@@ -65,6 +66,16 @@ public function getSchemaBuilder(): SchemaBuilder
65
66
return new SQLiteBuilder ($ this );
66
67
}
67
68
69
+ /**
70
+ * Determine if the given database exception was caused by a unique constraint violation.
71
+ *
72
+ * @return bool
73
+ */
74
+ protected function isUniqueConstraintError (Exception $ exception )
75
+ {
76
+ return boolval (preg_match ('#(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)#i ' , $ exception ->getMessage ()));
77
+ }
78
+
68
79
/**
69
80
* Get the default query grammar instance.
70
81
*
You can’t perform that action at this time.
0 commit comments