Skip to content

Commit

Permalink
fix: correct regex mappings for duplicate and foreign key errors (#266)
Browse files Browse the repository at this point in the history
Swap the variable names for DUPLICATE_KEY_REGEXES and FOREIGN_KEY_REGEXES to correctly match their contents. This ensures that the error detection for duplicate keys and foreign key violations works as intended across different database backends.

Signed-off-by: Noam Stolero <[email protected]>
  • Loading branch information
Noam Stolero authored Oct 22, 2024
1 parent 4bf2489 commit 2b5e103
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions advanced_alchemy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from advanced_alchemy.utils.deprecation import deprecated

FOREIGN_KEY_REGEXES = {
DUPLICATE_KEY_REGEXES = {
"postgresql": [
re.compile(
r"^.*duplicate\s+key.*\"(?P<columns>[^\"]+)\"\s*\n.*Key\s+\((?P<key>.*)\)=\((?P<value>.*)\)\s+already\s+exists.*$",
Expand All @@ -33,7 +33,7 @@
"cockroach": [],
}

DUPLICATE_KEY_REGEXES = {
FOREIGN_KEY_REGEXES = {
"postgresql": [
re.compile(
r".*on table \"(?P<table>[^\"]+)\" violates "
Expand Down

0 comments on commit 2b5e103

Please sign in to comment.