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
=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py 2009-12-10 10:31:16 +0000
+++ bin/osv/orm.py 2009-12-16 17:09:13 +0000
@@ -1842,7 +1842,8 @@
1842 if not hasattr(self, "_auto") or self._auto:1842 if not hasattr(self, "_auto") or self._auto:
1843 cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)1843 cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)
1844 if not cr.rowcount:1844 if not cr.rowcount:
1845 cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITH OIDS" % self._table)1845 cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS" % self._table)
1846 cr.execute("COMMENT ON TABLE \"%s\" IS '%s'" % (self._table, self._description.replace("'","''")))
1846 create = True1847 create = True
1847 cr.commit()1848 cr.commit()
1848 if self._parent_store:1849 if self._parent_store:
@@ -1904,9 +1905,10 @@
1904 ref = self.pool.get(f._obj)._table1905 ref = self.pool.get(f._obj)._table
1905 except AttributeError:1906 except AttributeError:
1906 ref = f._obj.replace('.', '_')1907 ref = f._obj.replace('.', '_')
1907 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))1908 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))
1908 cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id1, f._rel, f._id1))1909 cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id1, f._rel, f._id1))
1909 cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id2, f._rel, f._id2))1910 cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (f._rel, f._id2, f._rel, f._id2))
1911 cr.execute("COMMENT ON TABLE \"%s\" IS 'RELATION BETWEEN %s AND %s'" % (f._rel, self._table, ref))
1910 cr.commit()1912 cr.commit()
1911 else:1913 else:
1912 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 " \1914 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 " \
@@ -1935,6 +1937,7 @@
19351937
1936 # add the missing field1938 # add the missing field
1937 cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))1939 cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, get_pg_type(f)[1]))
1940 cr.execute("COMMENT ON COLUMN %s.%s IS '%s'" % (self._table, k, f.string.replace("'","''")))
19381941
1939 # initialize it1942 # initialize it
1940 if not create and k in self._defaults:1943 if not create and k in self._defaults: