Skip to content

Conversation

Denis74RUS
Copy link
Contributor

Hello David!

I found the issue when we try to use MATCH AGAINST statements (fulltext search) in the query.
For example this query string:
SELECT ... WHERE MATCH(column) AGAINST('searchString' IN BOOLEAN MODE) ...
... converts into:
SELECT ... WHERE MATCH(column) AGAINST() 'searchString' ...
We can see that 'IN BOOLEAN MODE' disappears and AGAINST params are placed after the function.

It happens because of:

  • PHPSQLParser returns 3 nodes for the current query (MATCH, AGAINST and AGAINST params) and MagicQuery just put them one by one in the result string;
[
  { "expr_type": "function", "base_expr": "MATCH", "sub_tree": ... } , 
  { "expr_type": "function", "base_expr": "AGAINST", "no_quotes": ...}, 
  { "expr_type": "match-arguments", "base_expr": "(:serachString IN BOOLEAN MODE)", ...} 
]
  • MagicQuery parses ExpressionType::MATCH_MODE as a Expression object and not like a ConstNode object and as a result misses it somewhere.

I wrote patch for solving this problem and added the test, please look at it and let me know what do you think of it. Maybe you see how to resolve this issue another way ?

Thank you in advance!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 67.907% when pulling 9379f84 on Denis74RUS:feature/fix-match-against into ba91d80 on thecodingmachine:1.2.

@moufmouf
Copy link
Member

Hi Denis,

Thanks a lot for this PR (and thanks for adding a test :) )

I wrote patch for solving this problem and added the test, please look at it and let me know what do you think of it. Maybe you see how to resolve this issue another way ?

I've had a look at your patch. I understand that it works and indeed, the "simplify" method looks a bit clunky but I could not find a better way than what you have done. I'm not aware of any other SQL functions that behave like MATCH AGAINST, so I guess there is no need to invent a complete concept just for this use case.

Thanks a lot for the fix, I'm merging this!

@moufmouf moufmouf merged commit a6efcac into thecodingmachine:1.2 Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants