ActiveRecord with only a primary key

Hi,

ActiveRecord does not currently support tables that have only a primary key.

This seems to be a needed feature as evidenced by the tickets: http://dev.rubyonrails.org/ticket/6187 http://dev.rubyonrails.org/ticket/6319 http://dev.rubyonrails.org/ticket/7877

The update case is easily fixed by just not running the query when there are no columns to update. But the create case is problematic because different databases need different queries for inserting a row while not providing any actual values.

Mysql (as always) is the most liberal, it accepts:

-- AC currently generates this so with mysql it is actually -- possible to create an activerecord with only a primary key -- (updating however does not yet work) INSERT INTO table () VALUES();

INSERT INTO table VALUES(); INSERT INTO table VALUES(NULL); INSERT INTO table VALUES(DEFAULT); INSERT INTO table (id) VALUES(NULL); INSERT INTO table (id) VALUES(DEFAULT);

Sqlite does not support the "DEFAULT" syntax and it also does not like "VALUES()", it works with:

INSERT INTO table VALUES(NULL); INSERT INTO table (id) VALUES(NULL);

Postgresql on the other hand interprets NULL a bit differently, it does not fill the column with a default value when NULL is used so the result is a not-null constraint violation. Postgresql only works with:

INSERT INTO table VALUES(DEFAULT); INSERT INTO table (id) VALUES(DEFAULT);

So I think that either an insert_blank method needs to be added to the database adapters which is used when a row needs to be created but there are no actual attributes, or the insert method needs a condition to cover this edge case.

I'd like to implement this, but I'd first like to know which approach (if any) I should take.

Thank you,