Gah! That's it, make_transient_to_detached does everything as you said.
I do truly only need "simple" loading on my objects, anything that has a
many-to-many relationship (they're in 3 separate areas), which would
require a separate dB call normally, I just set those manually.
Thanks Mike.
On Sun, Sep 30, 2018 at 9:39 AM seaders wrote:
>
> Well, here's my solution that works exactly the way I want it,
>
> @classmethod
> def from_flat_json(cls, d=None, db_enable_relationship_loading=True,
>**kwargs):
> # noinspection PyArgumentList
> new_instance =
Well, here's my solution that works exactly the way I want it,
@classmethod
def from_flat_json(cls, d=None, db_enable_relationship_loading=True,
**kwargs):
# noinspection PyArgumentList
new_instance = cls(**d, **kwargs)
state = instance_state(new_instance)
My advice is to simply make a sqlite memory database for testing which is
an almost universal pattern for test suites.
You can even make a database per test, that's a common pattern. Otherwise
you have to mock everything and yes "double job" it. The ORM doesn't want
to "double job" it either,
I've made my system with SQLAlchemy objects pretty pivotal to how it runs.
For testing, I'm not actually testing the dB, I'm testing other areas of
flow of my project, so - as much as possible - I don't necessarily want to
change its setup.
I would just like to have a kind of "snapshot" of my
On Sat, Sep 29, 2018 at 11:18 AM seaders wrote:
>
> Yes, that's exactly what I want. No queries to the database, at any time
> exactly.
>
> However, doing that, I get
>
> sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table:
> sport [SQL: 'INSERT INTO sport ...]
Yes, that's exactly what I want. No queries to the database, at any time
*exactly*.
However, doing that, I get
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table:
sport [SQL: 'INSERT INTO sport ...] (Background on this error at:
http://sqlalche.me/e/e3q8)
I haven't
On Sat, Sep 29, 2018 at 7:34 AM seaders wrote:
>
> Yep, that helps, nearly doing what I want.
>
> I have a "from_flat_json" function in my base class, so that's a perfect
> place to add the `session.enable_relationship_loading` bit for any created
> objects - that's now working, which is great.
Yep, that helps, nearly doing what I want.
I have a "from_flat_json" function in my base class, so that's a perfect
place to add the `session.enable_relationship_loading` bit for any created
objects - that's now working, which is great.
Only thing that's not wanted / right just yet is the
On Fri, Sep 28, 2018 at 9:41 PM seaders wrote:
>
> I'm writing some tests for my system, and I have all the objects that I
> *would* be getting from the database, as flat json files, which I then load
> up from, to SQLAlchemy files for my tests.
>
> I've all that working fine, but the one place
I'm writing some tests for my system, and I have all the objects that I
*would* be getting from the database, as flat json files, which I then load
up from, to SQLAlchemy files for my tests.
I've all that working fine, but the one place I'd like to improve is
"gluing" them back together /
11 matches
Mail list logo