[Twisted-Python] twisted.news adbapi backend
I'm guessing this has never been used (at least with pyPgSQL, anyway), since it has a function listRequest defined thusly: def listRequest(self): # COALESCE may not be totally portable # it is shorthand for # CASE WHEN (first parameter) IS NOT NULL then (first parameter) ELSE (second parameter) END sql = """ SELECT groups.name, COALESCE(MAX(postings.article_index), 0), COALESCE(MIN(postings.article_index), 0), groups.flags FROM groups LEFT OUTER JOIN postings ON postings.group_id = groups.group_id GROUP BY groups.name, groups.flags ORDER BY groups.name """ return self.runQuery(sql) ... but PostgreSQL doesn't implement a COALESCE command. And my next guess would be that it's never been tested, either. Correct? If so, maybe it should be either be fixed or jettisoned, or at least relegated to the sandbox. - Steve.
On Thu, Sep 25, 2003 at 10:55:01PM -0400, Stephen C. Waterbury wrote:
[snip]
... but PostgreSQL doesn't implement a COALESCE command.
Indeed. I developed it while I was still using MySQL. I was surprised to read that PostgreSQL doesn't implement COALESCE, so I checked the docs. They claim it has been supported since 6.5. Are you running an expecially old version? :)
And my next guess would be that it's never been tested, either. Correct?
Probably not. I certainly haven't, and the unit test coverage for this backend is non-existent. I was tempted to remove it a long time ago, but decided to leave it in in case anyone wanted to build on top of it. It's probably not great database code. Deprecating it now and removing it in a while sounds like a good idea. Jp -- Python/C/Linux/Smalltalk/Java Genetic Algorithms, Genetic Programming, Neural Networks Networking, asynchronous applications, legacy maintenance See my complete resume at http://intarweb.us:8080/
Hi Jp, Jp Calderone wrote:
On Thu, Sep 25, 2003 at 10:55:01PM -0400, Stephen C. Waterbury wrote:
Hm ... you mean I should actually check to see if it works before assuming it's not there? Doh! I was going by the fact that the psql \h didn't have anything on it, but you're absolutely right -- it's there and works as advertised. (I guess \h only documents the big, top-level commands -- not functions/expressions.)
It's probably not great database code. Deprecating it now and removing it in a while sounds like a good idea.
I don't think it looks bad, really ... just seemed like it had never been used. Actually, the only reason I was looking at it was that it was the only example I could find of code that used the adbapi runInteraction() and transaction stuff, so it looked like it might be useful to me at first, but I couldn't figure out how to get a Transaction to do a "SET CONSTRAINTS ALL DEFERRED", which I need for my transactions. (I did it in the transaction.execute(), but it didn't seem to have any effect, so I wasn't sure if it really applied ... I assume they are supposed to, for a given runInteraction scope, right?) Anyway, I went ahead and made a "transaction builder" that puts together a whole SQL transaction statement that I can give to runOperation, and that seems to work just fine -- which might actually be easier and faster anyway, since it lets PostgreSQL do its own optimization things, etc. Still, the adbapi transaction stuff is intriguing, so let me know if I'm missing something there -- e.g., if you know how to use it to do an SQL transaction with deferred constraints. What I was hoping it did was incrementally execute stuff and just commit when the runInteraction call ended. Cheers, Steve.
Il ven, 2003-09-26 alle 15:36, Stephen C. Waterbury ha scritto: [snip]
you may be interested in http://cvs.initd.org/cgi-bin/viewcvs.cgi/wabba/ glade binding of data coming from a database: http://cvs.initd.org/cgi-bin/viewcvs.cgi/pox/ and an example of usage: http://cvs.initd.org/cgi-bin/viewcvs.cgi/wilma/ (official release in the near future...) -- Federico Di Gregorio Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org Gli avvoltoi cinesi si nutrono di arte, ma possono anche mangiare i `domani'. -- Haruki Murakami
participants (3)
-
Federico Di Gregorio
-
Jp Calderone
-
Stephen C. Waterbury