harelba / q

q - Run SQL directly on delimited files and multi-file sqlite databases
http://harelba.github.io/q/
GNU General Public License v3.0
10.15k stars 419 forks source link

Literal 'From' in WHERE clause misparsed #275

Open allanstreib opened 2 years ago

allanstreib commented 2 years ago
echo  "a,b\nTraveling From Abroad,To Home" | q -H -d, "select * from - where a = 'Traveling From Abroad'"

produces the reponse "No files matching 'Abroad'' have been found"

Workaround

echo  "a,b\nTraveling From Abroad,To Home" | q -H -d, "select * from - where a like 'Traveling%Abroad'"

produces the (correct) response "Traveling From Abroad,To Home"

bitti commented 2 years ago

I think you miss the -e option for echo, but in fact the input doesn't matter so much to reproduce the bug (which it seems to be).

allanstreib commented 2 years ago

Yes, you may need that. On my platform (OpenBSD/ksh) it is the default behavior.

Oblomov commented 2 years ago

That's why you use printf instead of echo, avoids these ambiguities ;-)

harelba commented 2 years ago

Hi, sorry for the late response. I'm focused on packaging in order to release a new major version 3.0.0 with lots of big changes.

I'll dive into this right after the release is done.

Regardless, after this release, the next step would be to finally have a proper AST parsing mechanism for the SQL parsing, that will mitigate such issues.