On Sat, Feb 15, 2020, at 3:27 PM, Mark Aquino wrote:
> “You can use a @property so that when you get back an A or a B object , they 
> seek to return either the column on A or the column on B.“
> 
> I believe you’re describing the behavior I currently have, I.e. if I query B 
> then I can get b.visible_id otherwise I get A.visible_id. 
> 
> I see your point about efficiency, but I think I’m already doing this sort of 
> join under the hood because I’m using GraphQL to query all A and then pulling 
> attributes on subclasses of A depending on the type. 
> 
> I’m fine with eliminating visible_id from all subclasses, though, but I’d 
> like separate numbering for each subclass. 
> 
> 
> Is it possible to specify the sequence to use per class when persisting the 
> entities or do you have a method for that which you recommend?


your base table "a" has a "type" column. So just one visible_id column that is 
in a unique constraint with "type" and that would give you independent unique 
sequences per subclass.


(1, "a")
(2, "a")
(1, "b")
(2, "b")
(3, "a")

... etc

the next sequence value for a particular subclass is "SELECT MAX(id) + 1 FROM 
table WHERE type='<name>'"




> 
> If not, can you tell me how to do the mapping with coalesce and I’ll stress 
> test it to see if it will work performance wise?
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/2348bb1b-df75-46aa-b43a-458a13d37f99%40googlegroups.com.
> 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/dc0aa15a-9766-4556-8f81-fdae70b20a3f%40www.fastmail.com.

Reply via email to