Re: string = any() - Mailing list pgsql-general

From Andy Colson
Subject Re: string = any()
Date
Msg-id 4F0C652B.6040704@squeakycode.net
Whole thread Raw
In response to Re: string = any()  ("David Johnston" <polobo@yahoo.com>)
Responses Re: string = any()
List pgsql-general
> This still does not work, even in psql:
> select 'bob' = any( '{''joe'', ''bob'' }'::varchar[] )
>
>     $$ ^ This works for me just fine....though I am not using psql; are
> you having quoting issues?  What error do you get?
>

It runs, but it returns false.  I get false at least.  I'm assuming you
do to, otherwise something weird is going on.



> Its the same as if I try to prepare it in psql:
> clayia=# prepare x as select 'bob' = any($1::varchar[]); PREPARE
> Time: 1.884 ms
> clayia=# execute x( 'string_to_array(''joe,bob'', '','')' );
>
>     $$ ^ Why do you have single-quotes surrounding "string_to_array";
> the EXECUTE now sees the entire literal 'string_to_array....' as a single
> scalar value and thus does not resolve the function call into an array.

Because it simulates how php is actually running the function.  I
prepare the statement, and pass it a string.

execute x( 'string_to_array(''joe,bob'', '','')' );

That simulates pass a single string.  It also results in the same
error's that php is getting... so I just assumed I was testing it correct.

Without the string works fine... but that's not how php works.
execute x( string_to_array('joe,bob', ',') );

You should have the same problem in java, if you:
q = databaseFactory.queryFactory.prepare("select 'bob' =
any($1::varchar[])");

:-) just kidding

Then when you execute it, you have to pass the argument as a string:
q.execute("{'joe','bob'}");


yeah, I'm thinking the execute param step is not running the param
through the entire parse/analyze/whatnot step, so I cannot use functions.

Eh, well, the input is from a website, so wanted to use prepared queries
as much as possible, but I'll just pg_escape all the strings and cat
them all into the sql statement itself.

Ok, nevermind, just got Tom's email.  Double Quotes...

Thanks for the help,

-Andy

pgsql-general by date:

Previous
From: Andy Colson
Date:
Subject: Re: string = any()
Next
From: "David Johnston"
Date:
Subject: Re: string = any()