sqlalchemy-tickets Mailing List for SQLAlchemy (Page 72)
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-10-30 14:36:38
|
#2818: Query.exists() don't works with queries without filters
-----------------------------------+----------------------------------
Reporter: vmagamedov | Owner: zzzeek
Type: defect | Status: closed
Priority: high | Milestone: 0.8.xx
Component: orm | Severity: minor - half an hour
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: reopened => closed
* resolution: => fixed
* status_field: in progress => completed/closed
Comment:
eee219bc7e0656fb8afa9879 master /0.9
2576b5cdfb09fd1fb28 0.8
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2818#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-30 14:30:31
|
#2818: Query.exists() don't works with queries without filters
------------------------------+----------------------------------
Reporter: vmagamedov | Owner: zzzeek
Type: defect | Status: reopened
Priority: high | Milestone: 0.8.xx
Component: orm | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: in progress |
------------------------------+----------------------------------
Changes (by zzzeek):
* status: closed => reopened
* resolution: fixed =>
* status_field: completed/closed => in progress
Comment:
bit of a glitch:
{{{
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class ModelBase(Base):
__tablename__ = 'ModelBases'
id = sa.Column(sa.Integer, primary_key=True)
model_type = sa.Column(sa.Integer)
__mapper_args__ = {'polymorphic_on': model_type}
class Model(ModelBase):
__tablename__ = 'Models'
__mapper_args__ = {'polymorphic_identity': 1}
id = sa.Column(sa.ForeignKey(ModelBase.id), primary_key=True)
sess = sa.orm.Session()
print sess.query(Model).exists()
}}}
generates a select columns warning because use_labels isn't set.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2818#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-27 22:18:23
|
#2855: pypostgresql seems to return int2vector as a list
---------------------------+-----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone: 0.8.xx
Component: postgres | Severity: trivial - <10 minutes
Resolution: fixed | Keywords:
Progress State: in queue |
---------------------------+-----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* severity: minor - half an hour => trivial - <10 minutes
Comment:
r1e2945d26c126f0aad0dbe1c0 0.9 / master
reb58107417d1ce956e6d 0.8
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2855#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-27 22:08:22
|
#2855: pypostgresql seems to return int2vector as a list
----------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.8.xx
Component: postgres | Severity: minor - half an hour
Keywords: | Progress State: in queue
----------------------+---------------------------------------
this is hit when we load "indkey" from pg_indexes in get_indexes.
probably should just cast it as a string.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2855>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-27 21:16:57
|
#2854: readthedocs javascript has changed, not working on site
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: highest | Milestone: 0.9.0
Component: documentation | 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:
commit in rfe7322a05559534fcbacb8a illustrates what's been merged into all
of rel_0_9,8,7,6,5, all RTD has been offloaded to the sqlalchemy.org site
where we can more closely track their updates. fortunately rtd has
enhanced things so our code is a lot simpler on that side as well.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2854#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-27 14:55:36
|
#2854: readthedocs javascript has changed, not working on site
---------------------------+------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: highest | Milestone: 0.9.0
Component: documentation | Severity: major - 1-3 hours
Keywords: | Progress State: in queue
---------------------------+------------------------------------
they have some new variables to look up and such. we will remove
rtd_layout.mako from the SQLAlchemy versions and move all this code out to
the sqlalchemyorg wrapper, so that we can make quick changes to RTD things
on the sqlalchemyorg side for all versions. ideally the builds themselves
should refer to the sqlalchemy wrappers/adapters, not RTD at all.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2854>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 23:13:15
|
#2853: oracle reflection over synonym uses wrong owner
-----------------------------------+----------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: high | Milestone: 0.8.xx
Component: oracle | Severity: minor - half an hour
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* status_field: in progress => completed/closed
Comment:
rf1905b619d90163771b61ff99f8f9661b031dbd7 0.8
r5070c81ab963c1432bbbecf38d4cad7ac7b81652 master
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2853#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 23:06:46
|
#2853: oracle reflection over synonym uses wrong owner
--------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.8.xx
Component: oracle | Severity: minor - half an hour
Keywords: | Progress State: in progress
--------------------+---------------------------------------
{{{
#!diff
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -841,7 +841,8 @@ class OracleDialect(default.DefaultDialect):
clauses.append("synonym_name = :synonym_name")
params['synonym_name'] = desired_synonym
if desired_owner:
- clauses.append("table_owner = :desired_owner")
+ clauses.append("owner = :desired_owner")
+ #clauses.append("table_owner = :desired_owner")
params['desired_owner'] = desired_owner
if desired_table:
clauses.append("table_name = :tname")
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2853>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:59:05
|
#2810: Single Item support for Association Proxy
-----------------------------------+----------------------------------
Reporter: jonathan | 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: new => closed
* resolution: => fixed
* status_field: in queue => completed/closed
Comment:
r91ae63569df12654e0eae576
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2810#comment:8>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:31:00
|
#2707: stacklevel for SAWarning about Unicode types
----------------------------+-------------------------------
Reporter: iElectric | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: blue sky
Component: sql | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in queue |
----------------------------+-------------------------------
Changes (by zzzeek):
* severity: minor - half an hour => major - 1-3 hours
* milestone: 0.8.xx => blue sky
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2707#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:29:12
|
#2596: type level events for bind/result processors
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: closed
Priority: medium | Milestone: 0.8.xx
Component: sql | Severity: major - 1-3 hours
Resolution: wontfix | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => wontfix
* status_field: not decided upon => completed/closed
Comment:
haven't had a need for this, closing for now
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2596#comment:6>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:26:44
|
#2839: MySQL dialect's get_foreign_keys doesn't parse options
-----------------------------------+-----------------------------------
Reporter: uijllji | Owner:
Type: defect | Status: closed
Priority: high | Milestone: 0.9.0
Component: mysql | Severity: trivial - <10 minutes
Resolution: fixed | Keywords: foreign keys
Progress State: completed/closed |
-----------------------------------+-----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* severity: minor - half an hour => trivial - <10 minutes
* status_field: in queue => completed/closed
Comment:
r51e8e5df469b755ad8ba940a432
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2839#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:26:40
|
#2183: support "ON DELETE/UPDATE" in Foreign Key Reflection
-----------------------------------+-------------------------------
Reporter: guest | Owner: zzzeek
Type: enhancement | Status: closed
Priority: high | Milestone: 0.9.0
Component: schema | Severity: major - 1-3 hours
Resolution: fixed | Keywords:
Progress State: completed/closed |
-----------------------------------+-------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* status_field: in progress => completed/closed
Comment:
pg is mostly in r9d952e0a11709fe35ada2635a79043ca
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2183#comment:5>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:22:26
|
#2839: MySQL dialect's get_foreign_keys doesn't parse options
---------------------------+----------------------------------
Reporter: uijllji | Owner:
Type: defect | Status: new
Priority: high | Milestone: 0.9.0
Component: mysql | Severity: minor - half an hour
Resolution: | Keywords: foreign keys
Progress State: in queue |
---------------------------+----------------------------------
Changes (by zzzeek):
* severity: major - 1-3 hours => minor - half an hour
* milestone: 0.8.xx => 0.9.0
Comment:
AFAICT this is failing strictly because CASCADE has been spelled wrong for
many years:
`kw['on'] = 'RESTRICT|CASCASDE|SET NULL|NOACTION'`
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2839#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 21:22:17
|
#2183: support "ON DELETE/UPDATE" in Foreign Key Reflection
------------------------------+-------------------------------
Reporter: guest | Owner: zzzeek
Type: enhancement | Status: new
Priority: high | Milestone: 0.9.0
Component: schema | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in progress |
------------------------------+-------------------------------
Comment (by zzzeek):
mysql hasn't worked well due to #2839.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2183#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 17:14:28
|
#2787: History state after commit
-----------------------------------+--------------------------------
Reporter: harutune | Owner: zzzeek
Type: defect | Status: closed
Priority: high | Milestone: 0.9.0
Component: orm | Severity: major - 1-3 hours
Resolution: fixed | Keywords: history attributes
Progress State: completed/closed |
-----------------------------------+--------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => fixed
* status_field: in progress => completed/closed
Comment:
r2b1c8eabb10c932f6e83d08147c75bb05f9
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2787#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 15:42:47
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Changes (by schlamar):
* cc: marc.schlaich@… (removed)
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:19>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 15:42:35
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by schlamar):
Just forget it :) I had unique constraints on my ordering column which is
totally non-sense and which I should have realized even before reading the
warning in the documentation...
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:18>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 15:01:01
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by zzzeek):
hi can you please attach an actual code example of what it is you're
trying to do ? thanks. note that this ticket involves specifically
models with unique constraints where rows are being replaced.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:17>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 12:38:01
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by schlamar):
Ok, I definitely should have read the warning in
http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/orderinglist.html.
Disabling the unique constraints right now. The above solution still have
some issues.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:16>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 11:55:07
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by schlamar):
Another update: there are some issues with association proxy handling and
doing flush when the object is not yet fully created (similar to #2809).
So here is a fixed version for the code above:
{{{
#!python
def fix_order_by_constraint(session, obj, field, value):
setattr(obj, field, list())
session.flush() # possibly trigger delete cascade
for v in value:
state = inspection.inspect(v)
if state.deleted:
orm.make_transient(v) # put it back to life
# reset order by fields
for attr in get_order_by_properties(type(obj), field):
if hasattr(v, attr):
setattr(v, attr, None)
value = [get_related_obj(session, obj, v, field) for v in value]
if obj.id:
fix_order_by_constraint(session, obj, field, value)
setattr(obj, field, value)
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:15>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 09:43:01
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by schlamar):
Looks like resetting all order_by properties of revived objects does the
trick:
{{{
#!python
def get_order_by_properties(model, relation_name):
relation = getattr(model, relation_name)
if (hasattr(relation, 'property') and
isinstance(relation.property, RelationshipProperty)):
if relation.property.order_by:
return [c.name for c in relation.property.order_by]
return list()
value = [get_related_obj(session, obj, v, field) for v in value]
setattr(obj, field, list())
session.flush() # possibly trigger delete cascade
for v in value:
state = inspection.inspect(v)
if state.deleted:
orm.make_transient(v) # put it back to life
# reset order by fields
for attr in get_order_by_properties(type(obj), field):
if hasattr(v, attr):
setattr(v, attr, None)
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:14>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 09:23:30
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by schlamar):
Oh no. The solution from above does not work predictably in the following
case:
- Replace the first existing child with a new one
Sometimes the test passes, sometimes not. Error is:
{{{
IntegrityError: (IntegrityError) columns parent_id, position are not
unique u'INSERT INTO ...
}}}
I assume that there is not determined order to update pending instances?
Probably they are in a dict?
Any idea how I can solve this issue?
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:13>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 08:59:12
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Changes (by schlamar):
* cc: marc.schlaich@… (added)
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:12>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-25 08:54:23
|
#2501: the DELETE before INSERT problem
------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.xx
Component: orm | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+---------------------------------------
Comment (by schlamar):
I'm running in the same issue than #2765 but I have more complicated edge
cases.
My main functionality is to update an object from a dict, so e.g. `d =
{'children': [dict(z=1), dict(id=1, z=2)]` will create a new child for the
first entry and will use the existing Child with id 1 from the database.
There are a lot of cases to be considered: replace an existing with a new
one, the other way round, swap two existing children and probably more.
This gets interesting as soon as you have an ordered relationship with
`ordering_list` and a `delete-orphan` and a unique constraint on
(position, parent_id) in the child.
Right now I have "solved" all issues except the swapping by triggering
cascade delete for all existing children and then "reviving" the children
which are still needed by `make_transient`. Next, I fix possible ordering
issues by only adding previously existing objects to the relationship
(because if child id=1 with position=2 should now be on position=1 and a
new child should be on 2, you try to insert child=2 with position=2
first). At last, I set all objects to the relationship.
Here is my code. `get_related_obj` is responsible for creating or querying
the child object.
{{{
old_ids = set([o.id for o in getattr(obj, field)])
value = [get_related_obj(session, obj, v, field) for v in value]
setattr(obj, field, list())
session.flush() # possibly trigger delete cascade
for v in value:
state = inspection.inspect(v)
if state.deleted:
orm.make_transient(v) # put it back to life
new_filtered = [o for o in value if o.id and o.id in old_ids]
setattr(obj, field, new_filtered)
session.flush() # trigger update of position
# now set the correct list
setattr(obj, field, value)
}}}
I'm not sure if this is covering all edge cases, maybe you found something
I missed?
However, my main purpose of this comment is to give you some cases you
should test for this patch. I'm pretty sure that not all of them are
covered :)
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2501#comment:11>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|