Re: [sqlalchemy] sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) operator does not exist: jsonb = uuid",

2019-06-20 Thread Mike Bayer
you probably want to use cast() from sqlalchemy.dialects.postgresql import UUID from sqlalchemy import cast cast(MyModel.data['track']['id'], UUID) == UserTrack.id see the examples at https://docs.sqlalchemy.org/en/13/core/type_basics.html#sqlalchemy.types.JSON On Thu, Jun 20, 2019, at 3:25

[sqlalchemy] sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) operator does not exist: jsonb = uuid",

2019-06-20 Thread Jesse Finnegan
Bare with me. I'm some what new to SQL Alchemy so feel free to let me know if there is any info I can provide. I was wondering how I could type cast a jsonb (which should have a UUID init) to a UUID or vice versa in a .join? I have the following code: .join( CandidateActivity,

Re: merging old versions

2019-06-20 Thread Mike Bayer
On Thu, Jun 20, 2019, at 1:45 PM, Michael Merickel wrote: > I think the basic idea is to create a database and codebase in the state of > the target revision. Then autogenerate a migration from nothing to that > revision - just like you would do when starting to use alembic from an > existing

Re: [sqlalchemy] Re: Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-20 Thread Mike Bayer
On Thu, Jun 20, 2019, at 1:50 PM, Jonathan Vanasco wrote: > > > On Thursday, June 20, 2019 at 3:14:06 AM UTC-4, Chris Withers wrote: >> >> How can I indicate in my code that this is intentional and no warning >> should be omitted? > > > Personal option: > > I would not mask these. I

[sqlalchemy] Re: Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-20 Thread Jonathan Vanasco
On Thursday, June 20, 2019 at 3:14:06 AM UTC-4, Chris Withers wrote: > > > How can I indicate in my code that this is intentional and no warning > should be omitted? > Personal option: I would not mask these. I would let them persist and probably add a unittest to ensure they are invoked

Re: merging old versions

2019-06-20 Thread Michael Merickel
I think the basic idea is to create a database and codebase in the state of the target revision. Then autogenerate a migration from nothing to that revision - just like you would do when starting to use alembic from an existing schema. From there you can change the slug on it so that it works as

Re: [sqlalchemy] Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-20 Thread Mike Bayer
On Thu, Jun 20, 2019, at 10:41 AM, Mike Bayer wrote: > > > On Thu, Jun 20, 2019, at 3:14 AM, Chris Withers wrote: >> Hi All, >> >> I'm getting this warning: >> >> SAWarning: Flushing object with incompatible >> polymorphic identity ; the object may not refresh >> and/or load correctly

Re: [sqlalchemy] Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-20 Thread Mike Bayer
On Thu, Jun 20, 2019, at 3:14 AM, Chris Withers wrote: > Hi All, > > I'm getting this warning: > > SAWarning: Flushing object with incompatible > polymorphic identity ; the object may not refresh > and/or load correctly (this warning may be suppressed after 10 occurrences) >

Re: [sqlalchemy] primaryjoin and remote/foreign sides

2019-06-20 Thread Mike Bayer
On Thu, Jun 20, 2019, at 8:39 AM, Julien Cigar wrote: > > > On Wednesday, June 19, 2019 at 9:53:42 PM UTC+2, Mike Bayer wrote: >> >> >> On Wed, Jun 19, 2019, at 10:50 AM, Julien Cigar wrote: >>> That's the (almost) final version if you're interrested: >>>

Re: [sqlalchemy] primaryjoin and remote/foreign sides

2019-06-20 Thread Julien Cigar
On Wednesday, June 19, 2019 at 9:53:42 PM UTC+2, Mike Bayer wrote: > > > > On Wed, Jun 19, 2019, at 10:50 AM, Julien Cigar wrote: > > That's the (almost) final version if you're interrested: > https://gist.github.com/silenius/568aca7545e1bc0400b53b6ec157807d > > > great, I can't run it, so are

Re: [sqlalchemy] Colon notation and wildcard conflict

2019-06-20 Thread Cravan
Dear Simon, Thanks for your quick reply and help! It works now. Cravan On 20/6/19, 6:12 PM, "Simon King" wrote: I think you're using postgresql, so you can use ILIKE instead of LIKE to do a case-insensitive search. Simon On Thu, Jun 20, 2019 at 10:43 AM

Re: [sqlalchemy] Colon notation and wildcard conflict

2019-06-20 Thread Simon King
I think you're using postgresql, so you can use ILIKE instead of LIKE to do a case-insensitive search. Simon On Thu, Jun 20, 2019 at 10:43 AM Cravan wrote: > > Thanks Simon, this works for most cases. However, it still does not work in > some cases for example if I want Avengers:Endgame and

Re: [sqlalchemy] Colon notation and wildcard conflict

2019-06-20 Thread Cravan
Thanks Simon, this works for most cases. However, it still does not work in some cases for example if I want Avengers:Endgame and Avengers: Infinity War to come out if I type avengers(lower_cased). How should I rectify this? Cheers, Cravan On 20/6/19, 5:04 PM, "Simon King" wrote: Are you

Re: [sqlalchemy] Colon notation and wildcard conflict

2019-06-20 Thread Simon King
Are you saying that you want to surround the name that the user tried to search for with wildcards? If so, how about this: name = request.args.get("movie.title") name_pattern = "%" + name + "%" search_movie_statement = sqlalchemy.text('SELECT * FROM movies WHERE title LIKE

merging old versions

2019-06-20 Thread Chris Withers
Hi All, I have some versions that make use of the third party package I no longer use, how do I collapse down alembic revisions that have already been executed everywhere? I found https://stackoverflow.com/questions/34491914/alembic-how-to-merge-all-revision-files-to-one-file but that

[sqlalchemy] Colon notation and wildcard conflict

2019-06-20 Thread Cravan
Hi all, I recently tried to create a search function which is supposed to display all possible results in a table even if the title is incomplete. However, I am using python variables and hence have to use colon notation to sub it into the sql command, however I also learnt

[sqlalchemy] Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-20 Thread Chris Withers
Hi All, I'm getting this warning: SAWarning: Flushing object with incompatible polymorphic identity ; the object may not refresh and/or load correctly (this warning may be suppressed after 10 occurrences)     (state_str(state), dict_[polymorphic_key]), I know why: I'm changing the