[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 11:09 AM, Jonathon Anderson wrote: I'm trying to use types.TypeDecorator to define a set of strings stored in the database as a csv list, where the empty set is stored as null. process_bind_param seems to work, as values set on the bound field seem to get entered

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
What do you mean by textual strings? Do you mean strings backed by a TEXT type, rather than a fixed-length string? Why won't that work? On Jan 23, 10:57 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 23, 2008, at 11:09 AM, Jonathon Anderson wrote: I'm trying to use types.TypeDecorator

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 3:01 PM, Jonathon Anderson wrote: What do you mean by textual strings? Do you mean strings backed by a TEXT type, rather than a fixed-length string? Why won't that work? no, i mean: result = engine.execute(select * from table) will not work with any TypeEngine or

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
Oh, no. I'm not doing any raw sql. I have (at a most basic level): things_table = Table(things, metadata, Column(id, types.Integer, primary_key=True), Column(values, StringSet, nullable=True), ) class Thing (object): pass Session.mapper(Thing, things_table) But when I do

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 4:25 PM, Jonathon Anderson wrote: Oh, no. I'm not doing any raw sql. I have (at a most basic level): things_table = Table(things, metadata, Column(id, types.Integer, primary_key=True), Column(values, StringSet, nullable=True), ) class Thing (object):

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
So, in constructing my test case, I figured out what was going on. (I'm sure this is often the case.) http://pastebin.com/m612561a6 The problem is that process_result_value is only called when actually loading values from the database, and since a session maintains an object cache for object

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Michael Bayer
On Jan 23, 2008, at 10:16 PM, Jonathon Anderson wrote: So, in constructing my test case, I figured out what was going on. (I'm sure this is often the case.) http://pastebin.com/m612561a6 The problem is that process_result_value is only called when actually loading values from the

[sqlalchemy] Re: defining a StringSet type

2008-01-23 Thread Jonathon Anderson
I understand that solution. I did say without a python property. But if that's the only real way to do it, so be it. Maybe I was just looking for an excuse to learn how to define a custom type. ;) ~jon On Jan 23, 9:56 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 23, 2008, at 10:16 PM,