Running the typo blog engine on PostgreSQL
If you're running the Typo blog engine on PostgreSQL (like we're doing with this site) you'll hit this problem when you try to delete all spam comments that have been posted to your blog. This bug is fixed in Git with this commit:
+++ app/controllers/admin/feedback_controller.rb 2009-08-17 16:15:56.000000000 -0500
@@ -142,7 +142,7 @@
def delete_all_spam
if request.post?
- Feedback.delete_all('state in ("presumed_spam", "spam")')
+ Feedback.delete_all(['state in (?,?)', "presumed_spam", "spam"])
flash[:notice] = _("All spam have been deleted")
end
end
The problem is that PostgreSQL uses single quotes to delimit strings, and the solution is to use ActiveRecord's interpolation rather than manually building the IN clause. There's a potential performance gain as well since the call stack winds its way through the ActiveRecord code until it gets to the ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.quote_string method, which calls the native method PQescapeStringConn provided by the underlying PostgreSQL driver. Fast!
So, note to application developers - if you want your Rails app to be portable to different database engines, use the ActiveRecord helpers so that the individual database adapters can properly build the raw SQL statement.
More generally regarding Typo, I've run a couple of blogs on Typo+PostgreSQL and things are working well... it's a good combination.
Oh, and also, first post!
Trackbacks
Use the following link to trackback from your own site:
http://railsonpostgresql.com/trackbacks?article_id=4


