Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter_by(...).update(...) is not working in inheritance #85

Open
Shiny380 opened this issue Nov 4, 2020 · 1 comment
Open

filter_by(...).update(...) is not working in inheritance #85

Shiny380 opened this issue Nov 4, 2020 · 1 comment

Comments

@Shiny380
Copy link
Collaborator

Shiny380 commented Nov 4, 2020

filter_by(...).update(...) is not working in inheritance
I think I might know the problem with this.
https://hackersandslackers.com/database-queries-sqlalchemy-orm/#:~:text=Unlike%20filter()%20%2C%20filter_by(),match%20the%20arguments%20we%20pass
Unlike filter(), filter_by() accepts keyword arguments (note the difference in syntax here: filter() checks a conditional against a column object whereas filter_by() finds columns which match the arguments we pass). filter_by() can only search for exact values and serves as a kind of shorthand for simple filtering queries.

@Shiny380
Copy link
Collaborator Author

Shiny380 commented Nov 6, 2020

After a little bit of study:

  • filter didn't work but filter_by did work for the RTU/TCP polling get all points
  • the below code snippet shows that filter might have worked if I used PointModel.enable instead of ModbusPointModel.enable but didn't test.
session.query(Engineer).\
    filter(Engineer.id == Employee.id).\
    filter(Employee.name == 'dilbert').\
    delete()

https://docs.sqlalchemy.org/en/13/orm/query.html?highlight=synchronize_session#sqlalchemy.orm.query.Query.delete.params.synchronize_session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant