|
1 | | -# $Id: rdbms_common.py,v 1.71 2003-11-16 18:41:40 jlgijsbers Exp $ |
| 1 | +# $Id: rdbms_common.py,v 1.72 2003-12-05 09:47:46 richard Exp $ |
2 | 2 | ''' Relational database (SQL) backend common code. |
3 | 3 |
|
4 | 4 | Basics: |
@@ -155,19 +155,7 @@ def post_init(self): |
155 | 155 | self.conn.commit() |
156 | 156 |
|
157 | 157 | def refresh_database(self): |
158 | | - # now detect changes in the schema |
159 | | - for classname, spec in self.classes.items(): |
160 | | - dbspec = self.database_schema[classname] |
161 | | - self.update_class(spec, dbspec, force=1) |
162 | | - self.database_schema[classname] = spec.schema() |
163 | | - # update the database version of the schema |
164 | | - self.sql('delete from schema') |
165 | | - self.save_dbschema(self.database_schema) |
166 | | - # reindex the db |
167 | | - self.reindex() |
168 | | - # commit |
169 | | - self.conn.commit() |
170 | | - |
| 158 | + self.post_init() |
171 | 159 |
|
172 | 160 | def reindex(self): |
173 | 161 | for klass in self.classes.values(): |
@@ -1800,8 +1788,8 @@ def find(self, **propspec): |
1800 | 1788 | raise TypeError, "'%s' not a Link/Multilink property"%propname |
1801 | 1789 |
|
1802 | 1790 | # first, links |
1803 | | - where = [] |
1804 | | - allvalues = () |
| 1791 | + where = ['__retired__ = %s'] |
| 1792 | + allvalues = (0,) |
1805 | 1793 | a = self.db.arg |
1806 | 1794 | for prop, values in propspec: |
1807 | 1795 | if not isinstance(props[prop], hyperdb.Link): |
@@ -1852,14 +1840,16 @@ def stringFind(self, **requirements): |
1852 | 1840 | args = [] |
1853 | 1841 | for propname in requirements.keys(): |
1854 | 1842 | prop = self.properties[propname] |
1855 | | - if isinstance(not prop, String): |
| 1843 | + if not isinstance(prop, String): |
1856 | 1844 | raise TypeError, "'%s' not a String property"%propname |
1857 | 1845 | where.append(propname) |
1858 | 1846 | args.append(requirements[propname].lower()) |
1859 | 1847 |
|
1860 | 1848 | # generate the where clause |
1861 | 1849 | s = ' and '.join(['lower(_%s)=%s'%(col, self.db.arg) for col in where]) |
1862 | | - sql = 'select id from _%s where %s'%(self.classname, s) |
| 1850 | + sql = 'select id from _%s where %s and __retired__=%s'%(self.classname, |
| 1851 | + s, self.db.arg) |
| 1852 | + args.append(0) |
1863 | 1853 | self.db.sql(sql, tuple(args)) |
1864 | 1854 | l = [x[0] for x in self.db.sql_fetchall()] |
1865 | 1855 | if __debug__: |
|
0 commit comments