Matthew
clients.filter(lambda C: C.termination_date is None)
I think you should prepend clients = to this
Matthew
Filter returns a new query object
Alexander
clients = select(C for C in Clients if Client.village in villages) it looks a bit strange, maybe you mean query = select(C for C in Clients if C.village in villages)
Ben
Yes sorry that's what I meant
Ben
and I do clients = clients.filter(...)
Alexander
and I occasionally get only 3 or 4 in a page (where without the filter I get 10)
Maybe this is the last page of filtered result and it is partially filled?
Matthew
Could you paste the full code as it is please?
Alexander
You can look at the resulted SQL and check if it looks ok
Ben
I decided to rewrite the thing
Ben
and now Im running into a hard query compilation error
Ben
Ill open a ticket
Alexander
ok
Ben
https://github.com/ponyorm/pony/issues/420
Ben
I opened it
Ben
it seems quite serious
Ben
basically its not getting the sorting parameter in the query where it should
Ben
but only in the case where the sorting parameter is used in the intial query
Alexander
The problem is with erroneously added DISTINCT. This is the same problem as in #406 https://github.com/ponyorm/pony/issues/406 As a temporary fix you need to add .without_distinct() before .page(...)
Alexander
This is a non-trivial problem, and I don't know what is the best way to fix it yet
Ben
Oh right
Ben
thanks the without_distinct does the trick for now!
Ben
Ill have a look at Pony code and see if I can find something
Ben
Thanks a lot!!
Genesis Shards Community
dele in cascade, is posible?
Genesis Shards Community
how it is done?
Jim
https://docs.ponyorm.com/working_with_entity_instances.html#cascade-delete
Jim
don't hesitate to spend some time in the doc. it's very clear and well done
Genesis Shards Community
Thans, is configuration!!
Vitaliy
Hi Alexander! Is bitwise comparison supported by pony? I try to test it but received an error: select(u for u in User if u.id | 8 ) …. return method(monad, *args, **kwargs) TypeError: __or__() takes 1 positional argument but 2 were given
Alexander
Probably we need to add it, right now you can use raw_sql fragment: select(u for u in User if raw_sql('u.id | 8'))
Alexander
Is this operator supported in sql?
Alexander
https://www.tutorialspoint.com/postgresql/postgresql_bitwise-operators.htm
Alexander
Wow!
Vitaliy
Good, thanks!
Drop
Hi there! Any solutions for this issues? https://github.com/ponyorm/pony/issues/419 https://github.com/ponyorm/pony/issues/418
Alexander
in 419 what do you mean by default='New table'?
Drop
in 419 what do you mean by default='New table'?
filling a new field with this data (string New table) just example
Alexander
Hi Andrei, we need to fix these. Probably can do it during the weekend
Drop
And in #418 valid solution?
Alexander
It seems there is no way to specify default Json value for a new attribute, we need to fix it
Genesis Shards Community
is posible with MongoDB?
Alexander
PonyORM works with relational databases - PostgreSQL, MySQL, SQLite, Oracle
Lucky
sticker_tag_1 | File "/usr/local/lib/python3.6/site-packages/pony/utils/utils.py", line 77, in cut_traceback sticker_tag_1 | reraise(exc_type, exc, last_pony_tb) sticker_tag_1 | File "/usr/local/lib/python3.6/site-packages/pony/utils/utils.py", line 95, in reraise sticker_tag_1 | try: raise exc.with_traceback(tb) sticker_tag_1 | File "/usr/local/lib/python3.6/site-packages/pony/orm/sqltranslation.py", line 368, in init sticker_tag_1 | throw(NotImplementedError, 'for %s in %s' % (name, ast2src(qual.iter))) sticker_tag_1 | File "/usr/local/lib/python3.6/site-packages/pony/utils/utils.py", line 108, in throw sticker_tag_1 | raise exc # Set "pony.options.CUT_TRACEBACK = False" to see full traceback sticker_tag_1 | NotImplementedError: for t in sm.sticker.tags
Lucky
What's that about
Lucky
throw(NotImplementedError, 'for %s in %s' % (name, ast2src(qual.iter)))
Lucky
I think that was working before.
Lucky
stickers = orm.select( (sm.sticker, max(sm.date)) for sm in StickerMessage if (not hide_deleted or not sm.sticker.deleted) and sm.sticker.nsfw is not True and not orm.exists(t for t in sm.sticker.tags if t.string.lower() == "nsfw") ).order_by(-2).limit(limit+1, offset=offset)
M
Hi, I am running some PonyORM scripts in Jupyter Lab, which has this concept about kernel. I find that as the kernel seems to be open, I can not reexecute the program as it tries to (re)bind the database again. Is there any db.unbind() or something like that?
stsouko
Try to split cells with bind and queries
stsouko
Run binding only one time
Ben
I have a silly question which I cannot seem to find the answer to: when I have an Optional-Optional relationship, is there a way to force the ID to be on one table rather than the other?
Alexander
Yes, you need to explicitly specify column name for that: class Foo(db.Entity): bar = Optional("Bar", column="bar_id", reverse="foo") class Bar(db.Entity): foo = Optional("Foo", reverse="bar")
Ben
Oh right, thanks!
Ben
How does Pony decide which columns gets the ID by default?
Alexander
Pony compares class names "Foo" and "Bar" and put column into entity which name is alphabetically less ("Bar" in this case)
Ben
aah right
Ben
I see
Ben
Thanks a lot for the explanation!
Alexey
Hi everyone! We need your help. Please tell us about your experience with Pony ORM in a three minute survey. Your feedback helps us to create a better experience for you and all Pony ORM users. https://goo.gl/forms/suasXJaxMfKXXkmK2
Ben
Will do!
Alexey
Will do!
Thank you
Ben
😊
Martin
Hab was zu lesen
Alexander
It seems it is indeed not supported yet. Try to replace not orm.exists(t for t in sm.sticker.tags if t.string.lower() == "nsfw") to not orm.exists(t for t in Tag if t in sm.sticker.tags and t.string.lower() == "nsfw")
Lucky
But that must have been like a year ago where I wrote that code. I didn't touched anything there.
Alexander
The expression like this should work if sm is a some variable defined in a previous for-loops of the generator, like this: select(something for x in SomeEntity for sm in x.items # or for sm in AnotherEntity if exists(y for y in sm.sticker.tags if something)) But if I understand correctly, in this specific query sm is a variable containing some object retrieved earlier. In this case, from the Pony point of view, sm.sticker.tags is some external expression (that is, an expresson defined outside of select(...). Not all external expressions can be used as a source of a for-loop. Originally only entity class like SomeEntity can be used as a external source of for-loop. Recently we added queries, like: query1 = select(...) query2 = select(x for x in MyEntity for y in query1 if ...) But not all types of iteators are supported yet. I doubt this query has really worked before. But to be sure, it would be great to have some minimal example, which I can test on previous versions of Pony. There is a slim chance that we indeed broke something while adding array support, but I doubt it
Genesis Shards Community
Lather of insert registr return ID?
Lucky
However I had a look back into my requirements.txt at the time I implemented it, It's based on -e git://github.com/ponyorm/pony.git@dfedd28d02330fb351dc019f4dd03134299c23ab#egg=pony
Alexander
Ok, thanks for the info, maybe I will be able to look into it tomorrow
Lucky
Just did a pip freeze on the server, the version running above is pony==0.7.9.
Alexander
Hi everyone! We need your help. Please tell us about your experience with Pony ORM in a three minute survey. Your feedback helps us to create a better experience for you and all Pony ORM users. https://goo.gl/forms/suasXJaxMfKXXkmK2
S
Hey everyone! Quick question - is it possible to change the class type of a superclass to one of its inherited classes?
Alexander
Hi, can you describe in more details what do you want to do?