On 17/01/2017 15:08, mike bayer wrote:
On 01/17/2017 06:15 AM, Chris Withers wrote:
Great, thanks. I assume has_inherited_table returns False where the
table is defined on the class itself?
it looks like has_inherited_table is just looking for non-None __table__
attribute up the inheritance
On 01/17/2017 06:15 AM, Chris Withers wrote:
Great, thanks. I assume has_inherited_table returns False where the
table is defined on the class itself?
it looks like has_inherited_table is just looking for non-None __table__
attribute up the inheritance chain.
(ie: normal models, and the
Great, thanks. I assume has_inherited_table returns False where the
table is defined on the class itself?
(ie: normal models, and the "base" model in the case of single table
inheritance)
Chris
On 16/01/2017 17:49, mike bayer wrote:
at the declarative level we have this:
at the declarative level we have this:
http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/api.html#sqlalchemy.ext.declarative.has_inherited_table
this might be better since you're really looking for a "table" up above
On 01/16/2017 12:05 PM, Chris Withers wrote:
Hi All,
If
Hi All,
If I'm using instrument_class events to add some constraints to a table,
what's the 'right' way to spot when it's a subclass is being
instrumented? (where I'm guessing I shouldn't add the constraints).
My current attempt is here:
Hi,
What is the recommended method of specifying constraints on columns
added by a subclass using single-table inheritance? This does not work,
I get a KeyError for col_a:
class BaseClass(Base)
__table__ = base
__table_args__ = (Index(base_col),
I have a pretty simple case. A base class with three sub-classes, and then
a final class that inherits from the three derived classes. When
persisting, sqlalchemy only sets the properties of the parent class and the
first child class.
In all other respects the sub-class is behaving properly;
The inheritance mechanics don't support multiple inheritance from the POV of
multiple mapped classes as the base for another mapped class. Single table
inheritance would be the easiest case to work at some point, but there's lots
of mechanics in place right now that assume a linear path from
and if you expand upon this approach you'll probably have column conflicts too,
refer to
http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#resolving-column-conflicts
for the strategy for dealing with that.
On Jan 14, 2013, at 1:17 PM, Michael Bayer wrote:
The inheritance
I am all down with the power of mixins. The reason I mapped things this way
is because I do have concrete instances of string, amount, and quantity.
(I'm capturing data from receipts: string can be e.g. a receipt number,
amount can be e.g. a total, and quantity can be something unaffiliated
I agree this could be better. Not sure how deep we'd have to go to get
multiple inheritance in single inheritance form to work, mapping to inheritance
hierarchies is probably what adds most complexity to the ORM as it is. It's a
very rare use case though, and also gets way harder when we
Hi Michael,
That does exactly what I was after (and I've learned a little bit more
about sqalchemy!)
Thank you very much for your help.
On Thursday, 23 August 2012 19:13:27 UTC+1, Michael Bayer wrote:
On Aug 23, 2012, at 10:04 AM, Rob wrote:
Hi Michael,
I have a similar (but subtly
Hi Michael,
I have a similar (but subtly different) problem to this, trying to mix
single- and joined-table inheritance.
Essentially my model looks as follows:
Product(Base)
PhysicalProduct(Product)
NonPhysicalProduct(Product)
The Physical/NonPhysicalProduct use single table inheritance
Hi,
We've used joined table inheritance up to this point, but performance
issues are making us explore single table inheritance. I'm running into a
problem with mapper configuration. Using SQLAlchemy 0.7.8, Flask-SQLAlchemy
0.16, and Flask 0.8. Here is the inheritance:
class
On Aug 15, 2012, at 10:45 AM, Kuba Dolecki wrote:
Hi,
We've used joined table inheritance up to this point, but performance issues
are making us explore single table inheritance. I'm running into a problem
with mapper configuration. Using SQLAlchemy 0.7.8, Flask-SQLAlchemy 0.16, and
You responded! Woot. Thanks. Here's some additional info:
1. __tablename__ is generated automatically based on the class name.
Flask-SQLAlchemy does this for us. The __tablename__ for AutocreatedGroup
and TopicAutocreatedGroup model is both autocreated_group.
2. Sorry, I might have included
On Aug 15, 2012, at 11:41 AM, Kuba Dolecki wrote:
You responded! Woot. Thanks. Here's some additional info:
1. __tablename__ is generated automatically based on the class name.
Flask-SQLAlchemy does this for us. The __tablename__ for AutocreatedGroup and
TopicAutocreatedGroup model is
Cool, I think the approach you outlined briefly works, and I look forward
to hopefully seeing it in the next release.
For now, I will just add the columns back to the AutocreatedGroup class.
Again, thank you. I really appreciate your help. I'll make sure to make my
emails in the future more
hi,
what's wrong with the following mapping ?
TYPE_DEFAULT = 1
class BaseFriend(DeclarativeBase):
__tablename__ = 'friends'
__table_args__ = {'mysql_engine': 'InnoDB',
'mysql_charset': 'utf8'}
type = Column(SmallInteger, primary_key=True)
user_id
On Jun 16, 2012, at 9:37 AM, Vladimir Iliev wrote:
hi,
what's wrong with the following mapping ?
TYPE_DEFAULT = 1
class BaseFriend(DeclarativeBase):
__tablename__ = 'friends'
__table_args__ = {'mysql_engine': 'InnoDB',
'mysql_charset': 'utf8'}
On Saturday, June 16, 2012 4:52:14 PM UTC+3, Michael Bayer wrote:
On Jun 16, 2012, at 9:37 AM, Vladimir Iliev wrote:
hi,
what's wrong with the following mapping ?
TYPE_DEFAULT = 1
class BaseFriend(DeclarativeBase):
__tablename__ = 'friends'
Hoping for advice: I'm using sqlalchemy against a legacy application's
database design, most of which isn't in my control. I have a situation
where single table inheritance should work beautifully but there is one
catch: of the 7 polymorphic sub classes, there is one which is allowed to
On Mar 21, 2012, at 9:49 AM, Kent wrote:
Hoping for advice: I'm using sqlalchemy against a legacy application's
database design, most of which isn't in my control. I have a situation where
single table inheritance should work beautifully but there is one catch: of
the 7 polymorphic sub
That will work for me, thanks!
P.S. make a note that the doc statement that it will be a future release
should be updated.
On 3/21/2012 10:04 AM, Michael Bayer wrote:
also polymorphic_on can be any SQL expression in 0.7, like a CASE statement if
you wanted.
--
You received this message
On Mar 21, 2012, at 10:29 AM, Kent Bower wrote:
That will work for me, thanks!
P.S. make a note that the doc statement that it will be a future release
should be updated.
can you point me right to where it says that
On 3/21/2012 10:04 AM, Michael Bayer wrote:
also polymorphic_on
On Dec 7, 2011, at 11:08 PM, kris wrote:
Hmm, I think I want the opposite behavior. I was the defualt mapper to
Resource unless a more specific mapper has been defined.
I never defined a 'C' or 'D' and I would like simple get a Resource when no
better mapper is found.
i.e. I get
the recipe is broken, please wait until i have time to fix it, thanks.
On Dec 8, 2011, at 11:27 AM, Michael Bayer wrote:
On Dec 7, 2011, at 11:08 PM, kris wrote:
Hmm, I think I want the opposite behavior. I was the defualt mapper to
Resource unless a more specific mapper has been
OK it works (not yet in tip though).
On Dec 8, 2011, at 11:43 AM, Michael Bayer wrote:
the recipe is broken, please wait until i have time to fix it, thanks.
On Dec 8, 2011, at 11:27 AM, Michael Bayer wrote:
On Dec 7, 2011, at 11:08 PM, kris wrote:
Hmm, I think I want the opposite
Does this mean I can use this in 7.3? or Do I need to download tip?
Also could you show me how this would work with old style mapper(...) s
instead of declarative_base?
Thanks,
Kris
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To view this
works in 0.7.3. will also work in 0.7.4 Just not the current tip at the
moment.
the regular mapper() setup is equivalent (see
http://www.sqlalchemy.org/docs/orm/mapper_config.html#classical-mappings) :
discriminator_expr = case(...)
mapper(Person, ..., polymorphic_on=discriminator_expr,
On Dec 7, 2011, at 2:53 AM, kris wrote:
I am using a single table scheme to store for a set of resource types.
I would like to load a specific class if a mapper is defined and use the base
class if no
more specific version can be found. Is there a way to do this?
i.e.
resource =
Hmm, I think I want the opposite behavior. I was the defualt mapper to
Resource unless a more specific mapper has been defined.
I never defined a 'C' or 'D' and I would like simple get a Resource when no
better mapper is found.
i.e. I get Resource class for C, D and get a Resource_A for A and
I am using a single table scheme to store for a set of resource types.
I would like to load a specific class if a mapper is defined and use the
base class if no
more specific version can be found. Is there a way to do this?
i.e.
resource = Table('resource',
Yeah my bad, the original query does indeed query for (Z.id, B.name). I had
just changed it to A.name to get the printout for the workaround query
and forgot to change it back before pasting here.
If there's something I can do to contribute (not sure I'm qualified to
write those tests), do
heh :) the thing about tests is that anyone who gets a couple of days of
practice writing them in our style can be very productive...but everyone has
just one issue they need so that threshold isn't passed ...
I have a boatload of tests to write for the 0.7.4 milestone so I'll be blocking
I encountered a little strangeness when joining to a class using single
table inheritance.
I was wondering why I got no results for one particular query.
This was originally encountered with PostgreSQL but was successfully
reproduced with SQLite.
Is this a bug or a user error?
On Nov 15, 2011, at 8:54 PM, Alex Grönholm wrote:
query = session.query(Z, A.name).outerjoin(Z.b).filter(Z.id == 1)
print query
# WORKAROUND:
# query = session.query(Z, A.name).outerjoin(Z.b).filter(Z.id == 1)
# ^- use the superclass instead
I'd note that these
On Nov 15, 2011, at 11:39 PM, Michael Bayer wrote:
On Nov 15, 2011, at 8:54 PM, Alex Grönholm wrote:
query = session.query(Z, A.name).outerjoin(Z.b).filter(Z.id == 1)
print query
# WORKAROUND:
# query = session.query(Z, A.name).outerjoin(Z.b).filter(Z.id == 1)
#
here's a pastebin of it:
http://pastebin.com/z8XWsv2e
On Aug 16, 2011, at 7:42 PM, Michael Bayer wrote:
On Aug 16, 2011, at 5:37 PM, Mike Gilligan wrote:
I have a single table that looks similar to the following:
class Equipment(Base):
type = Column(CHAR(1), primary_key=True)
I have a single table that looks similar to the following:
class Equipment(Base):
type = Column(CHAR(1), primary_key=True)
sub_type = Column(CHAR(1), primary_key=True)
code = Column(CHAR(5), primary_key=True)
For historical purposes, I cannot modify this table. I would like to setup
On Aug 16, 2011, at 5:37 PM, Mike Gilligan wrote:
I have a single table that looks similar to the following:
class Equipment(Base):
type = Column(CHAR(1), primary_key=True)
sub_type = Column(CHAR(1), primary_key=True)
code = Column(CHAR(5), primary_key=True)
For
Hi all,
I'm running SQLAlchemy 0.7.0, against MySQL 5.1. I'm having issues
with a field that I'd like shared between the classes in single table
inheritance that I would like to have referred to differently in the
subclasses:
class Post(Base):
__tablename__ = 'posts'
id =
I'm having trouble with many-to-one relationships to subclasses that use
single table inheritance. I have tried this in 0.5.8 and 0.6beta1.
Here is my test case:
import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
Conor wrote:
I'm having trouble with many-to-one relationships to subclasses that use
single table inheritance. I have tried this in 0.5.8 and 0.6beta1.
that's what I get for not trying to answer every single email, a 6 month
old bug which I've missed. This is very small and I've created and
Hi
I am facing a different problem in inheritance.
I am using the single table inheritance through declarative.
http://www.sqlalchemy.org/docs/05/reference/ext/declarative.html#single-table-inheritance
b=Base()
b.id='xxx'
b.name='xxx'
b.type='type1'
I am manually setting the type column of my
how can i change the type of mapped object using single table inheritance?
thanks
--~--~-~--~~~---~--~~
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
Hello!
In a configuration looking like this:
class Parent:
pass
class Child(Parent):
pass
class ChildChild(Child):
pass
I would like to query the Childs and all classes that inherits it
(here: ChildChild), but not Parent instances.
session.query(Child).all() returns Child type only (
I have a situation similar to
http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_mapper_inheritance_single
with the exception that I have about 50 different types, but only one of
them I want to subclass. So I was wondering id there was some option to
polymorphic_identity to give it
Is there a way to inherit more than one level for single table
inheritance? Take this relationship for example:
Animal - Dog - German Shepard
Say there are 10 animals; 5 are dogs and 2 are German Shepard.
session.query(Animal).select() # Should yield 10 results.
49 matches
Mail list logo