Re: [sqlalchemy] Using Python 'sorted' doesn't change data?

2016-11-08 Thread mike bayer
it does not, and as an exercise I'd recommend trying to theorize how sorted() *could* make such an effect - and if it did, what assumptions would it be making? Hopefully this would reveal that the assumptions the library would need to make in order to even make such a thing happen would not

Re: [sqlalchemy] DeclaredAttr

2016-11-08 Thread mike bayer
Run this: from sqlalchemy.orm import configure_mappers configure_mappers() that ensures RefClass's deferred mapping gets set up appropriately. On 11/08/2016 01:39 PM, de...@devinfee.com wrote: First, thanks for your very insightful response. I'm trying to reproduce what you've provided,

Re: [sqlalchemy] SQLite VARBINARY is mapped to NUMERIC type, but sa.dialects.sqlite.dialect.type_descriptor reports VARBINARY

2016-11-08 Thread mike bayer
On 11/08/2016 01:03 PM, Vlad Frolov wrote: I was trying to solve an issue of an incorrect Alembic migration autogeneration for a custom field (SQLAlchemy-Uitls.PasswordType), which fallbacks to VARBINARY type for SQLite and it turned out that SQLAlchemy confuses me: *from* sqlalchemy

Re: [sqlalchemy] DeclaredAttr

2016-11-08 Thread devin
First, thanks for your very insightful response. I'm trying to reproduce what you've provided, but I'm getting an `InvalidRequestError` when querying on `RefClass`: *InvalidRequestError: SQL expression, column, or mapped entity expected - got ''* Indeed, RefClass has no `__mapper__`

[sqlalchemy] Re: SQLite VARBINARY is mapped to NUMERIC type, but sa.dialects.sqlite.dialect.type_descriptor reports VARBINARY

2016-11-08 Thread Vlad Frolov
Here are references to the relevant discussions: - https://github.com/kvesteri/sqlalchemy-utils/issues/106 - https://github.com/kvesteri/sqlalchemy-utils/pull/233 On Tuesday, November 8, 2016 at 8:03:45 PM UTC+2, Vlad Frolov wrote: > > I was trying to solve an issue of an incorrect

[sqlalchemy] SQLite VARBINARY is mapped to NUMERIC type, but sa.dialects.sqlite.dialect.type_descriptor reports VARBINARY

2016-11-08 Thread Vlad Frolov
I was trying to solve an issue of an incorrect Alembic migration autogeneration for a custom field (SQLAlchemy-Uitls.PasswordType), which fallbacks to VARBINARY type for SQLite and it turned out that SQLAlchemy confuses me: >>> *from* sqlalchemy *import* VARBINARY >>> *from*

[sqlalchemy] Using Python 'sorted' doesn't change data?

2016-11-08 Thread TomS.
Hi, I know this is silly question, but I just need confirmation - Python 'sorted' doesn't affect in any way data stored in DB? Example: class PPL(db.Model): person_pk_id = db.Column(db.Integer, primary_key=True) person_type = db.Column(db.Integer) person_order_s =

Re: [sqlalchemy] Cannot delete Child still linked to Parent (Dependency rule tried to blank-out primary key column)

2016-11-08 Thread irobin
Thanks a lot, that solved my problem ! On Tuesday, 8 November 2016 17:05:00 UTC+1, Mike Bayer wrote: > > > > On 11/08/2016 10:40 AM, iro...@kpler.com wrote: > > Hello, > > > > I am struggling with this case and so far, I haven't seen on > > documentation or on the different posts, a way to

Re: [sqlalchemy] postgresql array column, fetch only_load() element by index

2016-11-08 Thread Jonathan Vanasco
FYI, if you query via the ORM and load_only, the query should be something like : SELECT primary_key_column, array[1] FROM table; The ORM adds the primary key behind-the-scenes so it can setup the objects. as far as i know, If you need to only load array[1] and not the primary key column,

Re: [sqlalchemy] Cannot delete Child still linked to Parent (Dependency rule tried to blank-out primary key column)

2016-11-08 Thread mike bayer
On 11/08/2016 10:40 AM, iro...@kpler.com wrote: Hello, I am struggling with this case and so far, I haven't seen on documentation or on the different posts, a way to solve my problem. Firstly, I cannot have a ForeignKey linking Child to Parent because Parent has a polymorphic identity, and

[sqlalchemy] Cannot delete Child still linked to Parent (Dependency rule tried to blank-out primary key column)

2016-11-08 Thread irobin
Hello, I am struggling with this case and so far, I haven't seen on documentation or on the different posts, a way to solve my problem. Firstly, I cannot have a ForeignKey linking Child to Parent because Parent has a polymorphic identity, and PostgreSQL is not dealing with ForeignKey in such

Re: [sqlalchemy] Malformed whereclause for relationship with custom primaryjoin

2016-11-08 Thread mike bayer
On 11/08/2016 08:00 AM, Sebastian Eckweiler wrote: Hi there, I'm having an issue when building queries against a relationship using a custom primaryjoin. The issue can be reproduced with a slightly modified Users/Address model as taken from the docs: |

[sqlalchemy] Malformed whereclause for relationship with custom primaryjoin

2016-11-08 Thread Sebastian Eckweiler
Hi there, I'm having an issue when building queries against a relationship using a custom primaryjoin. The issue can be reproduced with a slightly modified Users/Address model as taken from the docs: from sqlalchemy import Integer, ForeignKey, String, Column from sqlalchemy.ext.declarative

Re: [sqlalchemy] postgresql array column, fetch only_load() element by index

2016-11-08 Thread Simon King
If you have an SQLAlchemy session, you would write this: session.query(Model.array[1]).all() Assuming your "Model.query" is a shorthand for "session.query(Model)", you might be able to use: Model.query.with_entities(Model.array[1]).all() Simon On Tue, Nov 8, 2016 at 10:12 AM, Dorian

Re: [sqlalchemy] postgresql array column, fetch only_load() element by index

2016-11-08 Thread Dorian Hoxha
Hi Simon, It all works. All I need is how to do: Model.query.options(load_only(Model.array[1])).all() ? Thanks On Tue, Nov 8, 2016 at 10:56 AM, Simon King wrote: > On Tue, Nov 8, 2016 at 9:31 AM, Dorian Hoxha > wrote: > > So, > > > > I

[sqlalchemy] postgresql array column, fetch only_load() element by index

2016-11-08 Thread Dorian Hoxha
So, I want to do "SELECT array[1] FROM table;". Meaning to select only 1 element. Is this possible (didn't find by searching docs,mailing-list,google). Though I can do it by normal query. Thank You -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper