[sqlalchemy] Re: nullable=False by default
But I'm supposed that the generation function of autoincrement only works when the field is NULL or there is an integer, so this fails on fields with a string empty. On Jul 7, 8:06 am, Kless [EMAIL PROTECTED] wrote: Yes, I read it. The integer columns with the primary key flag set are not being autoincremented, after of the Column subclass. On Jul 7, 3:45 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 6, 2008, at 7:06 PM, Kless wrote: I think that there is a bug. autoincrement doesn't works with *default=''* Any solution to this problem? the docs for autoincrement need to be read closely. This flag only applies to Integer columns with the primary key flag set. I'm not sure what interaction it would be expected to have with default in any case (default is all you need if you have a custom default generation function). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
On Jul 7, 2008, at 3:06 AM, Kless wrote: Yes, I read it. The integer columns with the primary key flag set are not being autoincremented, after of the Column subclass. what database ? Oracle and Firebird require a Sequence to be specified. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
On Jul 7, 2008, at 3:10 AM, Kless wrote: But I'm supposed that the generation function of autoincrement only works when the field is NULL or there is an integer, so this fails on fields with a string empty. im not sure offhand what an empty string would produce since I'd have to check what we're doing to detect no value present. But I would hope that if the string value went through, it would raise an error on the DB side (so this impies you might be using SQLite). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
Yes, it's SQLite. I use it into the development. On Jul 7, 4:06 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 7, 2008, at 3:10 AM, Kless wrote: But I'm supposed that the generation function of autoincrement only works when the field is NULL or there is an integer, so this fails on fields with a string empty. im not sure offhand what an empty string would produce since I'd have to check what we're doing to detect no value present. But I would hope that if the string value went through, it would raise an error on the DB side (so this impies you might be using SQLite). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
then its probably inserting your blank string into the column. SQLA doesn't want to get too much in the way of the natural features of the database in use. On Jul 7, 2008, at 11:09 AM, Kless wrote: Yes, it's SQLite. I use it into the development. On Jul 7, 4:06 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 7, 2008, at 3:10 AM, Kless wrote: But I'm supposed that the generation function of autoincrement only works when the field is NULL or there is an integer, so this fails on fields with a string empty. im not sure offhand what an empty string would produce since I'd have to check what we're doing to detect no value present. But I would hope that if the string value went through, it would raise an error on the DB side (so this impies you might be using SQLite). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
You have reason. I checked it with MySQL and it works ok. So here I have a lesson learned: use the same RDBMS on developing. Thanks Michael. On Jul 7, 4:50 pm, Michael Bayer [EMAIL PROTECTED] wrote: then its probably inserting your blank string into the column. SQLA doesn't want to get too much in the way of the natural features of the database in use. On Jul 7, 2008, at 11:09 AM, Kless wrote: Yes, it's SQLite. I use it into the development. On Jul 7, 4:06 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jul 7, 2008, at 3:10 AM, Kless wrote: But I'm supposed that the generation function of autoincrement only works when the field is NULL or there is an integer, so this fails on fields with a string empty. im not sure offhand what an empty string would produce since I'd have to check what we're doing to detect no value present. But I would hope that if the string value went through, it would raise an error on the DB side (so this impies you might be using SQLite). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
And, why can I add 'default' -- def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) -- it shows the next error: TypeError: _FigureVisitName object got multiple values for keyword argument 'default' On Jul 6, 7:53 pm, [EMAIL PROTECTED] wrote: u can workaround by def Column0( *a,**k): return Column( nullable=False, *a,**k) and use Column0(...) instead of Column... On Sunday 06 July 2008 21:53:52 Kless wrote: Is possible create the fields with nullable=False by default? It's heavy to have to add this to each field. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
I'm using so: def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) groups_table = Table('foo', metadata, Column0('id', Integer, primary_key=True), Column0('bar', Unicode(16)), ) Note: I'm using SA 0.5 beta. But well, that solved it. Thank you very much. On Jul 6, 9:17 pm, [EMAIL PROTECTED] wrote: how are u using it? probably u have another default=? or there is a non-keyword/positional argument matching that... try something like: def Column0(*a, **k): k.setdefault('default', '') k.setdefault('nullable', False) return Column(*a, **k) thus if u dont specify it explicit, it'll be implicit there. And, why can I add 'default' -- def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) -- it shows the next error: TypeError: _FigureVisitName object got multiple values for keyword argument 'default' On Jul 6, 7:53 pm, [EMAIL PROTECTED] wrote: u can workaround by def Column0( *a,**k): return Column( nullable=False, *a,**k) and use Column0(...) instead of Column... On Sunday 06 July 2008 21:53:52 Kless wrote: Is possible create the fields with nullable=False by default? It's heavy to have to add this to each field. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
I think that there is a bug. autoincrement doesn't works with *default=''* Any solution to this problem? On Jul 6, 10:46 pm, Kless [EMAIL PROTECTED] wrote: I'm using so: def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) groups_table = Table('foo', metadata, Column0('id', Integer, primary_key=True), Column0('bar', Unicode(16)), ) Note: I'm using SA 0.5 beta. But well, that solved it. Thank you very much. On Jul 6, 9:17 pm, [EMAIL PROTECTED] wrote: how are u using it? probably u have another default=? or there is a non-keyword/positional argument matching that... try something like: def Column0(*a, **k): k.setdefault('default', '') k.setdefault('nullable', False) return Column(*a, **k) thus if u dont specify it explicit, it'll be implicit there. And, why can I add 'default' -- def Column0(*a, **k): return Column(nullable=False, default='', *a, **k) -- it shows the next error: TypeError: _FigureVisitName object got multiple values for keyword argument 'default' On Jul 6, 7:53 pm, [EMAIL PROTECTED] wrote: u can workaround by def Column0( *a,**k): return Column( nullable=False, *a,**k) and use Column0(...) instead of Column... On Sunday 06 July 2008 21:53:52 Kless wrote: Is possible create the fields with nullable=False by default? It's heavy to have to add this to each field. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: nullable=False by default
On Jul 6, 2008, at 7:06 PM, Kless wrote: I think that there is a bug. autoincrement doesn't works with *default=''* Any solution to this problem? the docs for autoincrement need to be read closely. This flag only applies to Integer columns with the primary key flag set. I'm not sure what interaction it would be expected to have with default in any case (default is all you need if you have a custom default generation function). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---