in reply to Can I tell if DBI's quote() was used?

No, it's not possible. Specifically,

For example, foo bar clearly needs quoting, but "foo bar" could be foo bar already quoted or "foo bar" that hasn't been quoted.

quote should only be used where a string literal is expected, so NULL is indeed a special case. Then again, it should *already* be a special case cause string literals are usually used with "=" and NULL is usually used with "IS". See the "NULL Values" subsection of the "Placeholders and Bind Values" section of the DBI docs.

You should be more worried about numbers than about NULL.

Replies are listed 'Best First'.
Re^2: Can I tell if DBI's quote() was used?
by kyle (Abbot) on Apr 06, 2008 at 19:44 UTC

    "foo bar" could be foo bar already quoted or "foo bar" that hasn't been quoted.

    That's a good point I hadn't thought of. I'm not sure how much I'm worried about that, though. If SQL will consider it a literal (and not a syntax error or someone's SQL injection attack), that may be close enough. Then again, maybe not.

    You should be more worried about numbers than about NULL.

    Why's that?

      Because NULL must already be handled specially. (Then again, giving the problem you have, that might be assuming too much.) OTOH, one needs to know whether the SQL statement is expecting a string literal or a numerical literal to know whether 5 should be 5 or "5". Or maybe 5 will always do, but you still need to special case that.