mirasvit / module-blog

Magento 2 Blog Extension
https://mirasvit.com/magento-2-extensions/blog.html
Open Software License 3.0
67 stars 48 forks source link

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_at' cannot be null #92

Closed bartekszymanski closed 6 years ago

bartekszymanski commented 6 years ago

During create new post on fresh install. Magento ver. 2.2.2

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_at' cannot be null, query was: INSERT INTOmst_blog_post_entity(author_id,type,parent_id,created_at,updated_at) VALUES (?, ?, ?, NULL, '2018-01-21 09:37:18')

Tjitse-E commented 6 years ago

@bartekszymanski i've got the same issue here. Did you find out the cause of the error?

bartekszymanski commented 6 years ago

Take a look: https://github.com/mirasvit/module-blog/blob/92c85f8eac42e5c00176c2656942f1a659dd6f9c/Controller/Adminhtml/Post/Save.php#L82

Condition doesn't check data in $result['created_at'] so it may return wrong data in $formatter->parse($result['created_at'])

Tjitse-E commented 6 years ago

Thanks for your reply!

I've added a check in the _beforeSave method and that seems to work.