Changeset 126
- Timestamp:
- 08/09/07 20:54:53
- Files:
-
- branches/ast/geniusql/objects.py (modified) (3 diffs)
- branches/ast/geniusql/select.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ast/geniusql/objects.py
r125 r126 951 951 data, _ = self.fetch(selsql) 952 952 953 output_keys = [names[0] for names in sel.output] 953 954 for row in Dataset(sel, data): 954 row = dict(zip( sel.output_keys, row))955 row = dict(zip(output_keys, row)) 955 956 # Run a dummy object through our restriction before inserting. 956 957 if not query.restriction(_ImperfectDummy(**row)): … … 959 960 newtable.insert(**row) 960 961 else: 962 qnames = [names[2] for names in sel.output] 961 963 sql = ("INSERT INTO %s (%s) %s" % 962 (newtable.qname, ", ".join( sel.output_qnames), selsql))964 (newtable.qname, ", ".join(qnames), selsql)) 963 965 self.execute(sql) 964 966 … … 997 999 # pre-fetch cols and cache in an optimal format. 998 1000 c = dataset.selector.output_cols 999 self.cols = [c[ key] for key in dataset.selector.output_keys]1001 self.cols = [c[coldata[0]] for coldata in dataset.selector.output] 1000 1002 1001 1003 def __iter__(self): branches/ast/geniusql/select.py
r125 r126 193 193 input_list: a list of SQL expressions, one for each column in the 194 194 SELECT clause. These will include any "expr AS name" alias. 195 output _names: a list of the SQL names (aliases), one per output column.196 output_qnames: a list of quoted SQL names (aliases), one per output column.197 output_keys: the keys for each column in the final table.195 output: a list of tuples of the form: 196 (column key, column, SQL name (alias), quoted SQL name (alias)) 197 One per output column. 198 198 output_cols: a dict of source cols for the final table. 199 199 """ … … 229 229 230 230 self.input_list = [] 231 self.output_names = [] 232 self.output_qnames = [] 233 self.output_keys = [] 231 self.output = [] 234 232 self.output_cols = {} 235 233 self._groupby = [] … … 269 267 """ 270 268 newtable = self.schema.table(name) 271 for colkey, name, qname in zip(self.output_keys, self.output_names, 272 self.output_qnames): 269 for colkey, name, qname in self.output: 273 270 col = self.output_cols[colkey] 274 271 newcol = col.copy() … … 308 305 selname = '%s AS %s' % (selname, colqname) 309 306 self.input_list.append(selname) 310 self.output_names.append(colname) 311 self.output_qnames.append(colqname) 312 self.output_keys.append(colkey) 307 self.output.append((colkey, colname, colqname)) 313 308 self.output_cols[colkey] = col 314 309 … … 461 456 qname = self.db.quote(atom.name) 462 457 self.input_list.append('%s AS %s' % (atom.sql, qname)) 463 self.output_keys.append(atom.name) 464 self.output_names.append(atom.name) 465 self.output_qnames.append(qname) 458 self.output.append((atom.name, atom.name, qname)) 466 459 if not atom.aggregate: 467 460 self._groupby.append(atom.sql)
