Comments (3)
Your query is not correct in:
for user in User.query.filter_by(name='Peter Griffin'):
user.companies = companies
User.query.filter_by(name='Peter Griffin')
returns a query object not an array of User
instances, you should use User.query.filter_by(name='Peter Griffin').all()
.
And in fact it is a weird query, do you have more than one user named "Peter Griffin"? If not you should be using somthing like:
peter = User.query.filter_by(name='Peter Griffin').first()
peter.companies = companies
from stalker.
User.query.filter_by(name='Peter Griffin')
returns a query object not an array ofUser
instances, you should useUser.query.filter_by(name='Peter Griffin').all()
.
Yes, that syntax was a bit weird, perhaps. But if you disregard that syntax (which still demonstrates the issue) I'm getting the same error when using your suggested syntax:
from stalker import db, User, Project, Role, Client, DepartmentUser, ClientUser, ProjectUser
db.setup()
companies = []
for client in Client.query.all():
companies.append(client)
print companies # returns: [<Acme (Client)>, <Quahog (Client)>]
user = User.query.filter_by(name='Peter Griffin').first()
print type(user) # returns: <class 'stalker.models.auth.User'>
print user.name # returns: Peter Griffin
print user.companies # returns: [<Acme (Client)>]
user.companies = companies
print user.companies # returns: [<Acme (Client)>, <Quahog (Client)>]
db.DBSession.commit() # <--- Causes an error "AssertionError: Dependency rule tried to blank-out primary key column 'Client_Users.uid' on instance '<ClientUser at 0x564d320>'"
If you comment db.DBSession.commit()
out, there is no error (but then the change is also not saved).
I've upgraded to cbfa106.
from stalker.
This issue should not be closed.
It is not possible to commit a modification to User.companies
, as described in my previous comment.
from stalker.
Related Issues (20)
- "pip install" fails when stalker exists as dependency HOT 2
- Querying all projects, sorted by client name and then by project name HOT 7
- Postgres pubsub for near-realtime updates HOT 10
- Error in main Readme? HOT 1
- Delete a project with tasks and versions HOT 5
- Cockroach db HOT 2
- Help with SQL query HOT 16
- project creation from help file not working anymore HOT 9
- stalker_pyramid 0.1.0.b1 install error HOT 2
- Please, recreate the WorkingHours for all Studio instances! HOT 2
- Require psycopg2-binary rather than psycopg2 HOT 1
- Will Stalker run fine on postgres v11.5? HOT 2
- ``Version.take_name`` should be renamed to ``Version.variant``
- ``Scene`` should derive from ``Task``
- ``Shot.sequences`` should be ``Shot.sequence``
- Inherited arguments of ``__init__`` functions are not IDE friendly.
- Remove setting the status attribute with int.
- Remove ``Project.is_active`` attribute.
- Rename Task.depends to Task.depends_on
- Add ``stalker.db.declarative.ORMClass.save()``
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stalker.