What the Session Sent
BEGIN (implicit)
INSERT INTO hotel (name, street, city, country, year) VALUES (?, ?, ?, ?, ?)
('Madison Inn', '800 S Main St', 'Harrisonburg', 'USA', 1908)
COMMIT
BEGIN (implicit)
SELECT hotel.hotel_id, hotel.name, ... FROM hotel WHERE hotel.hotel_id = ?
(1,)
- Nothing happened at
session.add() -- only at commit()
- PostgreSQL gets the same
RETURNING hotel_id you wrote by hand
- After
commit(), reading hotel.hotel_id re-SELECTs the row