On Tue, Jan 19, 2016 at 1:39 PM, Jim Nasby <jim.na...@bluetreble.com> wrote:

> Is this odd quoting behavior expected? (Note difference between "'a':1"
> and "'b':'a'")
>
> ~@decina.local/53896# \set df
>> pd.DataFrame.from_dict([{'a':1,'b':'a'},{'a':2,'b':'b'}])
>> ~@decina.local/53896# \echo :df
>> pd.DataFrame.from_dict([{a:1,b:'a'},{a:2,b:'b'}])
>> ~@decina.local/53896#
>
>
​Yeah, something odds is going one here, testing on 9.3.10 Ubuntu 14.04

\set df ' " d ' " "
select :'df' => " d " "

Removing the last double-quote results in an "unterminated quoted string"
error

​Apparently the quoting rules for \set need to first be discovered and then
added to the documentation.​

\set df alpha'beta'delta => alphabetadelta
\set df "alpha'beta'delta" => "alpha'beta'delta"

So adding double-quotes causes the rest of the content to be considered
literally but unfortunately the double-quotes themselves become part of the
value.  Single-quotes by themselves get paired up and removed.

​[testing some more]

*Got It!*

Its the colon that is allowing the single-quotes around the "value" to
remain.  PostgreSQL read " :'a' " and sees a variable that it might need to
resolve - and when it cannot it simply leaves the variable name reference​
in place.

​If not for the colon all of the single-quotes would have been removed as
delimiters.

I still think some improvement and or outright fixes could be made here but
am going to leave it here for now.

David J.

Reply via email to