8000 Issues with `mixer.SKIP` · Issue #122 · klen/mixer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Issues with mixer.SKIP #122
Open
Open
@multimeric

Description

@multimeric

I noticed in the tests, and the source code, that there is a mixer.SKIP property that can be used to skip the generation of certain fields:

mixer/tests/test_main.py

Lines 287 to 291 in 6af15d5

def test_skip():
mixer = Mixer()
test = mixer.blend(Test, one=mixer.SKIP)
assert test.one is not mixer.SKIP
assert test.one is int
.

My first question is, why is this not documented? It seems to be tested so it must work for normal use.

My second question involves using SKIP with the SQLAlchemy backend. I've noticed if you try to use these together, you'll get an error:

# I think the model you use here can be anything that has a relationship field
x = mix.blend(models.ReportMeta, report_meta_key='key_1', report_meta_value='1', report=mix.SKIP)

And you get:

Traceback (most recent call last):
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/mixer/main.py", line 568, in blend
    return type_mixer.blend(**values)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/mixer/main.py", line 140, in blend
    target = self.postprocess(target, postprocess_values)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/mixer/backend/sqlalchemy.py", line 76, in postprocess
    setattr(target, name, value)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 262, in __set__
    instance_state(instance), instance_dict(instance), value, None
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 975, in set
    value = self.fire_replace_event(state, dict_, value, old, initiator)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 998, in fire_replace_event
    state, value, previous, initiator or self._replace_token
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 1407, in emit_backref_from_scalar_set_event
    instance_state(child),
AttributeError: Mixer (<class 'megaqc.model.models.ReportMeta'>): 'object' object has no attribute '_sa_instance_state'

I assume this is a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0