Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zend_Db_Statement_Exception: SQLSTATE[HY000]: General error: 1525 Incorrect DATETIME value #8

Open
henryhayes opened this issue Jun 4, 2023 · 2 comments

Comments

@henryhayes
Copy link

henryhayes commented Jun 4, 2023

Caused by the change in MySQL 8.0.16 documented here on StackOverflow, DATETIME column values can no longer be compared to an empty string.

Zend_Db_Statement_Exception: SQLSTATE[HY000]: General error: 1525 Incorrect DATETIME value: '', query was:

SELECT `joins`.`entity_id`, `joins`.`publish_date_store` AS `store_id`, IF (joins.publish_date IS NULL OR joins.publish_date = '', joins.publish_date_default, joins.publish_date ) AS publish_date FROM ( SELECT `e`.`entity_id`, `publish_date_default`.`value` AS `publish_date_default`, `evozon_blog_post_publish_date`.`value` AS `publish_date`, `evozon_blog_post_publish_date`.`store_id` AS `publish_date_store` FROM `evozon_blog_post_entity` AS `e` -> INNER JOIN `evozon_blog_post_entity_datetime` AS `publish_date_default` ON publish_date_default.entity_id = e.entity_id AND publish_date_default.attribute_id = '322' AND publish_date_default.store_id = 0 -> LEFT JOIN `evozon_blog_post_entity_datetime` AS `evozon_blog_post_publish_date` ON evozon_blog_post_publish_date.entity_id = e.entity_id AND evozon_blog_post_publish_date.attribute_id = '322' WHERE ( e.entity_id IN ('3'))) AS `joins`;

Evozon_Blog_Model_Resource_Indexer_UrlRewrite_Data_Source::getAttributesValue()

Investigation continues...

@henryhayes
Copy link
Author

Fix:

if (stristr($attrCode, 'date')) { $expr = new Zend_Db_Expr("IF (joins.{$attrCode} IS NULL, joins.{$attrCode}_default, joins.{$attrCode} ) AS {$attrCode}"); } else { $expr = new Zend_Db_Expr("IF (joins.{$attrCode} IS NULL OR joins.{$attrCode} = '', joins.{$attrCode}_default, joins.{$attrCode} ) AS {$attrCode}"); }
        $selectSql = $adapter->select()
            ->from(
                array('joins' => $select),
                array(
                    'entity_id' => 'joins.entity_id',
                    'store_id' => "joins.{$attrCode}_store",
                    $expr
                )
            );

henryhayes added a commit to henryhayes/magento-1-blog-extension that referenced this issue Jun 4, 2023
Fixed `Zend_Db_Expr` Evozon-PHP#8
@henryhayes
Copy link
Author

Fixed on pull request #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant