Comment 4 for bug 1035162

Revision history for this message
Mark Lakewood (munderwood) wrote :

Hi,

So we have two storm queries

store = storm_store.find(models.customer.Store, models.customer.Store.id == contract.store_id).one()

and

billing_address = storm_store.find(models.customer.Address, models.customer.Address.store_id == store.id,
                                                                                                    models.customer.Address.address_type_id == 2).one()

These have nothing to do with each other, apart from that I need to get the address of the store. To do that I first get the store, in the first find. this returns a model because of the one() method. Then I use the id of the store model to add a filter to the query on the next find. Hence the second query matches up with the SQL that I posted. It is doing a select on customer_address where the store_id == 0 and the address_type_id == 2. The bit that doesnt work is that when I then call the one() function on that find query, storm inserts and empty where table like so

WHERE customer_address.store_id = %s AND customer_address AND customer_address.store_id = %s AND customer_address.address_type_id = %s', (0, 0, 2)

see the "AND customer_address AND"

when I do not call one() on the result of the find, then the SQL is correctly constructed.

 I hope this clarifies this, and im sorry for the typos at the start that made it hard to understand.

Cheers

Mark