Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#11913 closed enhancement (fixed)

Remove use of deprecated get_read_db

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.1.4
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Replaced use of deprecated Environment.get_read_db() with transaction context manager db_query.

API Changes:

Description

There are numerous uses of Environment.get_read_db in the codebase, including the tests.

./trac/ticket/query.py:        db = self.env.get_read_db()
./trac/ticket/query.py:            db = self.env.get_read_db()
./trac/ticket/report.py:            return self.env.get_read_db().concat(*parts)
./trac/ticket/tests/query.py:          'cast_priority': self.env.get_read_db().cast('priority.value', 'int')})
./trac/ticket/tests/query.py:          'cast_priority': self.env.get_read_db().cast('priority.value', 'int')})
./trac/ticket/tests/query.py:          'cast_priority': self.env.get_read_db().cast('priority.value', 'int')})
./trac/ticket/tests/query.py:ORDER BY COALESCE(t.id,0)=0,t.id""" % {'like': self.env.get_read_db().like()})
./trac/ticket/tests/query.py:ORDER BY COALESCE(t.id,0)=0,t.id""" % {'like': self.env.get_read_db().like()})
./trac/ticket/tests/query.py:ORDER BY COALESCE(t.id,0)=0,t.id""" % {'like': self.env.get_read_db().like()})
./trac/ticket/tests/query.py:ORDER BY COALESCE(t.id,0)=0,t.id""" % {'like': self.env.get_read_db().like()})
./trac/ticket/tests/query.py:        foo = self.env.get_read_db().quote('foo')
./trac/ticket/tests/query.py:        foo = self.env.get_read_db().quote('foo')
./trac/ticket/tests/query.py:ORDER BY COALESCE(t.id,0)=0,t.id""" % {'like': self.env.get_read_db().like()})
./trac/ticket/tests/query.py:          'cast_time': self.env.get_read_db().cast('t.time', 'int64')})
./trac/ticket/tests/query.py:          'cast_time': self.env.get_read_db().cast('t.time', 'int64')})
./trac/ticket/tests/query.py:          'cast_time': self.env.get_read_db().cast('t.time', 'int64')})
./trac/ticket/tests/query.py:          'cast_time': self.env.get_read_db().cast('t.time', 'int64')})
./trac/ticket/tests/query.py:          'cast_changetime': self.env.get_read_db().cast('t.changetime', 'int64')})
./trac/ticket/tests/query.py:ORDER BY COALESCE(t.id,0)=0,t.id""" % {'like': self.env.get_read_db().like()})
./trac/ticket/tests/report.py:        self.assertEqual(self.env.get_read_db().concat("''", '%s', "''"), sql)
./trac/ticket/tests/report.py:        db = self.env.get_read_db()
./trac/upgrades/db18.py:        """ % env.get_read_db().cast('s2.var_value', 'int'))
./trac/upgrades/db25.py:    db = env.get_read_db()
./trac/upgrades/db21.py:    owner = env.get_read_db().concat('owner', "' *'")
./trac/db/tests/api.py:        db = self.env.get_read_db()
./trac/db/tests/api.py:        db = self.env.get_read_db()
./trac/db/tests/api.py:            db = self.env.get_read_db()
./trac/versioncontrol/cache.py:        db = self.env.get_read_db()

Attachments (0)

Change History (5)

comment:1 by Ryan J Ollos, 5 years ago

Owner: set to Ryan J Ollos
Release Notes: modified (diff)
Status: newassigned

comment:2 by Ryan J Ollos, 5 years ago

Release Notes: modified (diff)

Proposed changes in log:rjollos.git:t11913-remove-uses-of-get_read_db. I'll do some testing of the upgrade steps before committing the changes.

comment:3 by Jun Omae, 5 years ago

Looks good with except Python 2.5.

...
  File "/run/shm/fec2da7c66c70ef9a77310655463753dfa67fa4a/py25-sqlite/trac/ticket/tests/__init__.py", line 18, in <module>
    from trac.ticket.tests import api, model, query, wikisyntax, notification, \
  File "/run/shm/fec2da7c66c70ef9a77310655463753dfa67fa4a/py25-sqlite/trac/ticket/tests/query.py", line 104
    with self.env.db_query as db:
            ^
SyntaxError: invalid syntax
make: *** [unit-test] Error 1

comment:4 by Ryan J Ollos, 5 years ago

Milestone: 1.0.41.1.4

Thanks for spotting that issue. I'll apply the changes to the trunk instead.

comment:5 by Ryan J Ollos, 5 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [13669:13670] (sorry for the ugly changes, I got distracted while doing the cherry-pick and forgot to run the tests).

Last edited 5 years ago by Ryan J Ollos (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.