{"id":8699612,"date":"2017-01-26T00:37:55","date_gmt":"2017-01-26T00:37:55","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/database-errors-46\/"},"modified":"2017-01-26T00:37:55","modified_gmt":"2017-01-26T00:37:55","slug":"database-errors-46","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/database-errors-46\/","title":{"rendered":"Database errors"},"content":{"rendered":"<p>I&#8217;m getting a number of database errors from this plugin. Here are two of the recent unique errors:<\/p>\n<p><code>WordPress database error Unknown column &#039;post_type&#039; in &#039;where clause&#039; for query SELECT wp_comments.* FROM wp_comments  WHERE comment_post_ID = &#039;3149&#039; AND comment_approved = &#039;1&#039; AND post_type != &#039;ticket&#039;  ORDER BY comment_date_gmt DESC LIMIT 10 made by require(&#039;wp-blog-header.php&#039;), wp, WP-&gt;main, WP-&gt;query_posts, WP_Query-&gt;query, WP_Query-&gt;get_posts<\/code><br \/>\nIt looks like <code>wats_filter_comments_rss<\/code> is appending a where clause without knowing what&#8217;s being queried. In the case of the error, we&#8217;re querying the comments table, not the posts table.<\/p>\n<p><code>WordPress database error Unknown column &#039;wp_comments.comment_date_gmt&#039; in &#039;where clause&#039; for query SELECT  wp1.comment_ID FROM wp_comments  AS wp1 LEFT JOIN wp_posts AS wp3 ON wp1.comment_post_id = wp3.ID WHERE ( wp1.comment_approved = &#039;1&#039; ) AND wp1.comment_post_ID = 39282  AND ( \\n  wp_comments.comment_date_gmt &lt; &#039;2017-01-25 22:30:12&#039;\\n) AND wp3.post_status = &#039;publish&#039; AND NOT EXISTS (SELECT * FROM wp_commentmeta AS wp2 WHERE wp1.comment_ID = wp2.comment_id AND wp2.meta_key = &#039;wats_internal_update&#039; AND wp2.meta_value = 1)   ORDER BY wp1.comment_date_gmt DESC  made by require(&#039;wp-blog-header.php&#039;), require_once(&#039;wp-includes\/template-loader.php&#039;), do_feed, do_action(&#039;do_feed_rss2&#039;), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, do_feed_rss2, load_template, require_once(&#039;wp-includes\/feed-rss2-comments.php&#039;), comment_link, get_comment_link, get_page_of_comment, WP_Comment_Query-&gt;query, WP_Comment_Query-&gt;get_comments, WP_Comment_Query-&gt;get_comment_ids<\/code><br \/>\nIt looks like there&#8217;s some code to replace <code>wp_comments.comment_date_gmt<\/code> with <code>wp1.comment_date_gmt<\/code>, but it&#8217;s not catching this query.<\/p>\n<p>Note: I&#8217;m using version 1.0.61 of Wats Premium.<\/p>\n","protected":false},"template":"","class_list":["post-8699612","topic","type-topic","status-publish","hentry","topic-tag-database","topic-tag-where"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8699612","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8699612\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=8699612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}