FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by bobr2k » Wed Apr 30, 2008 10:46 am

I was checking some shipping conditions - I set up a multiple shipping locations condition, printed it out, then did not follow up by closing out the order or backing out and I'm throwing an exception ... yesterday we saw a similar problem - we cleared the cart database and resolved the problem. That one had a valid reason: Items in the cart for a product with options, removed the options without clearing the database.

Today I'm getting this:
INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'ac_Warehouses_ac_BasketShipments_FK1'. The conflict occurred in database '{StoreName}', table 'ac_Warehouses', column 'WarehouseId'. The statement has been terminated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'ac_Warehouses_ac_BasketShipments_FK1'. The conflict occurred in database '{StoreName}', table 'ac_Warehouses', column 'WarehouseId'. The statement has been terminated.
I can get to other pages but when I do anything related to add cart, or view cart the message reoccurs. Is there a way to reset the cart without having to call my database guy? Could this be a bug?
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by bobr2k » Wed Apr 30, 2008 11:07 am

I believe it's a bug. I just repeated the process: added a few items to the cart, ship a couple items to multiple destinations, accepted the fedex over 21 statement, while viewing the payment page I clicked on my account, clicked on manage addresses, clicked new ...

got this:
[[ConLib:MyAddressBookPage]] INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'ac_Warehouses_ac_BasketShipments_FK1'. The conflict occurred in database '{store name}', table 'ac_Warehouses', column 'WarehouseId'. The statement has been terminated.
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by AbleMods » Thu May 01, 2008 6:44 am

Bob, by any chance have you deleted a warehouse recently?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by bobr2k » Thu May 01, 2008 12:35 pm

Yep - I had to follow the method offered here:
viewtopic.php?f=42&t=6540&p=29599&hilit ... ods#p29599
Apparently when you delete a warehouse the logic does not delete related segments which would no longer be valid before deleting the warehouse record so I had some old items and some new items in my cart (added after the warehouse change) and got to a situation where it hiccuped. I don't think a person should have to be aware of a situation like that - those segments could and probably should be deleted behind the scenes.
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by AbleMods » Thu May 01, 2008 12:56 pm

bobr2k wrote:I don't think a person should have to be aware of a situation like that - those segments could and probably should be deleted behind the scenes.
It has to do with the key constraints configured in the database. Able still has a few minor tweaks to make to get it completely cleaned up. I had the same thing happen to me with a payment method many months ago.

I would report it to Able so they can get the system more tolerant of deleted warehouses.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by bobr2k » Thu May 01, 2008 2:38 pm

I would report it to Able so they can get the system more tolerant of deleted warehouses.
consider it done! 8)
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Post by sohaib » Thu May 08, 2008 9:50 am

Although still unverified a bug has been entered in our bug database for further investigation.
Marked for 7.1

Post Reply