Re: [sqlalchemy] 0.8.0b Postgres Array Issue

2013-03-07 Thread Michael Bayer
Can you pass along more specifics here?  I don't see where this named tuple is 
being created.  It's true that the ARRAY type by default doesn't know how deep 
it should be unwrapping arrays, if you pass the dimensions argument then it 
will be fixed.   But it's not clear why you didn't see this issue in 0.7 as 
well, perhaps we check for a wider range of array/tuple types at this point but 
I don't recall.



On Mar 7, 2013, at 1:21 PM, Jason ja...@deadtreepages.com wrote:

 Hello,
 
 I'm using a column defined as:
 discounts = Column(ARRAY(Discount))
 
 Where Discount is a UserDefinedType that just passes the value through 
 to/from Psycopg2 (which uses a namedtuple for the discounts value):
 
 class Discount(UserDefinedType):
  SQLAlchemy type that passes through values to be handled by a psycopg2
 extension type.
 
 type_name = 'Discount'
 
 def get_col_spec(self):
 return self.type_name
 
 def bind_processor(self, dialect):
 return None
 
 def result_processor(self, dialect, coltype):
 return None
 
 def is_mutable(self):
 return True
 
 def copy_value(self, value):
 return copy.copy(value)
 
 Previously (in 0.7.9) the discounts value on a model instance would be an 
 list of discount types (which are namedtuples). Now SQLAlchemy seems to 
 convert the Discount type into a list resulting in a two-dimensional list for 
 the discounts value instead of a list of namedtuples. The documentation 
 doesn't mention this side-effect of the array improvements, is this a bug in 
 0.8.0b? 
 
 Thanks,
 
 Jason
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] 0.8.0b Postgres Array Issue

2013-03-07 Thread Jason


On Thursday, March 7, 2013 1:40:46 PM UTC-5, Michael Bayer wrote:

 Can you pass along more specifics here?  I don't see where this named 
 tuple is being created.  It's true that the ARRAY type by default doesn't 
 know how deep it should be unwrapping arrays, if you pass the dimensions 
 argument then it will be fixed.   But it's not clear why you didn't see 
 this issue in 0.7 as well, perhaps we check for a wider range of 
 array/tuple types at this point but I don't recall.



 A namedtuple is returned by Psycopg2 directly (using its 
register_composite mechanism). The result processing changed in this 
commit: 
https://bitbucket.org/sqlalchemy/sqlalchemy/commits/0ba8b4fd402f1c187b80310fc838dcdea27e0af8,
 
so I will take a look to see if I can figure out what causes the new 
behaviour. I'm guessing that it sees the namedtuple instance and figures 
that it is a tuple instance so it can be converted into a list.


--
Jason

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] 0.8.0b Postgres Array Issue

2013-03-07 Thread Michael Bayer

On Mar 7, 2013, at 2:12 PM, Jason ja...@deadtreepages.com wrote:

 
 
 On Thursday, March 7, 2013 1:40:46 PM UTC-5, Michael Bayer wrote:
 Can you pass along more specifics here?  I don't see where this named tuple 
 is being created.  It's true that the ARRAY type by default doesn't know how 
 deep it should be unwrapping arrays, if you pass the dimensions argument 
 then it will be fixed.   But it's not clear why you didn't see this issue in 
 0.7 as well, perhaps we check for a wider range of array/tuple types at this 
 point but I don't recall.
 
 
 
 A namedtuple is returned by Psycopg2 directly (using its register_composite 
 mechanism). The result processing changed in this commit: 
 https://bitbucket.org/sqlalchemy/sqlalchemy/commits/0ba8b4fd402f1c187b80310fc838dcdea27e0af8,
  so I will take a look to see if I can figure out what causes the new 
 behaviour. I'm guessing that it sees the namedtuple instance and figures that 
 it is a tuple instance so it can be converted into a list.


yeah.  if you set the ARRAY with the number of expected dimensions (likely 1 
here) it shouldn't do any of that.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.