Closed darryllee closed 3 years ago
@darryllee thanks for reporting this.
This is indeed a crazy one :)
The root reason for this is the fact that sqlite (the engine behind q) handles double-quoted strings as identifiers first, and only then falls back to a string literal.
Converting the queries to use single-quotes for string literals forces sqlite to treat them as string-literals:
$ q -H -d ',' "select space,id from ./example.csv where id not in ('sysadmin','admin')"
AAPM,darryl
AD,joe
ADV,space-admin
AE,marty
$ q -H -d ',' "select space,id from ./example.csv where id='admin'"
ADSKB,admin
AEE,admin
$
Notice that the string-literals are surrounded by single-quotes, and for convenience, the entire query is double-quoted and not single-quoted.
The reference to sqlite's docs about this subject - https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
Ahhh.
Thank you! And more generally, thank you for q. It is truly a game-changer for a lot of work I've been doing lately!!
On Sun, Jun 6, 2021 at 1:06 AM Harel Ben-Attia @.***> wrote:
The reference to sqlite's docs about this subject - https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/harelba/q/issues/260#issuecomment-855357851, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANODJXDZE64ANJD2LZXNFLTRMUBDANCNFSM46EHV2EA .
--
--Darryl Lee @.***>
Problem was driving me crazy until I realized what it was and I worked around it by renaming the Admin column to Administrator:
example.csv:
% q -H -d ',' 'select space,id from ./example.csv where id not in ("sysadmin","admin")'
Even a simple query comes up empty:
q -H -d ',' 'select space,id from ./example.csv where id="admin"'
Fully quoted CSV has the same issue.