fix meta_value compares bug

This commit is contained in:
ycz
2019-07-23 17:16:03 +08:00
committed by Kevin Locke
parent 3fa4370b37
commit f2a05dddbe

View File

@ -534,6 +534,10 @@
// WP 2.9.1 uses a comparison where text data is not quoted
$pattern = '/AND meta_value = (-?\d+)/';
$sql = preg_replace( $pattern, 'AND meta_value = \'$1\'', $sql);
// Add type cast for meta_value field when it's compared to number
$pattern = '/AND meta_value < (\d+)/';
$sql = preg_replace($pattern, 'AND meta_value::bigint < $1', $sql);
// Generic "INTERVAL xx YEAR|MONTH|DAY|HOUR|MINUTE|SECOND" handler
$pattern = '/INTERVAL[ ]+(\d+)[ ]+(YEAR|MONTH|DAY|HOUR|MINUTE|SECOND)/';