Christian
Thanks, I'll check!
Christian
It's Azure, making the sqlite read-only 😐
Christian
Thanks for giving it a thought, though.
Алексей
Will PonyORM have a driver for Microsoft SQL Server?
Ben
Hi! Is the use of bool(some_datetime) in a property not supported?
Ben
seems to work fine with Postgres but crashes with SQLite
Alexander
What should it mean?
Ben
True if there is some and False if it is None
Ben
should I just compare to None?
Alexander
you need to write some_datetime is None instead
Ben
thanks!
Ben
clear
Ben
well I guess it is some_datetime is not None
Alexander
Probably so :)
Ben
its kind of odd that it seems to work with Postgres
Ben
but I might be wrong haha
Alexander
Yes, it is unexpected
Ben
I found something that I cannot explain
Ben
this works: addons = orm.select(a for a in self.add_ons if not a.cancelled) return orm.sum(a.total_amount for a in addons if a.loan)
Ben
but this throws AssertionError: addons = orm.select(a for a in self.add_ons if a.loan and not a.cancelled) return orm.sum(a.total_amount for a in addons)
Ben
they should be exactly equivalent
Ben
or am I missing something?
Ben
both "cancelled" and "loan" are properties
Ben
defined as: @property def cancelled(self): return (self.time_canceled is not None) and @property def loan(self): self.type == 'LOAN'
Alexander
AssertionError means some bug in Pony. Can you post the full traceback? I'll try to fix it during the weekend
Ben
Sure
Ben
one sec
Ben
No rush on my side as the other way works perfectly
Ben
just thought you should know
Alexander
Thank you for reporting!
Ben
what's the best way to send it to you?
Alexander
You can put it on https://pastebin.com/ or just send directly, as a personal Telegram message
Rozen
telegram bots couln't highlight python code?
Alexander
no
Ben
https://pastebin.com/Rv4Xc5HT
Alexander
Thanks!
Lucky
Can I somehow set the Application of a session in pony?
Rozen
O.o what would be the "application"?
Rozen
(i have no idea anyway, i just want to understand xD)
Lucky
Preferably something I can set.
Matthew
https://stackoverflow.com/questions/30322206/how-to-set-application-name-for-postgres-connections
Matthew
either execute the set sql command or include application_name in connection string
Алексей
Hello. Sorry. Who will answer me, is it possible to make friends PonyORM and MSSQL Server.
Alexander
Hello. Sorry. Who will answer me, is it possible to make friends PonyORM and MSSQL Server.
Hi! Right now, PonyORM does not support MS SQL Server. We eventually should add support for it, but I don't know when exactly.
Santosh
Can we combine two query object Supoose u1 = select(u for u in user if u.name=test) u2 = select(u for u in user if u.age=10) How do we make something like u1+u2
Alexander
Currently you can try only something like: select(u for u in User if u in u1 or u in u2) It may not always be efficient
Santosh
Okay let me try that
Santosh
It's something like I query again
Alexander
If you want to combine results in memory, it is easier: all_users = set(u1).union(u2)
Santosh
I need query object
Santosh
Further I may apply count or order after combing
Alexander
Then try this: select(u for u in User if u in u1 or u in u2) If you use previous queries u1 and u2 only inside another query they should not be executed separately
Santosh
Understood thanks
Veli
Hi, everyone Ponyorm newbie here :) there is my question: how can i set manual table name for db.entity ?
Alexander
class Person(db.Entity): _table_ = "some_table" name = Required(str)
Veli
Thanks!
Christian
Hi, with a bit of trying out, I arrived at this, but it seems a bit excessive? Can this be reduced to something shorter? area = innovation.areas.random(1)[:1] area = area[0] innovation.active_areas.add(area)
Christian
Especially the random(1)[:1] part, I don't really get why I need the limit and the slice.
Matthew
In [5]: models.Keyword.select().random(1)[0] Out[5]: Keyword[271087]
Alexander
Maybe I missed some context here... What task are you trying to solve?
Christian
I'm trying to get a single, random result from a library (areas) and then adding it to a collection of specific results (active_areas) for this innovation.
Matthew
does it matter if the random area is already in the active areas collection?
Matthew
do you need to care about the case where there are zero areas currently?
Christian
does it matter if the random area is already in the active areas collection?
Yes, it needs to be a different area. There are zero areas currently (first setter).
Alexander
Something like: area_or_empty_list = innovation.areas.select( lambda a: a not in innovation.active_areas ).random(1).fetch() if area_or_empty_list: innovation.active_areas.add( area_or_empty_list )
Alexander
It translates into the one SELECT, then possible one INSERT
Rozen
sweet, thanks
Alexander
And some Python
Christian
👍 Cool, I'll take some time to really get this. Thanks!
Anonymous
🙂
Adam
🙂
*groan*
Alexander
I found something that I cannot explain
Hi Ben, I fixed the AssertionError bug that you reported. Now instead of AssertionError: assert t is translator you should be able to see correct error messages: TranslationError: Addon.loan(...) is too complex to decompile (because it does not have the return statement) and AttributeError: Entity Addon does not have attribute time_canceled: self.time_canceled (inside Addon.cancelled)
Karsten
Hi, I construct a selection string (sel_str) with for i in range (...): code_lst [0] contains 0, code_lst [1] contains 100. The problem is, that only rows with code = 100 are returned. If I swap the values, I only get rows with code = 0 back. Here is the code in question: ... elif cnt > 1: sel_str += " AND (" for i in range(0, len(code_lst)): if len(code_lst[i]) > 0 and code_lst[i][0] != '-': new_code = code_lst[i] sel_str += "(r.code = $new_code) OR " sel_str = sel_str[:-4] + ')' ... Can someone help me ? Thank you
Alexander
Maybe you have limit(1) on your query
Karsten
Maybe you have limit(1) on your query
I have not explicitly set anything! How can I change this ? Or is 'new_code' only adopted at the end of the loop? Then the last value would be inserted everywhere.
Alexander
I think you need to check the resulted SQL of your query
Alexander
Maybe the problem lies somewhere else