I have the same problem right now. Seems maybe all the cases were not
covered?
I have a table 'race' that i can't load. But other tables loaded
without problem.
Code:
(Pdb) soup.meeting
<class 'sqlalchemy.ext.sqlsoup.MappedMeeting'>
(Pdb) soup.race
*** TypeError: type() argument 1 must be string, not unicode
Escaping to str the unicode value 'MappedRace' worked, but its a
hack ;)
>svn diff sqlalchemy.svn/
Index: sqlalchemy.svn/lib/sqlalchemy/ext/sqlsoup.py
===================================================================
--- sqlalchemy.svn/lib/sqlalchemy/ext/sqlsoup.py (revision
5183)
+++ sqlalchemy.svn/lib/sqlalchemy/ext/sqlsoup.py (working copy)
@@ -445,6 +445,8 @@
selectable = expression._selectable(selectable)
mapname = 'Mapped' + _selectable_name(selectable)
if isinstance(selectable, Table):
+ if isinstance(mapname, unicode):
+ mapname = str(mapname)
klass = TableClassType(mapname, (object,), {})
else:
klass = SelectableClassType(mapname, (object,), {})
Code:
(Pdb) soup.race
*** TypeError: type() argument 1 must be string, not unicode
(Pdb) soup.race
<class 'sqlalchemy.ext.sqlsoup.MappedRace'>
So, what is the right way io fix that issue?
On Jul 13 2007, 4:29 pm, bbull <[EMAIL PROTECTED]> wrote:
> The latest trunk seems to have fixed this issue.
>
> Thanks
>
> On Jul 12, 6:22 pm, jason kirtland <[EMAIL PROTECTED]> wrote:
>
> > bbull wrote:
> > > I have some code that returns what I'm calling a table object.
>
> > > return getattr(self.dbc, tablename)
>
> > > where self.dbc is an SqlSoup object and tablename is the name of the
> > > table.
>
> > > [..]
> > > TypeError: type() argument 1 must be string, not unicode
>
> > > For some reason, the line "mapname = 'Mapped' +
> > > _selectable_name(selectable)" in sqlsoup.py creates a unicode object
> > > instead of a string object when 'entity' is passed in. If I put a
> > > simple str() around the code ("mapname = str('Mapped' +
> > > _selectable_name(selectable))"), it works with no problem.
>
> > > Any reason why only this one particular case would cause this problem?
>
> > Try that again with the latest from trunk.
>
> > -j
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---