Search code examples
mysqldelphidelphi-xe4firedac

Faulty sha() function in FireDAC in combination with the '!' character


I am working with Delphi XE4 and have a problem with the FireDAC component (V8.0.5.3365) and the MySQL hash function sha(). For example when I use sha('testtest1!') in a normal database tool on the MySQL server, the result is

'd68c15248886d3eb551990298ab1f99db788365a'

when I use the same hash function from the FireDAC TADQuery function the result is:

'd41ff23e0e6147a8fd2722f68e53f993a92784b0'

This different output only happens when the hashed string includes an '!', otherwise the hashed string is the same. Is there something I am doing wrong??


Solution

  • I found the answer here: http://docwiki.embarcadero.com/Libraries/XE7/en/FireDAC.Stan.Option.TFDResourceOptions.MacroExpand

    The target DBMS uses '!', '&' symbols in its own SQL dialect and FireDAC cannot recognize them as an SQL construction therefore you have to go into TADQuery ResourceOptions and set MacroExpand to False then it will work.