Results 1 to 3 of 3
  1. #1
    Join Date
    May 2014
    Posts
    68
    Plugin Contributions
    0

    Default Update SQL error on customers_basket table

    On the file "mysql_upgrade_zencart_156.sql" while I'm upgrading my Zen Cart to 1.5.6a.
    There is one section deal with "customers_basket" table.

    Code:
    # Clean up expired prids from baskets
    #NEXT_X_ROWS_AS_ONE_COMMAND:3
    DELETE FROM customers_basket WHERE CAST(products_id AS unsigned) NOT IN (
    SELECT products_id
    FROM products WHERE products_status > 0);
    #NEXT_X_ROWS_AS_ONE_COMMAND:3
    DELETE FROM customers_basket_attributes WHERE CAST(products_id AS unsigned) NOT IN (
    SELECT products_id
    FROM products WHERE products_status > 0);
    However, this lead to SQL error of the following:

    Code:
    [22-Jan-2019 20:06:46 UTC] MySQL error 1292 encountered during zc_install:
    Truncated incorrect INTEGER value: '178:d098d2cbb96515debaa325b4732e4976'
    FROM products WHERE products_status > 0);
    ---------------
    
    
    [22-Jan-2019 20:06:46 UTC] MySQL error 1292 encountered during zc_install:
    Truncated incorrect INTEGER value: '178:d098d2cbb96515debaa325b4732e4976'
    FROM products WHERE products_status > 0);
    ---------------
    This lead to those statements skipped through and left my table with unclean baskets.
    I checked the "customers_basket" table and this is what I see.

    Click image for larger version. 

Name:	TfYwrkg.jpg 
Views:	38 
Size:	42.1 KB 
ID:	18286

    The field "products_id" stored as "text."

    Click image for larger version. 

Name:	ypKRY0M.jpg 
Views:	30 
Size:	30.5 KB 
ID:	18287

    Therefore, the cleaning was not completed.
    (This database upgrade after I removed all zero dates.)

    -PanZC2020

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Update SQL error on customers_basket table

    Quote Originally Posted by PanZC2020 View Post
    On the file "mysql_upgrade_zencart_156.sql" while I'm upgrading my Zen Cart to 1.5.6a.
    There is one section deal with "customers_basket" table.

    Code:
    # Clean up expired prids from baskets
    #NEXT_X_ROWS_AS_ONE_COMMAND:3
    DELETE FROM customers_basket WHERE CAST(products_id AS unsigned) NOT IN (
    SELECT products_id
    FROM products WHERE products_status > 0);
    #NEXT_X_ROWS_AS_ONE_COMMAND:3
    DELETE FROM customers_basket_attributes WHERE CAST(products_id AS unsigned) NOT IN (
    SELECT products_id
    FROM products WHERE products_status > 0);
    However, this lead to SQL error of the following:

    Code:
    [22-Jan-2019 20:06:46 UTC] MySQL error 1292 encountered during zc_install:
    Truncated incorrect INTEGER value: '178:d098d2cbb96515debaa325b4732e4976'
    FROM products WHERE products_status > 0);
    ---------------
    
    
    [22-Jan-2019 20:06:46 UTC] MySQL error 1292 encountered during zc_install:
    Truncated incorrect INTEGER value: '178:d098d2cbb96515debaa325b4732e4976'
    FROM products WHERE products_status > 0);
    ---------------
    This lead to those statements skipped through and left my table with unclean baskets.
    I checked the "customers_basket" table and this is what I see.

    Click image for larger version. 

Name:	TfYwrkg.jpg 
Views:	38 
Size:	42.1 KB 
ID:	18286

    The field "products_id" stored as "text."

    Click image for larger version. 

Name:	ypKRY0M.jpg 
Views:	30 
Size:	30.5 KB 
ID:	18287

    Therefore, the cleaning was not completed.
    (This database upgrade after I removed all zero dates.)

    -PanZC2020
    Looks like perhaps the following SQL may address that issue? It is untested other than knowing that if the field being searched does not include the needle that the entire field is returned which seems like would fit the described/expected condition.
    Code:
    # Clean up expired prids from baskets
    #NEXT_X_ROWS_AS_ONE_COMMAND:3
    DELETE FROM customers_basket WHERE CAST(SUBSTRING_INDEX(products_id, ":", 1) AS unsigned) NOT IN (
    SELECT products_id
    FROM products WHERE products_status > 0);
    #NEXT_X_ROWS_AS_ONE_COMMAND:3
    DELETE FROM customers_basket_attributes WHERE CAST(SUBSTRING_INDEX(products_id, ":", 1) AS unsigned) NOT IN (
    SELECT products_id
    FROM products WHERE products_status > 0);
    If this can be worked into the section that does the cast, then it would provide a result showing the numeric portion of the products_id or the products_id in whole if there were no attributes.

    I'm away from a real computer to fully suss it out, but seems to provide the necessary content to convert to an integer:

    Code:
    SUBSTRING_INDEX(products_id, ":", 1)
    Note that as "displayed" the second delete sql spans 4 lines instead of 3. I do not know why it is different. Running out of time to edit this post. Proposed revision substitutes the above substring_index for the products_id.
    Last edited by mc12345678; 23 Jan 2019 at 01:31 AM. Reason: checked again, didnt see a line break to cause 4 lines
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Update SQL error on customers_basket table

    After checking this SQL with a select statement instead of a delete statement, pull request #2113 has been submitted. Changes expected are likely to be seen at: https://github.com/zencart/zencart/pull/2113/files
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v137 SQL Table Error (table doesn't exist?)
    By plymgary1 in forum General Questions
    Replies: 14
    Last Post: 17 Feb 2012, 02:34 PM
  2. v1.2.x SQL error on product catalog after server update
    By pcontreras1 in forum General Questions
    Replies: 2
    Last Post: 2 Feb 2012, 04:33 AM
  3. SQL code needed to update products table
    By ewramos in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 22 Feb 2011, 05:30 PM
  4. Error after 5.1 SQL update.
    By akhan992 in forum Basic Configuration
    Replies: 5
    Last Post: 5 Nov 2010, 07:49 AM
  5. installing a template-uploading the sql table update
    By cudaboy71 in forum Installing on a Linux/Unix Server
    Replies: 6
    Last Post: 19 Jul 2006, 11:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR