Sql.postgres has a quote() method that just does replace. For ancient postgresql versions, that's as good as it gets. For newer versions, Postgres.postgres has a quote() method that is preferable.
How can I check for Postgres.postgres()->quote in Sql.postgres to see wether or not to use Sql.postgres()->quote? Or do I need to move the pure pike quote() method into Postgres.postgres?
Adam
Do you have an instance of Postgres.prostgres()? In that case just do
if(obj->quote) return obj->quote(...); else old method ... ;
Ok, it's a runtime check, but it should be fine.
On Mon, 29 May 2006 20:00:02 +0000 (UTC) "Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
Do you have an instance of Postgres.prostgres()?
No, its inherited, but it would still work. Or I was thinking I could rename quote to simple_quote and have a function pointer called quote. Then have the constructor check for ::quote, and point quote to the right method. Does that sound reasonable?
Adam
Hm, no, I don't see how you would be able to "check for ::quote". Either you use ::quote in your code, in which case you'll get a compilation error if it doesn't exist, or you don't, in which case you can't check for it...
You could overload `[] and simply not define quote in Sql.postgres at all, but that would be rather disgusting. :-9
On Mon, 29 May 2006 20:25:05 +0000 (UTC) "Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
Hm, no, I don't see how you would be able to "check for ::quote". Either you use ::quote in your code, in which case you'll get a compilation error if it doesn't exist, or you don't, in which case you can't check for it...
Ok, how's this sound?
Sql.postgres has simple_quote() Postgres.postgres has good_quote()
Sql.postgres looks something like this:
inherit Postgres.postgres; function quote; static void create(mixed ... args) { if (this->good_quote) quote = this->good_quote; else quote = simple_quote; ::create(@args); }
From a quick test class, that seems to work.
Adam
Yes, as long as the function you export from Postgres.postgres and the function you export from Sql.postgres have different names, there is no problem.
If Postgres.postgres()->quote() doesn't need any state from the postgres object, you could move it to a module function, i.e. Postgres.quote(). That would make things easier.
If Postgres.postgres()->quote() doesn't need any state from the postgres object, you could move it to a module function, i.e. Postgres.quote(). That would make things easier.
Do you have an instance of Postgres.prostgres()? In that case just do
if(obj->quote) return obj->quote(...); else old method ... ;
Ok, it's a runtime check, but it should be fine.
Do you have an instance of Postgres.prostgres()? In that case just do
if(obj->quote) return obj->quote(...); else old method ... ;
Ok, it's a runtime check, but it should be fine.
Do you have an instance of Postgres.prostgres()? In that case just do
if(obj->quote) return obj->quote(...); else old method ... ;
Ok, it's a runtime check, but it should be fine.
Do you have an instance of Postgres.prostgres()? In that case just do
if(obj->quote) return obj->quote(...); else old method ... ;
Ok, it's a runtime check, but it should be fine.
Do you have an instance of Postgres.prostgres()? In that case just do
if(obj->quote) return obj->quote(...); else old method ... ;
Ok, it's a runtime check, but it should be fine.
pike-devel@lists.lysator.liu.se