[Nitro] [PATCH] og-psql-refactoring

Kashia Buch kashia at vfemail.net
Sun Apr 9 10:00:17 EDT 2006


Hi,

> I'd really appreciate if someone could give this a try. I'd rather
> throw away the last patch if it isn't backward compatible.

I still can't run test-suits, but I ran Oxyliquit on it.
Works like before, so, I think that covers some of the tests :D


> Postgres doesn't appear to support autoincrement, so added a new
> method to SqlStore, generate_key. Postgres uses this to generate the
> oid value to be inserted. SqlStore defines this method as returning
> NULL which allows the other stores to autoincrement. This can possibly
> be extended to allow custom key generation for all the stores.
um....

look at this:

CREATE TABLE tst (
   oid SERIAL,
   title TEXT
)

creates:

oxytest=# \d tst
                            Table "public.tst"
   Column   |  Type   |                           Modifiers
-----------+---------+----------------------------------------------------------------
  oid       | integer | not null default nextval('tst_oid_seq'::regclass)
  title     | text    |

now, when inserting:

INSERT INTO tst (oid, title) VALUES (NULL, 'asdf');
INSERT INTO tst (title) VALUES ('asdf2');
INSERT INTO tst VALUES (NULL, 'asdf3');

This is where the _default_ is jumping in.

SELECT * FROM tst;

   oid   |  title
--------+---------
  1      | asdf
  2      | asdf2
  3      | asdf3

so, SERIAL is the keyword here, and NULL gets inserted to get the next oid.

Does that clarify things?

Kashia

-- 
Feel the love
http://pinkjuice.com/pics/ruby.png



More information about the Nitro-general mailing list