Hi,
I was trying to define a subclass of CheckConstraint to match a column
(whose name is given) to a regexp.
class CodenameConstraint(CheckConstraint):
"""Check that the column uses a limited alphabet."""
def __init__(self, column_name):
column = ColumnClause(column_name)
Hey Mike,
Looks like I spoke too soon -- a few more questions:
Using the example code you posted, we're actually seeing 4 additional
queries (one per result model), rather than the expected 3 (one per result
model type). If you print context.query inside load_extra, I think it's
clear why:
-
Thanks a ton for your help, Mike!
We played around with it and are pretty happy with your solution using the
load() event, so we'll be using that moving forward.
Damon
On Wednesday, March 29, 2017 at 2:40:39 PM UTC-7, Mike Bayer wrote:
>
> I have a working version of both loading relationships
On Monday, April 3, 2017 at 7:09:41 PM UTC-4, Jason T. wrote:
>
> I think there may be even a cleaner way to do this since I have
> relationships() built into the models,
>
In that case, you will need to use "contains_eager" if you play on
iterating on any of the relationships
http://d
Yes, I had read the documentation. I am just new to SQL and databases in
general. I think there may be even a cleaner way to do this since I have
relationships() built into the models, but since the tables have multiple
foreign keys I think I had to specify the "on clause" anyhow. Thanks for
th
Have you read the tutorial at
http://docs.sqlalchemy.org/en/rel_1_1/orm/tutorial.html#querying-with-joins
and read all the examples at
http://docs.sqlalchemy.org/en/rel_1_1/orm/query.html#sqlalchemy.orm.query.Query.join?
There's nothing odd about the joins you're trying to build here.
Yo
On 04/03/2017 04:31 PM, Colton Allen wrote:
No worries, we ended up dropping the relationship. Still a curious
error, though.
not too much, the relationship was definitely leaking between what
should normally be split across primaryjoin/secondaryjoin if the
"secondary" argument is in place
noting that your example is erroneously referring to "mysql", the trace
you describe is against Postgresql, issue
https://bitbucket.org/zzzeek/sqlalchemy/issues/3955/connectionless-execution-autocommit-on
is added and fix targeted at 1.1.9 is at
https://gerrit.sqlalchemy.org/#/q/I235a25daf4381b
Okay. I figured out how to use the ORM without joins, but I still can't
figure out how to use the joins. :(
bus1_alias = aliased(sam.Bus)
bus2_alias = aliased(sam.Bus)
branch_db = self.db_hook.session.query(sam.Branch). \
filter(sam.Branch.id_model == sam.Bus.id_model). \
filter(sam.Bran
No worries, we ended up dropping the relationship. Still a curious error,
though.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflo
On 04/03/2017 03:19 PM, Colton Allen wrote:
|
class EntryModel(Model):
word_count = db.relationship(
'WordCountModel', backref='entry', secondary='transcription',
primaryjoin='and_('
'WordCountModel.transcription_id == TranscriptionModel.id,'
'TranscriptionModel
Thank tou, I solved the problem with this code :
def name_for_collection_relationship(base, local_cls, referred_cls,
constraint):
disc = '_'.join(col.name for col in constraint.columns)
return referred_cls.__name__.lower() + '_' + disc + "_collection"
Le lundi 3 avril 2017 17:41:20 UTC
class EntryModel(Model):
word_count = db.relationship(
'WordCountModel', backref='entry', secondary='transcription',
primaryjoin='and_('
'WordCountModel.transcription_id == TranscriptionModel.id,'
'TranscriptionModel.entry_id == EntryModel.id,'
'Transcriptio
All,
I am able to join two tables and get the desired result with the below SQL
syntax; however, I am having trouble translating this SQL to the ORM join
syntax. Any help will be appreciated.
SELECT *
FROM raw.branch as b
JOIN raw.bus AS bus1
ON bus1.id = b.id_from_bus
AND bus1.id_model
Hello everyone,
I encountered a surprising behavior of the postres specific insert when
using UniqueConstraint.
A test code :
from sqlalchemy import Column, Integer, String, UniqueConstraint,
create_engine
from sqlalchemy.dialects.postgresql import insert as pg_insert
from sqlalchemy.ext.decla
On 04/03/2017 11:48 AM, Shane Carey wrote:
So the reason the children are marked for delete is because they are no
longer associated with the parent, and for that same reason the expunge does
not propagate to them.
As much as I wish this would work for me, I have to agree with you. Is
there an
So the reason the children are marked for delete is because they are no
longer associated with the parent, and for that same reason the expunge does
not propagate to them.
As much as I wish this would work for me, I have to agree with you. Is
there any way to prevent
the delete from occurring on
On 04/03/2017 09:53 AM, Артём Мигда wrote:
Hi,
I trying to use schema_translate_map in my project and I encountered
with strange behavior of execution_options binding. Here's a code with
session creation:
DBSession = scoped_session(sessionmaker())
session = DBSession()
session.connection(exec
On 04/03/2017 09:52 AM, Shane Carey wrote:
I am getting an error where delete orphan on a relationship seems to
happen even when the parent object is expunged.
I reproduced the issue in this example.
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import
hi -
this is perhaps a case automap should come up with something easier for,
and at least have a note in the docs that refers to this specifically,
however the general approach is to apply a naming convention to the
relationships that will allow the conflict to resolve. you'd define
name_f
Hi,
I trying to use schema_translate_map in my project and I encountered with
strange behavior of execution_options binding. Here's a code with session
creation:
DBSession = scoped_session(sessionmaker())
session = DBSession()
session.connection(execution_options={
'schema_translate_map`: {
I am getting an error where delete orphan on a relationship seems to happen
even when the parent object is expunged.
I reproduced the issue in this example.
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import *
Base = declarative_base()
class Parent(Bas
22 matches
Mail list logo