Re: [sqlalchemy] Re: Join SQL not optimal with inheritance

2015-01-30 Thread Malthe Borch
On Fri Jan 30 2015 at 4:42:42 PM Jonathan Vanasco jonat...@findmeon.com wrote: This should generate your second query: q = s.query(Foo)\ .join( Boo, Foo.id == Boo.id )\ .join( Bar, Boo.id == Bar.id )\ .first() But I already have

[sqlalchemy] Re: confused on avoiding sql injections using ORM

2011-07-04 Thread Malthe Borch
Think about it this way: There's two kinds of strings when you're dealing with SQL: 1) SQL language, 2) your data input. Don't ever include (2) in (1) –– let the API do it. \malthe On 4 July 2011 21:41, Krishnakant Mane krm...@gmail.com wrote: Hello all. I use Pylons 0.9.7 and sqlalchemy. I

[sqlalchemy] Re: Overriding table columns with Python-property

2008-07-22 Thread Malthe Borch
Michael Bayer wrote: well, i can support this in 0.5 trunk. in rev 4965, If a descriptor is present on a class, or if the name is excluded via the include/ exclude lists, the attribute will not be instrumented via the inherited mapper or via the mapped Table. So your example works with

[sqlalchemy] Re: Overriding table columns with Python-property

2008-07-22 Thread Malthe Borch
Michael Bayer wrote: well, i can support this in 0.5 trunk. in rev 4965, If a descriptor is present on a class, or if the name is excluded via the include/ exclude lists, the attribute will not be instrumented via the inherited mapper or via the mapped Table. So your example works with

[sqlalchemy] Support for old-style classes in inheritance tree

2008-07-22 Thread Malthe Borch
Currently, classes that inherit from old-style classes are not supported on two accounts: 1) They do not provide the __subclasses__-method 2) It's not possible to make a weak reference to them Below is a patch that effectively ignores them: Index: lib/sqlalchemy/util.py

[sqlalchemy] Re: Overriding table columns with Python-property

2008-07-20 Thread Malthe Borch
Michael Bayer wrote: well, i can support this in 0.5 trunk. in rev 4965, If a descriptor is present on a class, or if the name is excluded via the include/ exclude lists, the attribute will not be instrumented via the inherited mapper or via the mapped Table. So your example works with

[sqlalchemy] Re: Overriding table columns with Python-property

2008-07-19 Thread Malthe Borch
Michael Bayer wrote: works for me: I tried adapting your example, which admittedly works :-), to a scenario that better resembles mine, but now the property is overriden simply, even when I use ``exclude_properties``. Note that the setup is overly complex, but this should be seen in the

[sqlalchemy] Overriding table columns with Python-property

2008-07-18 Thread Malthe Borch
I have a table 'test' that defines a column 'col'. I map this table on: class Mapper(object): @property def col(self): return uSome read-only value. passing exclude_properties=('col',). However, when I save and commit an instance of Mapper, I get: [snip] UnmappedColumnError: No

[sqlalchemy] Re: Absurd operational error in SQLite

2008-06-14 Thread Malthe Borch
Michael Bayer wrote: oh. how are you getting it to join from soup- (album join vinyl) ? soup has a relation to album join vinyl and you're using query.join() ? it should be creating an aliased subquery for the right side of the join in that case. I thought 0.4 was able to do

[sqlalchemy] Absurd operational error in SQLite

2008-06-13 Thread Malthe Borch
When executing a query on some joined SQLA-mapper, SQLite throws the following exception (unlike Postgres, which handles it just fine): OperationalError: (OperationalError) no such column: album.id Here's the query: SELECT album.id AS album_id FROM soup JOIN (album JOIN vinyl ON vinyl.id =

[sqlalchemy] Re: Absurd operational error in SQLite

2008-06-13 Thread Malthe Borch
Michael Bayer wrote: sqlite doesn't like the parenthesis. when making the joins with a SQLA join() construct, you need to make the joins from left to right, i.e.: soup.join(album, ...).join(vinyl, ...) as opposed to: soup.join(album.join(vinyl, ...), ...) Actually, we are sort

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-12 Thread Malthe Borch
Michael Bayer wrote: The most crucial, although not the issue in this specific example, is that the relations table is used both as the secondary table in a relation(), and is also mapped directly to the Relation class. SQLA does not track this fact and even in a working mapping will

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-11 Thread Malthe Borch
I can add to this that the issue occurs only on consequent appends. Here's the excerpt that leads to the IntegrityError, demonstrating this. collection = Collection() session.save(collection) session.flush() vinyl = Vinyl() colletion.records.append(vinyl)

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-11 Thread Malthe Borch
Michael Bayer wrote: you'd have to work this into a full self-contained script which I can run locally since it seems theres some specific usage pattern creating the issue. (i.e. its very difficult for me to piece together snippets and guess where the issue might be occuring). This is

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Malthe Borch
Michael Bayer wrote: A self-referential relationship, when configured as many-to-one, requires the remote_side argument to indicate this, as described in http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_selfreferential . Otherwise it defaults to one-to-many. That

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Malthe Borch
Michael Bayer wrote: would need to see mappings. First, let me mention that this issue only occurs on Postgres; I can't replicate it on SQLite. This is the many-to-many relation table (posted previously): table = rdb.Table( 'relation', metadata, rdb.Column('id',