[storm] Invalid enum value on find
Oscar Campos
oscar.campos at open-phoenix.com
Fri Apr 5 07:53:45 UTC 2013
On Apr 5, 2013 4:20 AM, "James Henstridge" <james at jamesh.id.au> wrote:
>
> On Thu, Apr 4, 2013 at 6:36 AM, Oscar Campos
> <oscar.campos at open-phoenix.com> wrote:
> > El 03/04/13 22:30, Jamu Kakar escribió:
> >> Hi Oscar,
> >>
> >> Right, so you need to use an INTEGER column not an ENUM. That's how
> >> the Enum type is intended to be used.
> >>
> >> Thanks,
> >> J.
> >
> > Thank you Jamu, I will use Integer. Btw I think this should be reflected
> > in the documentation.
> >
> > One last question about this. If we have a native Enum type in MySQL why
> > don't try to use it instead of adapt integer to do the job?
>
> The Enum() type was added to handle the integer enumerations we were
> using in Launchpad. But it isn't limited to use with integer columns
> in the database.
>
> Think of the dictionary you pass to the Enum() constructor as mapping
> Python values to their corresponding SQL values. If you are using
> MySQL's enumeration column type, then the SQL values will be text
> strings, so you'd want something like:
>
> card_type = Enum(map={
> u'VISA': u'VISA', u'MC': u'MC', u'LASER': u'LASER',
> u'AMEX': u'AMEX',
> u'DINERS': u'DINERS', u'DELTA': u'DELTA', u'MAESTRO':
u'MAUSTRO'
> })
>
> Alternatively, you could use something other than strings to represent
> these values at the Python level, pick some other keys (Launchpad used
> https://launchpad.net/lazr.enum here).
>
> Alternatively, if you are happy to use strings at the Python level and
> are happy to only check values on the database side, then you could
> also use Storm's Unicode() type to represent the column.
>
> James.
Hi
Thank you for your tips. I already did the mapping with a str:str
dictionary but I am not really happy with it.
In fact I am not really happy using enumerated types in the database
because you can't compare the numeric values of the enumerated field in the
Python code at all.
I am trying to add support for Storm in an already developed application
that uses no ORM but regular MySQL driver and some problems arise because
there are several front end PHP applications that use the same data and
can't be redesigned without a lot of pain.
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/storm/attachments/20130405/4b5ad60c/attachment.html>
More information about the storm
mailing list