ActiveRecord patchset (introducing features such as postgres schema support)

Hi.

Our company is currently working on a large government contract to develop an elearning system using Ruby on Rails. To support our needs, we have added numerous useful features to ActiveRecord over the past year or so; they include things such as proper support for PostgreSQL schemas, saving binary data in PostgreSQL (currently broken as of Rails 2.1), SQL reflection for stored procedures, calling stored procedures using ActiveRecord, support for serializing (to_xml or to_json) objects of multiple classes into the same array... Now, my employer is seriously considering allocating person-hours for us to work with the Rails core team to get our patches included in trunk.

We believe our changes to be quite useful, and consider it only fair that we should give back to the community around this great project. The question is, whether you would be interested in helping us with this process, and including this functionality.

Thanks, I'll look forward to your replies, Adam

Hi Adam,

We'd love to work with you guys to merge your patches. Do you have a github fork where we can peruse the changes?

Best, jeremy

Hi again,

We don’t have a public fork right now, and it will take some time for things to get moving in the company. I’m sorry about this process, I need to show my superiors that there’s interest on your side for them to green-light the budget for this. I’ll make sure to post back here as soon the person-hours budget is approved and we can work out what would work best.

Thanks for your interest, I look forward to working with you guys.

Adam

Hello yet again,

I'm permitted by my superiors to go ahead, but I am going to have to do work on this alone, so things may not go as fast as I'd intended. Nevertheless, I have prepared the first patch that I would like to show to you, and find out what you would have me fix, add, or change. Due to the fact that I am only one person, and cannot possibly hope to prepare the entirety of our repository (nor am I allowed to) for your review in reasonable time, I'm going to have to submit individual patches. Unless you want me to do otherwise, I'm going to stick with the normal patch review process, and have, for now, submitted the first version of this patch here: #888 Add SQL methods to models - Ruby on Rails - rails.

I would appreciate it, if you could review it and let me know what to change.

Cheers, Adam

We have also done some work extending the rails postgresql adapter for a legacy database. Specifically, to support postgresql DDL commands in ruby code. Currently it supports dumping and creating database functions, database trigger functions, user defined database types, and creating (not dumping by default) database views.

We created it as a monkey patch plugin for the rails schema_dumper and postgresql_adapter and it has worked nicely for us from Rails 1.2.6 to Rails 2.1. The rubyforge site is http://rubyforge.org/projects/railspgprocs/.

I should mention we'd be interested in getting these additions added to the core postgresql adapter if there is a possibility of that. Although I wouldn't want to step on any toes either. We'd be happy to collaborate with Adam and Co. on this also, seeing as he brought it up.

Nice code :slight_smile: What versions of pg does it work with?

jeremy

I just want to say, good work. :slight_smile: I've tried to use Rails with PostgreSQL some time ago and I ran into all sorts of issues. Hopefully these changes will get included in time.

Care to elaborate on the issues?

I'm not aware of any issues with using Postgresql with Rails like one would use Mysql, but ofcourse the more advanced Postgresql features aren't supported by Rails. This sometimes means that for schema one needs to use the :sql format and one also needs to write custom SQL to access certain features, but I wouldn't call those issues, just lack of niceties.

Certain features, as you're probably aware of, like foreign key migrations/dumping, are provided by the Redhill on Rails plugins: http://www.redhillonrails.org/index.html

This works on PostgreSQL versions 8.0-8.2