terrymanu commented on issue #18763:
URL: 
https://github.com/apache/shardingsphere/issues/18763#issuecomment-3636751520

   ##  Issue Understanding
   
     - On ShardingSphere-Proxy 5.1.2 (read/write splitting only, MySQL driver 
8.0.28) a SELECT fails with This version of ShardingSphere-Proxy doesn't yet 
support this SQL. 'You have an error in your SQL syntax'.
     - SQL shown: SELECT knowledgename, knowledgecontent FROM Academic WHERE 
knowledgename LIKE "%"? "%"; user says direct MySQL seems fine.
   
   ##  Root Cause
   
     - The SQL is syntactically invalid: LIKE "%"? "%" puts % as string 
literals and inserts ? between them, which is not valid SQL. The parser 
therefore throws a syntax error.
     - Per ShardingSphere usage, wildcard characters for LIKE must come from 
the parameter value itself or be concatenated in SQL, not written as "%"? "%".
   
   ##  Analysis
   
     - Same pattern as #17888: a SQL syntax error, not a missing Proxy feature.
     - Correct forms:
         - WHERE knowledgename LIKE CONCAT('%', ?, '%') (parameter without %), 
or
         - WHERE knowledgename LIKE ? with the parameter value %keyword%.
     - Read/write splitting routing does not affect syntax; the same prepared 
SQL sent directly to MySQL would also fail.
   
   ##  Conclusion
   
     - This is a SQL writing issue, not a ShardingSphere bug.
     - Fix the mapper LIKE clause to a standard prepared form (parameter 
carries %, or use CONCAT/CONCAT_WS to add wildcards) and avoid the "%"? "%" 
pattern.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to