File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1515use Closure ;
1616use Doctrine \DBAL \Driver \PDO \SQLite \Driver ;
1717use Doctrine \DBAL \Driver \PDO \SQLite \Driver as DoctrineDriver ;
18+ use Exception ;
1819use Hyperf \Database \Connection ;
1920use Hyperf \Database \Query \Grammars \Grammar as HyperfQueryGrammar ;
2021use Hyperf \Database \Query \Processors \Processor ;
@@ -65,6 +66,16 @@ public function getSchemaBuilder(): SchemaBuilder
6566 return new SQLiteBuilder ($ this );
6667 }
6768
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+
6879 /**
6980 * Get the default query grammar instance.
7081 *
You can’t perform that action at this time.
0 commit comments