[sqlalchemy] Re: AttributeError: can't set attribute after updating to 1.0.4 from 0.9.4

2016-05-30 Thread 'Pankaj Gupta' via sqlalchemy
I'm facing exactly same issue. 

It worked in past very well (below 1.0) and was very useful to update 
attribute or add new attributes (temporarily), now i can neither update not 
add new attributes. 

I'm wondering if someone can help us to port to later release or give some 
guidance for us to make it work.

Thanks,
-Pankaj

On Friday, May 15, 2015 at 7:26:16 PM UTC+5:30, Antoine Leclair wrote:
>
> Hi all,
>
> I recently tried to update SQLAlchemy from 0.9.4 to 1.0.4 in a client's 
> project. However, I run into an error that is not there with 0.9.4.
>
> It happens for this type of query:
>
> q = DBSession.query(User) \
>  .filter(User.profile_id.in_(profile_ids)) \
>  .join(Profile)
> q = q.outerjoin(
> CouplePhoto,
> and_(
> User.profile_id==CouplePhoto.profile_id,
> CouplePhoto.avatar==True
> )
> )
> q = q.with_entities(User.profile_id, User.given_name, User.zipcode,
> CouplePhoto.filename, User.gender, Profile.sex)
> users_data = q.all()
> for u in users_data:
> if u.filename:
> *# the next line causes the error in 1.0.4*
> *u.filename = 'something'*
>
> In 0.9.4, the type of "u" was "KeyedTuple" and in 1.0.4, it's "result". 
> The error is "AttributeError: can't set attribute".
>
> The goal of this assignation is to recompute the filename according to the 
> original filename (to show a thumb instead of original). It is not saved in 
> the database.
>
> Now, I know this is not necessarily good design and I would not have done 
> it that way myself. But the code base is probably full of this type of 
> thing, mixed with business logic, and trying to fix them is clearly not 
> doable in the short term.
>
> And we have to update SQLAlchemy, because some circular reference issue 
> was fixed when using Alembic somewhere between 0.9.4 and 1.0.4.
>
> Is there anything I should be aware of to help with this?
>
> Thanks in advance.
>

-- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] outerjoin

2011-01-26 Thread Pankaj
Hi,

I have this subquery, which yields results

sp_HeaderDetails =
session.query( InvoiceCashFlowPerDocNum.sequence_id,
InvoiceHeaderInfo.invoice_ref, InvoiceHeaderInfo.doc_num  ) \
.filter( ( InvoiceCashFlowPerDocNum.doc_num ==
InvoiceHeaderInfo.doc_num ) )  \
.subquery()

I then do a outerjoin on another query

cashflows = session.query( CashflowEventDetail, sp_HeaderDetails ) \
   .outerjoin( ( sp_HeaderDetails,
and_(sp_HeaderDetails.c.sequence_id ==
CashflowEventDetail.sequence_id ) ) )

This above statement generates the following sql:


SELECT cash_flow_event_detail.id
FROM cash_flow_event_detail LEFT OUTER JOIN (SELECT
invoice_cashflows.sequence_id AS sequence_id,
invoice_header_information.invoice_ref AS invoice_ref,
invoice_header_information.doc_num AS doc_num
FROM invoice_cashflows, invoice_header_information
WHERE invoice_cashflows.doc_num = invoice_header_information.doc_num)
AS anon_1 ON anon_1.sequence_id = cash_flow_event_detail.sequence_id

The above sql doesnt return any values if I run the sql in python. It
also generates error when I run it in db artisan generating a missing
keyword error.

However, if I remove the keyword AS in clause AS anon_1, it
succeeds in DbArtisan.

Any help would be appreciated

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.