mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-13 13:37:20 +00:00
do not match in pre/postfix of empty fields
Empty fields where pre and postfixed just as any other field. When searching for a string that matched a pre/postfix all empty fields where returned because the pre/postfix matched.
This commit is contained in:
@ -21,7 +21,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'', // postfix
|
'', // postfix
|
||||||
'=', // comp
|
'=', // comp
|
||||||
'val', // value
|
'val', // value
|
||||||
'(T.col = ?)', // expect sql
|
'((T.col != \'\' AND T.col = ?))', // expect sql
|
||||||
array('val'), // expect opts
|
array('val'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -29,7 +29,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'', // postfix
|
'', // postfix
|
||||||
'=', // comp
|
'=', // comp
|
||||||
'val', // value
|
'val', // value
|
||||||
'(? || T.col = ?)', // expect sql
|
'((T.col != \'\' AND ? || T.col = ?))', // expect sql
|
||||||
array('before', 'val'), // expect opts
|
array('before', 'val'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -37,7 +37,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'=', // comp
|
'=', // comp
|
||||||
'val', // value
|
'val', // value
|
||||||
'(T.col || ? = ?)', // expect sql
|
'((T.col != \'\' AND T.col || ? = ?))', // expect sql
|
||||||
array('after', 'val'), // expect opts
|
array('after', 'val'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -45,7 +45,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'=', // comp
|
'=', // comp
|
||||||
'val', // value
|
'val', // value
|
||||||
'(? || T.col || ? = ?)', // expect sql
|
'((T.col != \'\' AND ? || T.col || ? = ?))', // expect sql
|
||||||
array('before', 'after', 'val'), // expect opts
|
array('before', 'after', 'val'), // expect opts
|
||||||
),
|
),
|
||||||
// LIKE
|
// LIKE
|
||||||
@ -54,7 +54,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'', // postfix
|
'', // postfix
|
||||||
'LIKE', // comp
|
'LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(T.col LIKE ?)', // expect sql
|
'((T.col != \'\' AND T.col LIKE ?))', // expect sql
|
||||||
array('%val%'), // expect opts
|
array('%val%'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -62,7 +62,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'', // postfix
|
'', // postfix
|
||||||
'LIKE', // comp
|
'LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(? || T.col LIKE ?)', // expect sql
|
'((T.col != \'\' AND ? || T.col LIKE ?))', // expect sql
|
||||||
array('before','%val%'), // expect opts
|
array('before','%val%'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -70,7 +70,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'LIKE', // comp
|
'LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(T.col || ? LIKE ?)', // expect sql
|
'((T.col != \'\' AND T.col || ? LIKE ?))', // expect sql
|
||||||
array('after','%val%'), // expect opts
|
array('after','%val%'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -78,7 +78,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'LIKE', // comp
|
'LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(? || T.col || ? LIKE ?)', // expect sql
|
'((T.col != \'\' AND ? || T.col || ? LIKE ?))', // expect sql
|
||||||
array('before','after','%val%'), // expect opts
|
array('before','after','%val%'), // expect opts
|
||||||
),
|
),
|
||||||
// NOT LIKE
|
// NOT LIKE
|
||||||
@ -87,7 +87,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'', // postfix
|
'', // postfix
|
||||||
'NOT LIKE', // comp
|
'NOT LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(T.col NOT LIKE ?)', // expect sql
|
'((T.col != \'\' AND T.col NOT LIKE ?))', // expect sql
|
||||||
array('%val%'), // expect opts
|
array('%val%'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -95,7 +95,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'', // postfix
|
'', // postfix
|
||||||
'NOT LIKE', // comp
|
'NOT LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(? || T.col NOT LIKE ?)', // expect sql
|
'((T.col != \'\' AND ? || T.col NOT LIKE ?))', // expect sql
|
||||||
array('before','%val%'), // expect opts
|
array('before','%val%'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -103,7 +103,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'NOT LIKE', // comp
|
'NOT LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(T.col || ? NOT LIKE ?)', // expect sql
|
'((T.col != \'\' AND T.col || ? NOT LIKE ?))', // expect sql
|
||||||
array('after','%val%'), // expect opts
|
array('after','%val%'), // expect opts
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -111,7 +111,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'NOT LIKE', // comp
|
'NOT LIKE', // comp
|
||||||
'%val%', // value
|
'%val%', // value
|
||||||
'(? || T.col || ? NOT LIKE ?)', // expect sql
|
'((T.col != \'\' AND ? || T.col || ? NOT LIKE ?))', // expect sql
|
||||||
array('before','after','%val%'), // expect opts
|
array('before','after','%val%'), // expect opts
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class Type_Text_struct_test extends StructTest {
|
|||||||
'after', // postfix
|
'after', // postfix
|
||||||
'NOT LIKE', // comp
|
'NOT LIKE', // comp
|
||||||
array('%val1%', '%val2%'), // multiple values
|
array('%val1%', '%val2%'), // multiple values
|
||||||
'((? || T.col || ? NOT LIKE ? OR ? || T.col || ? NOT LIKE ?))', // expect sql
|
'((T.col != \'\' AND (? || T.col || ? NOT LIKE ? OR ? || T.col || ? NOT LIKE ?)))', // expect sql
|
||||||
array('before','after','%val1%', 'before','after','%val2%',), // expect opts
|
array('before','after','%val1%', 'before','after','%val2%',), // expect opts
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -35,6 +35,10 @@ class Text extends AbstractMultiBaseType {
|
|||||||
* @param string $op
|
* @param string $op
|
||||||
*/
|
*/
|
||||||
public function filter(QueryBuilderWhere $add, $tablealias, $colname, $comp, $value, $op) {
|
public function filter(QueryBuilderWhere $add, $tablealias, $colname, $comp, $value, $op) {
|
||||||
|
$add = $add->where($op); // open a subgroup
|
||||||
|
$add->where('AND', "$tablealias.$colname != ''"); // make sure the field isn't empty
|
||||||
|
$op = 'AND';
|
||||||
|
|
||||||
/** @var QueryBuilderWhere $add Where additionional queries are added to */
|
/** @var QueryBuilderWhere $add Where additionional queries are added to */
|
||||||
if(is_array($value)) {
|
if(is_array($value)) {
|
||||||
$add = $add->where($op); // sub where group
|
$add = $add->where($op); // sub where group
|
||||||
|
Reference in New Issue
Block a user