Skip to content

Commit

Permalink
fix meta_value compares bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ycz authored and kevinoid committed Jul 23, 2019
1 parent 3fa4370 commit f2a05dd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pg4wp/driver_pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ function pg4wp_rewrite( $sql)
// 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)/';
Expand Down

0 comments on commit f2a05dd

Please sign in to comment.