I set up the DB:
from sqlalchemy import * 
from sqlalchemy.orm import * 
from sqlalchemy.ext.declarative import declarative_base 


Base = declarative_base() 

class Employee(Base): 
    __tablename__ = 'employee' 
    id = Column(Integer, primary_key=True)  

class EmployeeRecord(Base):
    __tablename__ = 'employee_record' 
    
    employee_id = Column(Integer, ForeignKey(Employee.id), primary_key=True)


    employee = relationship(
        Employee,
        viewonly=True,  
        backref=backref("records", passive_deletes="all",),
        passive_deletes="all",
    )
    
e = create_engine("postgresql://localhost/test_issue2", echo=True) 

Base.metadata.drop_all(e) 
Base.metadata.create_all(e) 

and then:
s = Session(e) 

e = Employee(id=1)
s.add(e)

s.flush()

print("xxxx")
e.records.clear()

and I see:

xxxx 2018-12-01 21:16:13,608 INFO sqlalchemy.engine.base.Engine SELECT 
employee_record.employee_id AS employee_record_employee_id FROM employee_record 
WHERE %(param_1)s = employee_record.employee_id

I don't understand why that SELECT is needed given the passive_deletes being 
set.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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.

Reply via email to