Page MenuHomePhabricator

Add a "query compiler" to convert user search queries into a form MySQL likes
ClosedPublic

Authored by epriestley on Nov 24 2016, 3:32 PM.
Tags
None
Referenced Files
F14054385: D16938.diff
Sat, Nov 16, 12:53 AM
F14043581: D16938.diff
Tue, Nov 12, 11:23 AM
F14028129: D16938.diff
Fri, Nov 8, 11:56 AM
F14007521: D16938.id40770.diff
Tue, Oct 29, 7:18 AM
F13973982: D16938.id40771.diff
Oct 18 2024, 3:32 AM
F13965129: D16938.id.diff
Oct 16 2024, 12:06 AM
Unknown Object (File)
Oct 10 2024, 4:11 AM
Unknown Object (File)
Oct 10 2024, 4:11 AM
Subscribers
None

Details

Summary

Ref T11741. Ref T10642.

By default, MySQL runs query cat dog as "cat OR dog". Users expect "cat AND dog".

For users using MySQL, we instruct them to fix this by changing ft_boolean_syntax. However:

  • You can't edit this in RDS (T10642).
  • There's no similar option for InnoDB (T11741).

Instead, we can parse the query ourselves, and submit +"cat" +"dog" to MySQL, using whatever syntax it is configured for. This will also let us simplify setup since users won't need to change this setting any more.

This just implements a parser/compiler and test cases. It does not yet change search beahvior.

Test Plan

Added and executed unit tests. Ran some of the resulting queries in MySQL to make sure it did what I was expecting.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Add a "query compiler" to convert user search queries into a form MySQL likes.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
  • Improve error message for trailing operators, by showing the operator.
  • Parse cat"dog".
  • Reject cat"dog.
chad edited edge metadata.
This revision is now accepted and ready to land.Nov 24 2016, 4:41 PM
This revision was automatically updated to reflect the committed changes.