
Mikki
27.10.2016
13:37:46
Welcome!

Michael
27.10.2016
13:44:15
Hey! Thanks :)

Luckydonald
28.10.2016
00:48:01
5

Mikki
29.10.2016
10:53:33
Welcome!

Google

stsouko
29.10.2016
16:43:36
Hello!
from enum import Enum
from pony.orm.dbapiprovider import IntConverter
class EnumConverter(IntConverter):
def validate(self, val):
if not isinstance(val, Enum):
raise ValueError('Must be an Enum. Got {}'.format(type(val)))
return val
def py2sql(self, val):
return val.value
def sql2py(self, val):
return self.py_type(val)
db.provider.converter_classes.append((Enum, EnumConverter))
class Models(db.Entity):
id = PrimaryKey(int, auto=True)
model_type = Required(ModelType, default=ModelType.PREPARING)
class ModelType(Enum):
PREPARER = 0
Hello!
I tryed to use custom converter.
its work if i do smth as: Models[1].model_type

Rozen
31.10.2016
14:38:45
use ` to make the code less ugly in the chat

stsouko
31.10.2016
14:38:54
but not in queries: select(x.model_type for x in Models)

Rozen
31.10.2016
14:39:20
print ('hello wurld')

stsouko
31.10.2016
14:39:31
ok
`class EnumConverter(IntConverter):
def validate(self, val):
if not isinstance(val, Enum):
raise ValueError('Must be an Enum. Got {}'.format(type(val)))
return val
def py2sql(self, val):
return val.value
def sql2py(self, val):
return self.py_type(val)
db.provider.converter_classes.append((Enum, EnumConverter))`
`
class EnumConverter(IntConverter):
def validate(self, val):
if not isinstance(val, Enum):
raise ValueError('Must be an Enum. Got {}'.format(type(val)))
return val
def py2sql(self, val):
return val.value
def sql2py(self, val):
return self.py_type(val)
db.provider.converter_classes.append((Enum, EnumConverter))
`
oh sheee
http://pastebin.com/yidQy0X6

Google

stsouko
31.10.2016
14:43:02
is it possible?

Alexander
31.10.2016
14:43:41
Multiline examples are wrapped with three backquotes. What error do you get when using select?

stsouko
31.10.2016
14:44:19
TypeError: Unsupported type 'ModelType'
select(x.id for x in Models if x.model_type == ModelType.PREPARER)
I tryed this and got TypeError: Expression ModelType.PREPARER has unsupported type 'ModelType'
если можно на русском, то: я предположил что маппер автоматом раскрывает Енам в число и выполняет запрос. вот и решил сделать так.

Rozen
31.10.2016
14:49:37
D:

Alexander
31.10.2016
14:49:56
We plan to add support of enums, I think it is a bit more complex than in your example. Right now the simplest you can do is to manualy convert enum items to values inside query:
select(x.id for x in Models if x.model_type == ModelType.PREPARER.value)

stsouko
31.10.2016
14:51:43
Thank You for quick response!

Alexander
31.10.2016
14:56:48
Sure
As a short explanation:
It is possible to embed arbitrary Python expression inside a PonyORM query if that expression does not use loop variables. For example
x = 10
y = 'hello'
select(p for p in Person if p.name > foo(bar(x), baz(y)))
In that query foo(bar(x), baz(y)) is external expression which can be evaluated outside of the query. For such expression Pony does eval and get its result. Pony does not analyze what is inside such an expression. The only thing that mater for Pony is the type of the resulted value of a whole external expression.
PonyORM threats ModelType.PREPARER.value as external expression. At this moment PonyORM does not know anything about Enum type, but the resulted type of a whole external expression is int and Pony can process it without any problem.

Luckydonald
01.11.2016
09:43:29

Alexey
01.11.2016
09:44:18
No worries, the reply that follows was in English

Sai Rahul
02.11.2016
02:22:41
Hi Alexey, i have seen http://stackoverflow.com/questions/16115713/how-pony-orm-does-its-tricks question in stack overflow. There are 3 steps in translation and step 1 is described in detail. Can you explain about step2 ? Also is there any good reference on abstract SQL ?

Alexey
02.11.2016
15:10:27
as per the Abstract SQL - it is not documented yet, because it is not a part of the public API. But at some point I think we should provide the documentation for it.

Sai Rahul
03.11.2016
02:29:58
Thanks a lot Alexey

Romet
03.11.2016
16:11:27
Hi! I see the asyncio/futures issue keeps getting bumped on github. Are there any actual plans for this?

Mikki
04.11.2016
18:25:43
Welcome!

Angel
04.11.2016
18:45:35
Thanks

Google

Alexey
05.11.2016
15:16:42

Rozen
05.11.2016
15:18:44
migrations migrations! :D

Romet
05.11.2016
15:19:41
Makes sense, godspeed :)

Luckydonald
05.11.2016
16:08:58

Romet
05.11.2016
16:09:34
I'm personally a huge fan of Django's ORM. If the migration system ends up being anything like it, it would be pretty great :)

Alexey
05.11.2016
16:09:53

Luckydonald
05.11.2016
16:10:16

Alexey
05.11.2016
16:10:54

Luckydonald
05.11.2016
16:12:54
How I would use it, in general
I will see

Angel
05.11.2016
16:18:17
What data pattern does the pony use?

Alexey
05.11.2016
16:22:02

Angel
05.11.2016
16:34:57
Thanks for the answer. I guess Im not very familiar with the nomenclature but, I was referring to as active record or data mapper?

Alexey
05.11.2016
16:51:39
Data Mapper

Angel
05.11.2016
16:55:42
Thanks

Luckydonald
07.11.2016
09:13:16
I still think, this logo feels like Pöny

Михаил
07.11.2016
09:16:41
всем привет, на русском общение приветствуется?

Luckydonald
07.11.2016
09:17:20
I cant read that

Google

Михаил
07.11.2016
09:20:43
Do anybody use pony with tornado?
How about threading-safe?

[Anonymous]
07.11.2016
09:23:39
ДОЛБОЕБ
УВИЖУ ЕЩЕ ОДНО РУССКОЕ СЛОВО
И ПОЛУЧИШЬ ЛЮЛЕЙ
Goodbye guys, have a good day

Luckydonald
07.11.2016
09:24:18
This feels like capslock xD

Romet
07.11.2016
09:28:42
I'm not fluent in russian
But he was being a bit rude

Leonid
07.11.2016
09:30:54

Luckydonald
07.11.2016
09:31:27
I think he joined, said (in Russian) that Russian is bad and left again.

Leonid
07.11.2016
09:32:39
«SO,
MOTHERF**KER
IF I'LL SEE ANY RUSSIAN WORD IN HERE AGAIN
I'LL BEAT YOU IN THE FACE»
If this is ok — welp, this means where is something wrong.

Luckydonald
07.11.2016
09:33:22
I couldn't read it before. Welp thank you.

Михаил
07.11.2016
09:34:48
may be reason is he was ukrainian? :)
so, does anybody used pony orm in async apps?

Luckydonald
07.11.2016
09:38:36
Nope, me did not.

Google

Romet
07.11.2016
13:01:33
I wanted to, but apparently no asyncio support

Михаил
07.11.2016
15:49:13
Guys, may I use Pony's json type for describing array field in postgres?

Angel
07.11.2016
16:38:00
sorry

Alexey
07.11.2016
16:39:06

Angel
07.11.2016
16:40:20
please disregard

Михаил
07.11.2016
16:40:44
as is and without creating own array class?