------------------------------------------------------------
revno: 8
committer: Andres Salomon <dilinger@athenacr.com>
branch nick: trac-sqlcolfix
timestamp: Tue 2006-02-28 16:06:21 -0500
message:
include the `sql` column rename in the db17 upgrade.
------------------------------------------------------------
revno: 7
committer: Andres Salomon <dilinger@athenacr.com>
branch nick: trac-sqlcolfix
timestamp: Tue 2006-02-28 15:57:49 -0500
message:
Rename 'sql' column in report table to 'query', so it doesn't conflict w/
mysql keyword.
=== modified file 'trac/db_default.py'
|
|
|
|
| 148 | 148 | Column('id', auto_increment=True), |
| 149 | 149 | Column('author'), |
| 150 | 150 | Column('title'), |
| 151 | | Column('sql'), |
| | 151 | Column('query'), |
| 152 | 152 | Column('description')], |
| 153 | 153 | ] |
| 154 | 154 | |
| … |
… |
|
| 379 | 379 | ('name', 'value'), |
| 380 | 380 | (('database_version', str(db_version)),)), |
| 381 | 381 | ('report', |
| 382 | | ('author', 'title', 'sql', 'description'), |
| | 382 | ('author', 'title', 'query', 'description'), |
| 383 | 383 | __mkreports(reports))) |
| 384 | 384 | |
| 385 | 385 | default_config = \ |
=== modified file 'trac/ticket/report.py'
|
|
|
|
| 148 | 148 | req.redirect(self.env.href.report()) |
| 149 | 149 | |
| 150 | 150 | title = req.args.get('title', '') |
| 151 | | sql = req.args.get('sql', '') |
| | 151 | query = req.args.get('query', '') |
| 152 | 152 | description = req.args.get('description', '') |
| 153 | 153 | cursor = db.cursor() |
| 154 | | cursor.execute("INSERT INTO report (title,sql,description) " |
| 155 | | "VALUES (%s,%s,%s)", (title, sql, description)) |
| | 154 | cursor.execute("INSERT INTO report (title,query,description) " |
| | 155 | "VALUES (%s,%s,%s)", (title, query, description)) |
| 156 | 156 | id = db.get_last_id(cursor, 'report') |
| 157 | 157 | db.commit() |
| 158 | 158 | req.redirect(self.env.href.report(id)) |
| … |
… |
|
| 176 | 176 | |
| 177 | 177 | if not req.args.has_key('cancel'): |
| 178 | 178 | title = req.args.get('title', '') |
| 179 | | sql = req.args.get('sql', '') |
| | 179 | query = req.args.get('query', '') |
| 180 | 180 | description = req.args.get('description', '') |
| 181 | 181 | cursor = db.cursor() |
| 182 | | cursor.execute("UPDATE report SET title=%s,sql=%s,description=%s " |
| 183 | | "WHERE id=%s", (title, sql, description, id)) |
| | 182 | cursor.execute("UPDATE report SET title=%s,query=%s,description=%s " |
| | 183 | "WHERE id=%s", (title, query, description, id)) |
| 184 | 184 | db.commit() |
| 185 | 185 | req.redirect(self.env.href.report(id)) |
| 186 | 186 | |
| … |
… |
|
| 204 | 204 | def _render_editor(self, req, db, id, copy=False): |
| 205 | 205 | if id == -1: |
| 206 | 206 | req.perm.assert_permission('REPORT_CREATE') |
| 207 | | title = sql = description = '' |
| | 207 | title = query = description = '' |
| 208 | 208 | else: |
| 209 | 209 | req.perm.assert_permission('REPORT_MODIFY') |
| 210 | 210 | cursor = db.cursor() |
| 211 | | cursor.execute("SELECT title,description,sql FROM report " |
| | 211 | cursor.execute("SELECT title,description,query FROM report " |
| 212 | 212 | "WHERE id=%s", (id,)) |
| 213 | 213 | row = cursor.fetchone() |
| 214 | 214 | if not row: |
| … |
… |
|
| 216 | 216 | 'Invalid Report Number') |
| 217 | 217 | title = row[0] or '' |
| 218 | 218 | description = row[1] or '' |
| 219 | | sql = row[2] or '' |
| | 219 | query = row[2] or '' |
| 220 | 220 | |
| 221 | 221 | if copy: |
| 222 | 222 | title += ' (copy)' |
| … |
… |
|
| 233 | 233 | req.hdf['report.id'] = id |
| 234 | 234 | req.hdf['report.mode'] = 'edit' |
| 235 | 235 | req.hdf['report.title'] = title |
| 236 | | req.hdf['report.sql'] = sql |
| | 236 | req.hdf['report.sql'] = query |
| 237 | 237 | req.hdf['report.description'] = description |
| 238 | 238 | |
| 239 | 239 | def _render_view(self, req, db, id): |
| … |
… |
|
| 426 | 426 | description = 'This is a list of reports available.' |
| 427 | 427 | else: |
| 428 | 428 | cursor = db.cursor() |
| 429 | | cursor.execute("SELECT title,sql,description from report " |
| | 429 | cursor.execute("SELECT title,query,description from report " |
| 430 | 430 | "WHERE id=%s", (id,)) |
| 431 | 431 | row = cursor.fetchone() |
| 432 | 432 | if not row: |
| 433 | 433 | raise util.TracError('Report %d does not exist.' % id, |
| 434 | 434 | 'Invalid Report Number') |
| 435 | 435 | title = row[0] or '' |
| 436 | | sql = row[1] |
| | 436 | query = row[1] |
| 437 | 437 | description = row[2] or '' |
| 438 | 438 | |
| 439 | | return [title, description, sql] |
| | 439 | return [title, description, query] |
| 440 | 440 | |
| 441 | 441 | def get_var_args(self, req): |
| 442 | 442 | report_args = {} |
=== modified file 'trac/upgrades/db17.py'
|
|
|
|
| 2 | 2 | |
| 3 | 3 | def do_upgrade(env, ver, cursor): |
| 4 | 4 | """Rename the columns `kind` and `change` in the `node_change` table for |
| 5 | | compatibity with MySQL. |
| | 5 | compatibity with MySQL, as well as the `sql` column in the `reports` table. |
| 6 | 6 | """ |
| | 7 | db_connector, _ = DatabaseManager(env)._get_connector() |
| | 8 | |
| | 9 | # alter node_change table |
| 7 | 10 | cursor.execute("CREATE TEMP TABLE nc_old AS SELECT * FROM node_change") |
| 8 | 11 | cursor.execute("DROP TABLE node_change") |
| 9 | 12 | |
| … |
… |
|
| 16 | 19 | Column('base_rev'), |
| 17 | 20 | Index(['rev']) |
| 18 | 21 | ] |
| 19 | | db_connector, _ = DatabaseManager(env)._get_connector() |
| 20 | 22 | for stmt in db_connector.to_sql(table): |
| 21 | 23 | cursor.execute(stmt) |
| 22 | 24 | |
| 23 | 25 | cursor.execute("INSERT INTO node_change (rev,path,node_type,change_type," |
| 24 | 26 | "base_path,base_rev) SELECT rev,path,kind,change," |
| 25 | 27 | "base_path,base_rev FROM nc_old") |
| | 28 | |
| | 29 | # alter report table |
| | 30 | cursor.execute("CREATE TEMP TABLE report_old AS SELECT * FROM report") |
| | 31 | cursor.execute("DROP TABLE report") |
| | 32 | |
| | 33 | table = Table('report', key='id')[ |
| | 34 | Column('id', auto_increment=True), |
| | 35 | Column('author'), |
| | 36 | Column('title'), |
| | 37 | Column('query'), |
| | 38 | Column('description') |
| | 39 | ] |
| | 40 | for stmt in db_connector.to_sql(table): |
| | 41 | cursor.execute(stmt) |
| | 42 | |
| | 43 | cursor.execute("INSERT INTO report (id,author,title,query,description) " |
| | 44 | "SELECT id,author,title,sql,description FROM report_old") |