sqlalchemy-tickets Mailing List for SQLAlchemy (Page 71)
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-11-11 03:35:49
|
#2863: ParseError on installation, Python 3.3
----------------------------------+------------------------------------
Reporter: Julian_O | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: (none) | Severity: no triage selected yet
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by Julian_O):
The first two lines in question are of the format:
{{{
>>> print Session().query(User, User.balance).\\
... join(User.accounts).filter(User.balance > 5000)
}}}
i.e. they are doctest strings, using the Python 2.x format.
I wonder if 2to3 is being confused by the existence of an old format print
statement within a comment.
I suggest replacing it with the new style print function (i.e.
parenthesis) to satisfy 2to3.
{{{
>>> print(Session().query(User, User.balance).\\
... join(User.accounts).filter(User.balance > 5000))
}}}
If that doesn't work, replace print with str.
{{{
>>> str(Session().query(User, User.balance).\\
... join(User.accounts).filter(User.balance > 5000))
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2863#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-11 03:28:47
|
#2863: ParseError on installation, Python 3.3
----------------------+-----------------------------------------
Reporter: Julian_O | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: (none) | Severity: no triage selected yet
Keywords: | Progress State: awaiting triage
----------------------+-----------------------------------------
When installing in Python 3.3, the setup script gives a !ParseError. It is
not clear if this is actually interfering with any functionality, but it
is a concerning flag, and is one of the first experiences users have with
the software.
The errors in question are:
{{{
Can't parse docstring in build\lib\sqlalchemy\ext\hybrid.py line 247:
ParseError: bad token: type=55, value='\\', context=('', (247, 42))
Can't parse docstring in build\lib\sqlalchemy\ext\hybrid.py line 448:
ParseError: bad token: type=55, value='\\', context=('', (450, 41))
Can't parse docstring in build\lib\sqlalchemy\sql\expression.py line
5607: ParseError: bad token: type=55, value='\\', context=('', (5607, 38))
}}}
I am not very familiar with the tool, but I think these might be output
from 2to3.
It works fine on Python 2.7.5, 32-bit, Windows.
It gives the errors on Python 3.3, 64-bit, Windows.
Here is the full output:
{{{
>pip install sqlalchemy
Downloading/unpacking sqlalchemy
Downloading SQLAlchemy-0.8.3.tar.gz (3.9MB): 3.9MB downloaded
Running setup.py egg_info for package sqlalchemy
warning: no files found matching '*.jpg' under directory 'doc'
no previously-included directories found matching 'doc\build\output'
***************************************************************************
WARNING: C extensions are not supported on this Python platform,
speedups are not enabled.
Plain-Python build succeeded.
***************************************************************************
Installing collected packages: sqlalchemy
Running setup.py install for sqlalchemy
Fixing build\lib\sqlalchemy\event.py build\lib\sqlalchemy\events.py
build\lib\sqlalchemy\exc.py build\lib\sqlalchemy\inspection.py
build\lib\sqlalchemy\interfaces.py build\lib\sqlal
\sqlalchemy\dialects\drizzle\__init__.py
build\lib\sqlalchemy\dialects\firebird\base.py
build\lib\sqlalchemy\dialects\firebird\fdb.py
build\lib\sqlalchemy\dialects\firebird\kinterbasdb.
ts\mysql\base.py build\lib\sqlalchemy\dialects\mysql\cymysql.py
build\lib\sqlalchemy\dialects\mysql\gaerdbms.py
build\lib\sqlalchemy\dialects\mysql\mysqlconnector.py build\lib\sqlalchem
ib\sqlalchemy\dialects\postgresql\pg8000.py
build\lib\sqlalchemy\dialects\postgresql\psycopg2.py
build\lib\sqlalchemy\dialects\postgresql\pypostgresql.py
build\lib\sqlalchemy\dialects\p
uild\lib\sqlalchemy\engine\interfaces.py
build\lib\sqlalchemy\engine\reflection.py
build\lib\sqlalchemy\engine\result.py
build\lib\sqlalchemy\engine\strategies.py build\lib\sqlalchemy\e
e\clsregistry.py build\lib\sqlalchemy\ext\declarative\__init__.py
build\lib\sqlalchemy\orm\attributes.py
build\lib\sqlalchemy\orm\collections.py
build\lib\sqlalchemy\orm\dependency.py b
y build\lib\sqlalchemy\orm\session.py build\lib\sqlalchemy\orm\state.py
build\lib\sqlalchemy\orm\strategies.py build\lib\sqlalchemy\orm\sync.py
build\lib\sqlalchemy\orm\unitofwork.py bu
build\lib\sqlalchemy\testing\mock.py
build\lib\sqlalchemy\testing\pickleable.py
build\lib\sqlalchemy\testing\profiling.py
build\lib\sqlalchemy\testing\requirements.py build\lib\sqlalch
\test_update_delete.py build\lib\sqlalchemy\testing\suite\__init__.py
build\lib\sqlalchemy\util\compat.py
build\lib\sqlalchemy\util\deprecations.py
build\lib\sqlalchemy\util\langhelpers
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
Fixing build\lib\sqlalchemy\event.py build\lib\sqlalchemy\events.py
build\lib\sqlalchemy\exc.py build\lib\sqlalchemy\inspection.py
build\lib\sqlalchemy\interfaces.py build\lib\sqlal
\sqlalchemy\dialects\drizzle\__init__.py
build\lib\sqlalchemy\dialects\firebird\base.py
build\lib\sqlalchemy\dialects\firebird\fdb.py
build\lib\sqlalchemy\dialects\firebird\kinterbasdb.
ts\mysql\base.py build\lib\sqlalchemy\dialects\mysql\cymysql.py
build\lib\sqlalchemy\dialects\mysql\gaerdbms.py
build\lib\sqlalchemy\dialects\mysql\mysqlconnector.py build\lib\sqlalchem
ib\sqlalchemy\dialects\postgresql\pg8000.py
build\lib\sqlalchemy\dialects\postgresql\psycopg2.py
build\lib\sqlalchemy\dialects\postgresql\pypostgresql.py
build\lib\sqlalchemy\dialects\p
uild\lib\sqlalchemy\engine\interfaces.py
build\lib\sqlalchemy\engine\reflection.py
build\lib\sqlalchemy\engine\result.py
build\lib\sqlalchemy\engine\strategies.py build\lib\sqlalchemy\e
e\clsregistry.py build\lib\sqlalchemy\ext\declarative\__init__.py
build\lib\sqlalchemy\orm\attributes.py
build\lib\sqlalchemy\orm\collections.py
build\lib\sqlalchemy\orm\dependency.py b
y build\lib\sqlalchemy\orm\session.py build\lib\sqlalchemy\orm\state.py
build\lib\sqlalchemy\orm\strategies.py build\lib\sqlalchemy\orm\sync.py
build\lib\sqlalchemy\orm\unitofwork.py bu
build\lib\sqlalchemy\testing\mock.py
build\lib\sqlalchemy\testing\pickleable.py
build\lib\sqlalchemy\testing\profiling.py
build\lib\sqlalchemy\testing\requirements.py build\lib\sqlalch
\test_update_delete.py build\lib\sqlalchemy\testing\suite\__init__.py
build\lib\sqlalchemy\util\compat.py
build\lib\sqlalchemy\util\deprecations.py
build\lib\sqlalchemy\util\langhelpers
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
Can't parse docstring in build\lib\sqlalchemy\ext\hybrid.py line 247:
ParseError: bad token: type=55, value='\\', context=('', (247, 42))
Can't parse docstring in build\lib\sqlalchemy\ext\hybrid.py line 448:
ParseError: bad token: type=55, value='\\', context=('', (450, 41))
Can't parse docstring in build\lib\sqlalchemy\sql\expression.py line
5607: ParseError: bad token: type=55, value='\\', context=('', (5607, 38))
warning: no files found matching '*.jpg' under directory 'doc'
no previously-included directories found matching 'doc\build\output'
***************************************************************************
WARNING: C extensions are not supported on this Python platform,
speedups are not enabled.
Plain-Python build succeeded.
***************************************************************************
Successfully installed sqlalchemy
Cleaning up...
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2863>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-10 08:25:45
|
#2862: dogpile helloworld is all wrong
---------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: highest | Milestone: 0.8.xx
Component: documentation | Severity: minor - half an hour
Keywords: | Progress State: in queue
---------------------------+---------------------------------------
we removed the "namespace" concept but helloworld.py is all about
namespacing, with comments that make no sense re: the code. kind of
strange.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2862>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-08 23:21:11
|
#2861: document use of version_id_col with versioning example
--------------------------------+-----------------------------------
Reporter: bikbit | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.9.0
Component: documentation | Severity: trivial - <10 minutes
Resolution: | Keywords: versioning
Progress State: in queue |
--------------------------------+-----------------------------------
Changes (by zzzeek):
* milestone: 0.8.xx => 0.9.0
* component: utils => documentation
* severity: very major - up to 2 days => trivial - <10 minutes
* status_field: awaiting triage => in queue
Comment:
sure, this is a natural effect of the two transactions not being entirely
isolated. If you have your isolation set at at least REPEATABLE READ then
you wouldn't get this issue.
you can alleviate this condition using a different kind of "versioning"
which is the mapper-level versioning feature, see
http://docs.sqlalchemy.org/en/rel_0_9/orm/mapper_config.html#configuring-a
-version-counter.
I've committed a proof of concept for this in rac54ba0f2d8df5a76b685284.
A change could be to make this a flag on the `Versioned` class itself and
to add documentation.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2861#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-08 21:17:28
|
#2861: Hazard during versioning records
------------------------+--------------------------------------------
Reporter: bikbit | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.8.xx
Component: utils | Severity: very major - up to 2 days
Keywords: versioning | Progress State: awaiting triage
------------------------+--------------------------------------------
Problem description:
Two requests from client application works on this same record in short
period of time and sometimes appears integrity error from database on
compound key of historical record: id,version.
My guess/investigations:
When two requests perform operation on this same database record and for
example first finished operation, then second have not actual information
about newest version of historical record and try to save new one with
this same version as first.
Versioning used from example of SqlAlchemy and trigered in event
before_flush.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2861>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-08 18:17:09
|
#2727: ProgrammingError when autoload from PostgreSQL (Amazon Redshift)
---------------------------+----------------------------------
Reporter: ashkop | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.x.xx
Component: postgres | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: on hold |
---------------------------+----------------------------------
Comment (by zzzeek):
note potential pullreq at https://bitbucket.org/zzzeek/sqlalchemy/pull-
request/6/sqlalchemy-to-support-postgresql-80/diff
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2727#comment:13>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-08 01:48:17
|
#2859: Mapper.columns is keyed based on `key` attribute not column name
-----------------------------------+----------------------------------
Reporter: tisdall | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: documentation | Severity: minor - half an hour
Resolution: worksforme | Keywords:
Progress State: completed/closed |
-----------------------------------+----------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => worksforme
* status_field: awaiting triage => completed/closed
Comment:
the result you're getting is correct, the mapping links those columns to
the attribute name specified in declarative first and foremost over that
of .name or .key of the Column itself.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2859#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-08 01:47:10
|
#2860: spam
----------------------------------+------------------------------------
Reporter: spam | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: cextensions | Severity: no triage selected yet
Resolution: invalid | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Changes (by zzzeek):
* reporter: asnmaglot => spam
Old description:
> So everyone is able to uncover precisely the floor lamps, which used is
> normally needed [http://twojalkomat.pl/ alkomaty twojalkomat.pl]?
New description:
spam
--
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2860#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-08 01:46:56
|
#2860: the incontrovertible fact that it is precisely
----------------------------------+------------------------------------
Reporter: asnmaglot | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: cextensions | Severity: no triage selected yet
Resolution: invalid | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => invalid
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2860#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-07 21:03:23
|
#2860: the incontrovertible fact that it is precisely
-------------------------+-----------------------------------------
Reporter: asnmaglot | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: cextensions | Severity: no triage selected yet
Keywords: | Progress State: awaiting triage
-------------------------+-----------------------------------------
So everyone is able to uncover precisely the floor lamps, which used is
normally needed [http://twojalkomat.pl/ alkomaty twojalkomat.pl]?
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2860>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-06 17:14:49
|
#2859: Mapper.columns is keyed based on `key` attribute not column name
----------------------------------+----------------------------------
Reporter: tisdall | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: documentation | Severity: minor - half an hour
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+----------------------------------
Comment (by tisdall):
sorry, I think this is a non-issue but I have no idea how to close the
ticket...
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2859#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-06 16:23:55
|
#2859: Mapper.columns is keyed based on `key` attribute not column name
---------------------------+---------------------------------------
Reporter: tisdall | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: documentation | Severity: minor - half an hour
Keywords: | Progress State: awaiting triage
---------------------------+---------------------------------------
I'm not sure if this is an issue with the documentation or the
implementation. Basically they don't match.
[http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#sqlalchemy.orm.mapper.Mapper.columns
The Mapper docs] say "are keyed based on the attribute name defined in the
mapping, not necessarily the key attribute of the Column itself" but I
have a case where this doesn't appear to be true.
Using [http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#using-
descriptors-and-hybrids the 2nd EmailAddress class in the hybrid docs]
(the first would likely give the same result) I end up getting the "email"
column keyed as "_email".
{{{
inspector = inspect(EmailAddress)
print(dict(inspector.columns))
}}}
results in:
{{{
{'_email': Column('email', String(), table=<email_address>), 'id':
Column('id', Integer(), table=<email_address>, primary_key=True,
nullable=False)}
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2859>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-01 19:25:41
|
#2858: regression w/ sqlite join rewriting
-----------------------------------+-------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: closed
Priority: highest | Milestone: 0.9.0
Component: sqlite | 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:
the fix was easier than it first seemed it would be:
r5d0e84434f116460d64d3078f650d9
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2858#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-01 18:37:47
|
#2857: PostgreSQL LATERAL JOIN support
------------------------------------+----------------------------------
Reporter: jcigar | Owner: zzzeek
Type: enhancement | Status: new
Priority: low | Milestone: 0.x.xx
Component: postgres | Severity: minor - half an hour
Resolution: | Keywords: lateral
Progress State: needs a volunteer |
------------------------------------+----------------------------------
Changes (by zzzeek):
* priority: medium => low
* status_field: awaiting triage => needs a volunteer
* severity: no triage selected yet => minor - half an hour
* milestone: 0.9.xx => 0.x.xx
Comment:
this is pretty easy to do yourself, feel free to turn into a pullreq (with
unit tests of course):
{{{
#!python
class Lateral(Alias):
# ...
@compiles(Lateral, "postgresql")
def compile(element, compiler, **kw):
return "LATERAL %s" % compiler.visit_alias(element, **kw)
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2857#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-01 18:36:02
|
#2858: regression w/ sqlite join rewriting
---------------------+------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: highest | Milestone: 0.9.0
Component: sqlite | Severity: major - 1-3 hours
Keywords: | Progress State: in progress
---------------------+------------------------------------
{{{
#!python
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import *
engine = create_engine('sqlite://', echo=True)
#engine = create_engine('postgresql://scott:tiger@localhost/test',
echo=True)
Base = declarative_base(bind=engine)
metadata = Base.metadata
account = Table('account', metadata,
Column('account_id', Integer, key='id', primary_key=True),
Column('name', String(255), nullable=False),
)
account_address_map = Table('account_address_map', metadata,
Column('account_id', Integer, ForeignKey('account.id'),
nullable=False),
Column('address_id', Integer, ForeignKey('address.id'),
nullable=False),
Column('role_id', Integer, nullable=False)
)
address = Table('address', metadata,
Column('address_id', Integer, key='id', primary_key=True),
Column('address1', String(255), nullable=False),
)
mapping = account_address_map.select().where(account_address_map.c.role_id
== 1)
class Account(Base):
__table__ = account
service_address = relationship('Address',
secondary=mapping,
uselist=False,
viewonly=True)
class Address(Base):
__table__ = address
metadata.drop_all()
metadata.create_all()
session = Session()
session.query(Account).options(joinedload_all('service_address')).all()
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2858>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-11-01 15:27:28
|
#2857: PostgreSQL LATERAL JOIN support
-------------------------+-----------------------------------------
Reporter: jcigar | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.xx
Component: postgres | Severity: no triage selected yet
Keywords: lateral | Progress State: awaiting triage
-------------------------+-----------------------------------------
all is in the title ... :)
[http://wiki.postgresql.org/wiki/What%27s_new_in_PostgreSQL_9.3#LATERAL_JOIN]
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2857>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 19:46:34
|
#2856: ORM mapping of reflected col names that are not ASCII
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
worksforme |
Progress State: |
completed/closed |
-------------------------+-------------------------------------------------
Comment (by teddy):
Thank you!
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:8>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 19:44:22
|
#2856: ORM mapping of reflected col names that are not ASCII
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
worksforme |
Progress State: |
completed/closed |
-------------------------+-------------------------------------------------
Comment (by zzzeek):
here's a doc section on that:
http://docs.sqlalchemy.org/en/rel_0_9/orm/mapper_config.html#automating-
column-naming-schemes-from-reflected-tables
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:7>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 19:08:43
|
#2856: ORM mapping of reflected col names that are not ASCII
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
worksforme |
Progress State: |
completed/closed |
-------------------------+-------------------------------------------------
Comment (by teddy):
Thank's for your explanation, really great. When i'm started with my
experiments, i decided that there is a tricky problem with naming =)
I'm not a very experienced or skilled developer, especially in
architecture and smart separation of components (decomposition), so this a
very good demonstration for me =)
Thanks!
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:6>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 19:04:17
|
#2856: ORM mapping of reflected col names that are not ASCII
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
worksforme |
Progress State: |
completed/closed |
-------------------------+-------------------------------------------------
Comment (by zzzeek):
I'm changing the mapper documentation now to clarify this case.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:5>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 19:00:49
|
#2856: ORM mapping of reflected col names that are not ASCII
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
worksforme |
Progress State: |
completed/closed |
-------------------------+-------------------------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => worksforme
* status_field: awaiting triage => completed/closed
Comment:
OK when i first saw this I assumed the oracle dialect couldn't reflect
those names, but it seems like it is, so wow on that.
Second issue, note that the ORM is an optional component here. The
reflection is working fine as you're getting a `Table` with the names you
want. The issue is that you're mapping that `Table` to a Python class,
a process which by default links the columns to same-named attributes on a
class - and Python 2.x does not accept non-ASCII identifiers - this is not
a SQLAlchemy limitation, it's a Python 2.x one.
So if you wanted to do #1, e.g. `CyrTest.Поле1.`, you could use Python 3
(and you'd definitely want to use 0.9, which is released as beta1 so far,
for the best Py3K compat), otherwise it's not possible. In Python 3 the
reflection + mapping works as is.
Now using a system like a transliteration library, great, that's not a
built-in for SQLAlchemy, you do in fact need to go with the "key"
approach. We provide the "column_reflect" event to most effectively
redefine keys as needed.
Below is an example program against SQLite illustrating both a Python 3
and a Python 2 approach. I don't have a transliteration library
available so I am using `"attr_%s" % hexlify(name.encode('utf-8')` here,
replace that with whatever you'd like.
If the reflection is working then this is as far as we can go, so I'm
closing this as "worksforme".
{{{
#!python
#!coding: utf-8
from sqlalchemy import create_engine, Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session
import sys
e = create_engine("sqlite://", echo=True)
e.execute(u"""
CREATE TABLE test (
"ИД" INTEGER PRIMARY KEY,
"ПОЛЕ1" VARCHAR(20),
"ЕЩЕПОЛЕ" VARCHAR(20)
)
""")
e.execute(u"""
INSERT INTO test ("ИД", "ПОЛЕ1", "ЕЩЕПОЛЕ") VALUES (1, 'v1', 'v2')
""")
py3 = sys.version_info >= (3, )
if not py3:
from sqlalchemy import event
import binascii
@event.listens_for(Table, "column_reflect")
def column_reflect(inspector, table, column_info):
# do whatever encoding/transliteration you'd like here
column_info['key'] = "attr_%s" %
binascii.hexlify(column_info['name'].encode('utf-8'))
Base = declarative_base()
class Foo(Base):
__table__ = Table('test', Base.metadata, autoload=True,
autoload_with=e)
s = Session(e)
f1 = s.query(Foo).first()
if py3:
# using exec so this script runs in py2k as well,
# you can use non-ascii identifiers in py3k.
exec("print(f1.ПОЛЕ1)")
else:
# our hexlified (or transliteterated, or whatever)
print(f1.attr_d09fd09ed09bd09531)
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:4>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 18:10:07
|
#2856: Oracle error with reflect on table with cyrillic column names in
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
Progress State: |
awaiting triage |
-------------------------+-------------------------------------------------
Comment (by teddy):
Hmmm, did some experiments.
I've put some changes to instrumentation.py:
{{{#!python
line 244 setattr(self.class_, key, inst)
}}}
to
{{{#!python
line 244 setattr(self.class_, key.encode('utf-8'), inst)
}}}
and to
{{{#!python
line 1 import trans
...
line 244 setattr(self.class_, key.encode('trans'), inst)
}}}
If we use transliteration, there is a problems such a
{{{SomeMappedClass.__table__.c.keys()}}} returns native field names.
If we use native names, there is a big question with manipulation in
interactive mode...
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 17:49:33
|
#2856: Oracle error with reflect on table with cyrillic column names in
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
Progress State: |
awaiting triage |
-------------------------+-------------------------------------------------
Comment (by teddy):
Another little addition, sorry for my memory =)
If we declare mapped class a bit more explicitly:
{{{#!python
class CyrTest(Base):
__table__ = Table("cyr_test", Base.metadata,
Column(u'ИД', Integer, primary_key=True, key='id'),
Column(u'ПОЛЕ1', String, key='field1'),
Column(u'ЕЩЕПОЛЕ', String, key='field2'),
oracle_resolve_synonyms=True,
autoload=True
)
}}}
It will reflect on table successfully. The problem in keys, of course.
I dont't know how to resolve this situation, but i see 2 ways:
At first, we can just use colimn names as is, so we can write something
like {{{CyrTest.Поле1}}}.
At second, we can trasliterate names to latin, and use something like
{{{CyrTest.Pole1}}}.
Transliteration libraries is present for Python, for example
https://pypi.python.org/pypi/trans, which i use in my projects.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 17:25:41
|
#2856: Oracle error with reflect on table with cyrillic column names in
-------------------------+-------------------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: | Severity: no triage selected yet
declarative | Keywords: oracle, cyrillic, declarative,
Resolution: | reflexion
Progress State: |
awaiting triage |
-------------------------+-------------------------------------------------
Comment (by teddy):
Little addition. This bug is present in a 0.7.x version too, just forgot
to post it then.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 17:01:19
|
#2856: Oracle error with reflect on table with cyrillic column names in
-------------------------------------+-------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: declarative | Severity: no triage selected
Keywords: oracle, cyrillic, | yet
declarative, reflexion | Progress State: awaiting triage
-------------------------------------+-------------------------------------
There is a bug with reflexion on cyrillic column names in Oracle.
Lets assume we have a table with such DDL:
{{{
#!sql
CREATE TABLE cyr_test (
"ИД" NUMBER CONSTRAINT id_demo NOT NULL,
"ПОЛЕ1" VARCHAR2,
"ЕЩЕПОЛЕ" VARCHAR2,
CONSTRAINT с_id_pk_demo PRIMARY KEY ("ИД")
);
}}}
So we try to reflect on this table in sqlalchemy:
{{{
#!python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy import *
from sqlalchemy.orm import sessionmaker
engine = create_engine('oracle+cx_oracle://<some_conn_string>,
encoding="windows-1251", optimize_limits=True, use_binds_for_limits=False,
echo='debug', coerce_to_decimal=False)
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base(bind=engine)
S = sessionmaker(bind=engine)
s = S()
class CyrTest(Base):
__table__ = Table("cyr_test", Base.metadata,
Column(u'ИД', Integer, primary_key=True),
oracle_resolve_synonyms=True,
autoload=True
)
}}}
And, getting this error:
{{{#!python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 14, in <module>
class CyrTest(Base):
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative\api.py",
line 5
0, in __init__
_as_declarative(cls, classname, cls.__dict__)
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative\base.py",
line
292, in _as_declarative
mt.map()
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative\base.py",
line
376, in map
**mapper_args
File "C:\Python27\lib\site-packages\sqlalchemy\orm\__init__.py", line
1229, in
mapper
return Mapper(class_, local_table, *args, **params)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 219,
in __
init__
self._configure_properties()
File "C:\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 904,
in _c
onfigure_properties
setparent=True)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line
1181, in _
configure_property
prop.instrument_class(self)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\properties.py", line
128, i
n instrument_class
doc=self.doc
File "C:\Python27\lib\site-packages\sqlalchemy\orm\attributes.py", line
1449,
in register_descriptor
manager.instrument_attribute(key, descriptor)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\instrumentation.py",
line 1
92, in instrument_attribute
self.install_descriptor(key, inst)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\instrumentation.py",
line 2
44, in install_descriptor
setattr(self.class_, key, inst)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
ordin
al not in range(128)
}}}
With another table, without cyrillic column names, everything works fine.
Tested on sqlalchemy 0.8.1/0.8.3/0.9.0b1 in Python 2.7.2 (ActiveState
ActivePython 2.7.2.5), Windows 7 x64, Oracle 11g.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|