Merge lp:~syleam/openobject-server/trunk-postgresql-comment-oids into lp:openobject-server

Proposed by Christophe CHAUVET
Status: Merged
Merged at revision: not available
Proposed branch: lp:~syleam/openobject-server/trunk-postgresql-comment-oids
Merge into: lp:openobject-server
Diff against target: 33 lines (+5/-2)
1 file modified
bin/osv/orm.py (+5/-2)
To merge this branch: bzr merge lp:~syleam/openobject-server/trunk-postgresql-comment-oids
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+16253@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

Add comment on table based from _description
Add comment on column based from label field
On CREATE TABLE not used OIDS (deprecate since PostgreSQL 8.0)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/osv/orm.py'
2--- bin/osv/orm.py 2009-12-10 10:31:16 +0000
3+++ bin/osv/orm.py 2009-12-16 17:09:13 +0000
4@@ -1842,7 +1842,8 @@
5 if not hasattr(self, "_auto") or self._auto:
6 cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)
7 if not cr.rowcount:
8- cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITH OIDS" % self._table)
9+ cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS" % self._table)
10+ cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'","''")))
11 create = True
12 cr.commit()
13 if self._parent_store:
14@@ -1904,9 +1905,10 @@
15 ref = self.pool.get(f._obj)._table
16 except AttributeError:
17 ref = f._obj.replace('.', '_')
18- cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE, "%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE) WITH OIDS' % (f._rel, f._id1, self._table, f._id2, ref))
19+ cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE, "%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE) WITHOUT OIDS' % (f._rel, f._id1, self._table, f._id2, ref))
20 cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id1, f._rel, f._id1))
21 cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id2, f._rel, f._id2))
22+ cr.execute("COMMENT ON TABLE \"%s\" IS 'RELATION BETWEEN %s AND %s'" % (f._rel, self._table, ref))
23 cr.commit()
24 else:
25 cr.execute("SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size " \
26@@ -1935,6 +1937,7 @@
27
28 # add the missing field
29 cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))
30+ cr.execute("COMMENT ON COLUMN %s.%s IS '%s'" % (self._table, k, f.string.replace("'","''")))
31
32 # initialize it
33 if not create and k in self._defaults: