sqlalchemy-tickets Mailing List for SQLAlchemy (Page 90)
Brought to you by:
zzzeek
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(174) |
Apr
(50) |
May
(71) |
Jun
(129) |
Jul
(113) |
Aug
(141) |
Sep
(82) |
Oct
(142) |
Nov
(97) |
Dec
(72) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(159) |
Feb
(213) |
Mar
(156) |
Apr
(151) |
May
(58) |
Jun
(166) |
Jul
(296) |
Aug
(198) |
Sep
(89) |
Oct
(133) |
Nov
(150) |
Dec
(122) |
| 2008 |
Jan
(144) |
Feb
(65) |
Mar
(71) |
Apr
(69) |
May
(143) |
Jun
(111) |
Jul
(113) |
Aug
(159) |
Sep
(81) |
Oct
(135) |
Nov
(107) |
Dec
(200) |
| 2009 |
Jan
(168) |
Feb
(109) |
Mar
(141) |
Apr
(128) |
May
(119) |
Jun
(132) |
Jul
(136) |
Aug
(154) |
Sep
(151) |
Oct
(181) |
Nov
(223) |
Dec
(169) |
| 2010 |
Jan
(103) |
Feb
(209) |
Mar
(201) |
Apr
(183) |
May
(134) |
Jun
(113) |
Jul
(110) |
Aug
(159) |
Sep
(138) |
Oct
(96) |
Nov
(116) |
Dec
(94) |
| 2011 |
Jan
(97) |
Feb
(188) |
Mar
(157) |
Apr
(158) |
May
(118) |
Jun
(102) |
Jul
(137) |
Aug
(113) |
Sep
(104) |
Oct
(108) |
Nov
(91) |
Dec
(162) |
| 2012 |
Jan
(189) |
Feb
(136) |
Mar
(153) |
Apr
(142) |
May
(90) |
Jun
(141) |
Jul
(67) |
Aug
(77) |
Sep
(113) |
Oct
(68) |
Nov
(101) |
Dec
(122) |
| 2013 |
Jan
(60) |
Feb
(77) |
Mar
(77) |
Apr
(129) |
May
(189) |
Jun
(155) |
Jul
(106) |
Aug
(123) |
Sep
(53) |
Oct
(142) |
Nov
(78) |
Dec
(102) |
| 2014 |
Jan
(143) |
Feb
(93) |
Mar
(35) |
Apr
(26) |
May
(27) |
Jun
(41) |
Jul
(45) |
Aug
(27) |
Sep
(37) |
Oct
(24) |
Nov
(22) |
Dec
(20) |
| 2015 |
Jan
(17) |
Feb
(15) |
Mar
(34) |
Apr
(55) |
May
(33) |
Jun
(31) |
Jul
(27) |
Aug
(17) |
Sep
(22) |
Oct
(26) |
Nov
(27) |
Dec
(22) |
| 2016 |
Jan
(20) |
Feb
(24) |
Mar
(23) |
Apr
(13) |
May
(17) |
Jun
(14) |
Jul
(31) |
Aug
(23) |
Sep
(24) |
Oct
(31) |
Nov
(23) |
Dec
(16) |
| 2017 |
Jan
(24) |
Feb
(20) |
Mar
(27) |
Apr
(24) |
May
(28) |
Jun
(18) |
Jul
(18) |
Aug
(23) |
Sep
(30) |
Oct
(17) |
Nov
(12) |
Dec
(12) |
| 2018 |
Jan
(27) |
Feb
(23) |
Mar
(13) |
Apr
(19) |
May
(21) |
Jun
(29) |
Jul
(11) |
Aug
(22) |
Sep
(14) |
Oct
(9) |
Nov
(24) |
Dec
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 20:01:52
|
#1765: Column does not accept None as type with a multi-column
ForeignKeyConstraint
-----------------------------------+-------------------------------
Reporter: ged | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone: 0.9.0
Component: schema | Severity: major - 1-3 hours
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* status_field: in progress => completed/closed
* resolution: => fixed
* milestone: 0.8.xx => 0.9.0
Comment:
re288aff8eae6d08
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1765#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 15:34:00
|
#1443: reflect check constraints (uniques done)
------------------------------------+---------------------------------
Reporter: guest | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.x.xx
Component: postgres | Severity: major - 1-3 hours
Resolution: | Keywords: reflect constraints
Progress State: needs a volunteer |
------------------------------------+---------------------------------
Comment (by zzzeek):
unique constraints are in rc69fe4acf8929856735e5d9, with some supplemental
commits later on.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1443#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 05:40:16
|
#1765: Column does not accept None as type with a multi-column
ForeignKeyConstraint
------------------------------+-------------------------------
Reporter: ged | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.8.xx
Component: schema | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in progress |
------------------------------+-------------------------------
Changes (by zzzeek):
* status_field: awaiting triage => in progress
* milestone: 0.x.xx => 0.8.xx
Comment:
kind of a lame patch. trying to get .type to evaluate later but this
gets in the way of trickier pickling scenarios.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1765#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 04:40:32
|
#2711: documentation hints for GAE dialect usage
-----------------------------------+----------------------------------
Reporter: Lou K | Owner: zzzeek
Type: defect | Status: closed
Priority: low | Milestone: 0.x.xx
Component: documentation | Severity: minor - half an hour
Resolution: worksforme | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => worksforme
* status_field: needs a volunteer => completed/closed
Comment:
the GAE docs are as far as I need them to go (users of GAE need to know on
their own what's up with their DBAPI) and also #2715 has addressed
remaining import issues.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2711#comment:6>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 04:34:57
|
#1750: consider supporting DBAPI-level autocommit
-----------------------------------+--------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: closed
Priority: medium | Milestone: blue sky
Component: engine | Severity: refactor - over two days
Resolution: wontfix | Keywords:
Progress State: completed/closed |
-----------------------------------+--------------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => wontfix
* status_field: not decided upon => completed/closed
Comment:
as a generalized solution we won't be doing this. we are starting to
support enabling of autocommit per-dialect using execution options, and
that's fine, though this is always in the realm of "the user wants to do
this explicitly".
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1750#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 04:29:54
|
#2096: psycopg 2.4 doesn't allow % in bind names anymore
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone: 0.x.xx
Component: postgres | Severity: major - 1-3 hours
Resolution: wontfix | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => wontfix
* status_field: in queue => completed/closed
Comment:
i really can't see ever doing anything about this. the % in bind names
follows from that you might have used them in column names and overall
it's really not a postgresql use case.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2096#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-23 04:28:14
|
#2471: add example of declared_attr columns shared across inheritance to
declarative docs
-----------------------------------+----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: task | Status: closed
Priority: medium | Milestone: 0.x.xx
Component: documentation | Severity: minor - half an hour
Resolution: wontfix | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => wontfix
* status_field: not decided upon => completed/closed
Comment:
i dont see why this pattern is special for the main docs
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2471#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-22 16:24:23
|
#2722: clarify what should happen with query(A).select_from(A).join(B.a)
--------------------------------+-------------------------------
Reporter: rbu | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: blue sky
Component: documentation | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in queue |
--------------------------------+-------------------------------
Changes (by zzzeek):
* milestone: 0.8.xx => blue sky
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2722#comment:6>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-22 16:23:35
|
#2751: assocaition proxy support for scalar-targeted attributes
-----------------------------------+----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: high | Milestone: 0.9.0
Component: ext | Severity: minor - half an hour
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: reopened => closed
* resolution: => fixed
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2751#comment:7>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-22 16:21:40
|
#2744: Consider special flags/logic/other in TypeDecorator to ease production of
custom `__eq__()` logic
-----------------------------------+-------------------------------
Reporter: vladimir-lu | Owner: zzzeek
Type: defect | Status: closed
Priority: high | Milestone: 0.8.xx
Component: sql | Severity: major - 1-3 hours
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* status_field: needs tests => completed/closed
Comment:
raa5cc5a2cca1131af7925f5bec1745571bfd5736 0.8
reba9d1b58f38577fb71d3374a2133d6e9159c277 master
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2744#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-22 15:44:16
|
#2763: retaining=True flag on firebird dialects should be configurable
----------------------+-------------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.8.xx
Component: firebird | Severity: minor - half an hour
Keywords: | Progress State: needs questions answered
----------------------+-------------------------------------------
1. boolean for the rollback/commit - True or False by default?
documentation verbiage?
2. pull request to make the flag configurable at the dialect level
3. how backwards incompatible is this? if so, can be for 0.9 ?
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2763>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-21 18:52:02
|
#2628: need a working __repr__ for Variant
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone: 0.8.xx
Component: schema | Severity: major - 1-3 hours
Resolution: wontfix | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => wontfix
* status_field: in queue => completed/closed
Comment:
replaced by https://bitbucket.org/zzzeek/alembic/issue/131/create-special-
rendering-for-variant.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2628#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-21 04:42:07
|
#2628: need a working __repr__ for Variant
---------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.8.xx
Component: schema | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in queue |
---------------------------+-------------------------------
Comment (by ajsd0990):
See pull request 9 on GitHub: https://github.com/zzzeek/sqlalchemy/pull/9
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2628#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-20 19:34:22
|
#2668: auto_correlate fails if all froms are existing in a superquery
-----------------------------------+-------------------------------
Reporter: lukecyca | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone: 0.8.0final
Component: orm | Severity: major - 1-3 hours
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: reopened => closed
* resolution: => fixed
Comment:
the ongoing work to provide this functionality in a more specific way is
in #2746 and I've added another change which I've long wondered if it was
needed to the most recent patch, where your test case passes.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2668#comment:15>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-20 19:33:09
|
#2746: Add a flag to explicitly enable correlation even when the subquery has
`asfrom=True`
------------------------------+----------------------------------
Reporter: sayap | Owner: zzzeek
Type: enhancement | Status: new
Priority: highest | Milestone: 0.8.xx
Component: sql | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+----------------------------------
Changes (by zzzeek):
* priority: medium => highest
* status_field: in queue => needs tests
* milestone: 0.9.0 => 0.8.xx
Comment:
See also #2668 which we'll close as a dupe here, we need to consider
propagating the correlation list recursively:
{{{
#!python
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1241,6 +1241,8 @@ class SQLCompiler(engine.Compiled):
froms = select._get_display_froms(existingfroms, asfrom=asfrom)
correlate_froms = set(sql._from_objects(*froms))
+ if existingfroms:
+ correlate_froms = correlate_froms.union(existingfroms)
self.stack.append({'from': correlate_froms,
}}}
here's the test case for that:
{{{
#!python
from sqlalchemy.sql import table, column, select, exists
p = table('parent', column('id'))
c = table('child', column('id'), column('parent_id'), column('pos'))
s = c.select().where(c.c.parent_id == p.c.id).order_by(c.c.pos).limit(1)
s = s.correlate(p, froms=True)
s = exists().select_from(s).where(s.c.id == 1)
s = select([p]).where(s)
print s
}}}
we want:
{{{
SELECT parent.id
FROM parent
WHERE EXISTS (SELECT *
FROM (SELECT child.id AS id, child.parent_id AS parent_id, child.pos AS
pos
FROM child
WHERE child.parent_id = parent.id ORDER BY child.pos
LIMIT :param_1)
WHERE id = :id_1)
}}}
and not:
{{{
SELECT parent.id
FROM parent
WHERE EXISTS (SELECT *
FROM (SELECT child.id AS id, child.parent_id AS parent_id, child.pos AS
pos
FROM child, parent
WHERE child.parent_id = parent.id ORDER BY child.pos
LIMIT :param_1)
WHERE id = :id_1)
}}}
and not
{{{
SELECT parent.id
FROM parent
WHERE EXISTS (SELECT *
FROM (SELECT child.id AS id, child.parent_id AS parent_id, child.pos AS
pos
FROM child, parent
WHERE child.parent_id = parent.id ORDER BY child.pos
LIMIT :param_1)
WHERE id = :id_1)
}}}
I'm a little concerned about propagating the FROMs all the way in like
that but no tests fail, and I'm getting the impression that when you have
"SELECT ( SELECT ( SELECT ) ) ", those selects are typically going to be
nested in the FROM clause and this new "froms" flag is a nice way of
ensuring it doesn't happen by default.
updated patch is attached and i think we have to make this 0.8 also since
people from 0.7 are getting hit by it.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2746#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-20 19:24:26
|
#2762: Relationship lazy configuration doesn't work with polymorphism
-----------------------------------+------------------------------------
Reporter: schlamar | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: orm | Severity: no triage selected yet
Resolution: worksforme | Keywords:
Progress State: completed/closed |
-----------------------------------+------------------------------------
Comment (by schlamar):
If you load the polymorphic collection already as relationship via
`query.options(joinedload('model'))`, I guess only the last option works?
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2762#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-20 19:05:40
|
#2762: Relationship lazy configuration doesn't work with polymorphism
-----------------------------------+------------------------------------
Reporter: schlamar | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: orm | Severity: no triage selected yet
Resolution: worksforme | Keywords:
Progress State: completed/closed |
-----------------------------------+------------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => worksforme
* status_field: awaiting triage => completed/closed
Comment:
a polymorphic load on joined table inheritance by default only loads from
the base table, not any of the related tables. therefore a joined eager
load from SubModel->related_model is ignored here.
The solution here is to use `with_polymorphic`, of which there are three
ways to specify (mapper level, `query.with_polymorphic()`, and the newer
`with_polymorphic()` standalone function), specifying that loads for
`Model` should also join out to load submodels of type `SubModel`:
{{{
#!python
session = Session()
model_with_related = with_polymorphic(Model, SubModel)
s = session.query(model_with_related).one()
session.close()
s.related_model
# or
session = Session()
s = session.query(Model).with_polymorphic(SubModel).one()
session.close()
s.related_model
# or
Model.__mapper__.with_polymorphic = (SubModel, None)
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2762#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-20 15:25:40
|
#2668: auto_correlate fails if all froms are existing in a superquery
-----------------------------------+-------------------------------
Reporter: lukecyca | Owner: zzzeek
Type: defect | Status: reopened
Priority: medium | Milestone: 0.8.0final
Component: orm | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by avoidscorn):
* status: closed => reopened
* cc: sqlalchemy@… (added)
* resolution: fixed =>
Comment:
This change causes problems for me, as I rely on "invalid" SELECT-used-
as-a-FROM behavior. PostgreSQL at least supports it. My use case: given a
parent table and child table, find the parent whose max-child satisfies
some condition.
Example:
{{{#!python
import sqlalchemy as sa
metadata = sa.MetaData()
parent = sa.Table("parent", metadata,
sa.Column("id", sa.Integer, primary_key=True))
child = sa.Table("child", metadata,
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("parent_id", sa.Integer, sa.ForeignKey("parent.id")),
sa.Column("pos", sa.Integer))
# Find the max-child for a given parent.
child_q = sa.select([child])
child_q = child_q.where(child.c.parent_id == parent.c.id)
child_q = child_q.order_by(child.c.pos)
child_q = child_q.limit(1)
child_q = child_q.correlate(parent)
child_q = child_q.alias("max_child")
max_child_q = sa.select([1], from_obj=child_q)
# Arbitrary max-child condition.
max_child_q = max_child_q.where(child_q.c.id == 1)
q = sa.select([parent])
q = q.where(sa.exists(max_child_q))
print q
}}}
Produces this SQL:
{{{#!sql
SELECT parent.id
FROM parent
WHERE EXISTS (SELECT 1
FROM (SELECT child.id AS id, child.parent_id AS parent_id, child.pos AS
pos
FROM child, parent
WHERE child.parent_id = parent.id ORDER BY child.pos
LIMIT :param_1) AS max_child
WHERE max_child.id = :id_1)
}}}
Note the unwanted "parent" FROM clause in the innermost SELECT. It does
not show up in 0.7.x.
I realize there are more efficient ways to do max-child queries, but this
method is convenient when the code that generates the max-child clause is
independent from the code that creates the overall query.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2668#comment:14>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-20 14:47:05
|
#2762: Relationship lazy configuration doesn't work with polymorphism
----------------------+-----------------------------------------
Reporter: schlamar | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: orm | Severity: no triage selected yet
Keywords: | Progress State: awaiting triage
----------------------+-----------------------------------------
Testcase:
{{{
#!python
from sqlalchemy import create_engine, Column, ForeignKey, Integer
from sqlalchemy.orm import relationship, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class RelatedModel(Base):
__tablename__ = 'related_model'
id = Column(Integer, primary_key=True)
class Model(Base):
__tablename__ = 'model'
id = Column(Integer, primary_key=True)
mtype = Column(Integer, nullable=False)
__mapper_args__ = {'polymorphic_on': mtype}
class SubModel(Model):
__tablename__ = 'submodel'
id = Column(Integer, ForeignKey('model.id'), primary_key=True)
__mapper_args__ = {'polymorphic_identity': 1}
related_model_id = Column(Integer, ForeignKey('related_model.id'))
related_model = relationship('RelatedModel', lazy='joined')
def main():
engine = create_engine('sqlite:///:memory:')
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()
s = SubModel()
s.related_model = RelatedModel()
session.add(s)
session.commit()
session.close()
session = Session()
s = session.query(Model).one()
session.close()
s.related_model
}}}
I expect that the relationship `SubModel -> RelatedModel` is already
loaded, even when querying against the base class. However, the above code
raises `DetachedInstanceError: Parent instance <SubModel at 0x2b465f0> is
not bound to a Session; lazy load operation of attribute 'related_model'
cannot proceed`.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2762>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-19 20:46:42
|
#2761: allow non-property objects to work with declarative string resolution
-------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: new
Priority: high | Milestone: 0.8.xx
Component: orm | Severity: minor - half an hour
Keywords: | Progress State: needs tests
-------------------------+---------------------------------------
{{{
#!python
from sqlalchemy import Column, Integer, String, ForeignKey, case
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import relationship
Base = declarative_base()
class User(Base):
__tablename__ = 'user'
id = Column(Integer, primary_key=True)
firstname = Column(String(50))
lastname = Column(String(50))
game_id = Column(Integer, ForeignKey('game.id'))
@hybrid_property
def fullname(self):
if self.firstname is not None:
return self.firstname + " " + self.lastname
else:
return self.lastname
@fullname.expression
def fullname(cls):
return case([
(cls.firstname != None, cls.firstname + " " + cls.lastname),
], else_=cls.lastname)
class Game(Base):
__tablename__ = 'game'
id = Column(Integer, primary_key=True)
name = Column(String(50))
users = relationship("User", order_by="User.fullname")
if __name__ == '__main__':
game = Game(name="tetris")
}}}
patch:
{{{
#!diff
diff --git a/lib/sqlalchemy/ext/declarative/clsregistry.py
b/lib/sqlalchemy/ext/declarative/clsregistry.py
index 95aba93..a669e37 100644
--- a/lib/sqlalchemy/ext/declarative/clsregistry.py
+++ b/lib/sqlalchemy/ext/declarative/clsregistry.py
@@ -12,7 +12,7 @@ This system allows specification of classes and
expressions used in
from ...orm.properties import ColumnProperty, RelationshipProperty, \
SynonymProperty
from ...schema import _get_table_key
-from ...orm import class_mapper
+from ...orm import class_mapper, interfaces
from ... import util
from ... import exc
import weakref
@@ -190,19 +190,21 @@ class _GetColumns(object):
def __getattr__(self, key):
mp = class_mapper(self.cls, configure=False)
if mp:
- if not mp.has_property(key):
+ if key not in mp.all_orm_descriptors:
raise exc.InvalidRequestError(
"Class %r does not have a mapped column named
%r"
% (self.cls, key))
- prop = mp.get_property(key)
- if isinstance(prop, SynonymProperty):
- key = prop.name
- elif not isinstance(prop, ColumnProperty):
- raise exc.InvalidRequestError(
- "Property %r is not an instance of"
- " ColumnProperty (i.e. does not correspond"
- " directly to a Column)." % key)
+ desc = mp.all_orm_descriptors[key]
+ if desc.extension_type is interfaces.NOT_EXTENSION:
+ prop = desc.property
+ if isinstance(prop, SynonymProperty):
+ key = prop.name
+ elif not isinstance(prop, ColumnProperty):
+ raise exc.InvalidRequestError(
+ "Property %r is not an instance of"
+ " ColumnProperty (i.e. does not
correspond"
+ " directly to a Column)." % key)
return getattr(self.cls, key)
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2761>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-17 23:46:43
|
#2756: enhancements for PropComparator adaption vs. AliasedClass, etc.
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: task | Status: closed
Priority: high | Milestone: 0.9.0
Component: orm | Severity: major - 1-3 hours
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* status_field: in queue => completed/closed
Comment:
r7f82168cb6b0f0e22d387f
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2756#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-17 21:48:42
|
#2751: assocaition proxy support for scalar-targeted attributes
-----------------------------------+----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: reopened
Priority: high | Milestone: 0.9.0
Component: ext | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status_field: in progress => completed/closed
Comment:
r42d58f8b6e67c0182
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2751#comment:6>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-17 21:45:45
|
#1939: Automatic expiration of related properties (objects or collections), i.e.
when the FK attribute changes. you know, this thing.
-----------------------------------+-------------------------------
Reporter: kentbower | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.x.xx
Component: orm | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: not decided upon |
-----------------------------------+-------------------------------
Comment (by kentbower):
Replying to [comment:15 zzzeek]:
> recipe added, [wiki:UsageRecipes/ExpireRelationshipOnFKChange]
Thanks for the recipe!
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1939#comment:16>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-17 21:26:17
|
#2760: "expire=False" option on session.commit() ?
-------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.0
Component: orm | Severity: minor - half an hour
Keywords: | Progress State: in queue
-------------------------+---------------------------------------
to go with close(permanent=True)
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2760>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-06-16 03:02:46
|
#2072: add c.execution_options(isolation_level='AUTOCOMMIT') for psycopg2 dialect
-----------------------------------+----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: closed
Priority: high | Milestone: 0.8.xx
Component: postgres | Severity: minor - half an hour
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* status_field: in queue => completed/closed
Comment:
rf7e6112d0f973f98659397de598cf47ae2043061 0.8 docs
r7a3a446d02b2155 0.8
ra1ceae2ed3b3996d5b8a55 master
rd826d99544c5c2 master / docs
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2072#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|