#80 Fix bug that breaks "tg-admin sql status"

closed-accepted
Oleg Broytman
None
5
2007-01-10
2006-12-11
Paul Johnston
No

I was unable to get "tg-admin sql status" to work; I've attached the exception at the bottom.

The problem is that in sqlbuilder.py, in the function sqlIdentifier, it does a check like 'type(obj) is type("")'. In this case the object in unicode, which incorrectly causes a failure. The fix is to replace the check with isinstance(obj, basestring).

C:\tsrweb>tg-admin sql status
Using database URI mssql://pythonweb:mdi*2mdO1@./giitr
Traceback (most recent call last):
File "c:\python24\scripts\tg-admin-script.py", line 7, in ?
sys.exit(
File "c:\python24\lib\site-packages\TurboGears-1.0b2-py2.4.egg\turbogears\comm
and\base.py", line 358, in main
command.run()
File "c:\python24\lib\site-packages\TurboGears-1.0b2-py2.4.egg\turbogears\comm
and\base.py", line 144, in run
command.the_runner.run(sys.argv)
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\manage
r\command.py", line 102, in run
runner.run()
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\manage
r\command.py", line 233, in run
self.command()
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\manage
r\command.py", line 663, in command
col = col.withClass(soClass)
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py
", line 410, in withClass
extra_vars=self._extra_vars,
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py
", line 558, in __init__
super(SOUnicodeCol, self).__init__(**kw)
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py
", line 439, in __init__
super(SOStringLikeCol, self).__init__(**kw)
File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py
", line 143, in __init__
assert sqlbuilder.sqlIdentifier(name), 'Name must be SQL-safe (letters, numb
ers, underscores): %s (or use forceDBName=True)' \ AssertionError: Name must be SQL-safe (letters, numbers, underscores): u'capword
' (or use forceDBName=True)

Discussion

  • Paul Johnston
    Paul Johnston
    2006-12-12

    Logged In: YES
    user_id=1051055
    Originator: YES

    After discussion on the list, here's an alternative patch.
    File Added: mssqlconnection.py.patch

     
  • Oleg Broytman
    Oleg Broytman
    2007-01-10

    Logged In: YES
    user_id=4799
    Originator: NO

    Applied to all branches (0.7, 0.8, trunk) in the revisions 2183-2186. Thank you!

     
  • Oleg Broytman
    Oleg Broytman
    2007-01-10

    • assigned_to: nobody --> phd
    • status: open --> closed-accepted