-
Notifications
You must be signed in to change notification settings - Fork 13
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
Enhancement request: How to get an object by primary key when it is a composite key #7
Comments
paxet
changed the title
Enhancement reques: How to get an object by primary key when it is a composite key
Enhancement request: How to get an object by primary key when it is a composite key
Sep 10, 2018
Are you sure you've posted a correct example? The following works for me:
|
My fault, sorry. from pony.orm import *
db = Database()
class MyEntity(db.Entity):
a = Required(str)
b = Required(str)
PrimaryKey(a, b)
db.bind(provider='sqlite', filename=':memory:')
db.generate_mapping(create_tables=True)
with db_session():
ent = MyEntity(a='Key1', b='Key2')
primary_key = str(ent.get_pk())
ent = MyEntity[eval(primary_key)] >>> MyEntity[eval(primary_key)]
MyEntity['Key1', 'Key2'] |
First of all I think this issue relates to pony itself, not pony-doc repository. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using Composite primary keys for an entity and then
entity.get_pk()
it returns a tuple.How to retrieve object from database with that tuple?
I'm seeking something like this:
The text was updated successfully, but these errors were encountered: