
Alexander
17.01.2017
17:01:33
Cool :)

Luckydonald
17.01.2017
17:40:52
pony.orm.core.DBSchemaError: Index for column 'file_id' already exists
Note about which table would be great
Also I now try dropping every Index there is

Micaiah
17.01.2017
17:42:37
sweet!

Google

Alexander
17.01.2017
17:42:39
This error is from the database, we have no control on how it looks. If you turn on sql output by using sql_debug(True) you can see which sql command was executed last

Luckydonald
17.01.2017
17:58:37
Is just printing
GET NEW CONNECTION
RELEASE CONNECTION

Alexander
17.01.2017
18:00:56
ok, it is a bug that should be fixed in the next release...
Do you create index for file_id column manually, or it is the index that Pony generates automatically?

Luckydonald
17.01.2017
18:02:34
I tried to rename the StickerPack table to simply Pack in the database
After changing the python code accordinly
So, yes the current index on file_id is what I created
Maybe I should rollback a backup and wait for migrations.... ...
But than, I never rolled back a backup, so I'll try to get it running again


Alexander
17.01.2017
18:10:18
I think it may be an index for a foreign key column. The Sticker entity has file_id attribute as a primary key, and I can guess that StickerPack entity has some attribute which defined as Required(Sticker) or Optional(Sticker). For such a column there is a foreign key to sticker table, and it is recommended to create an index as well. So Pony creates such indexes automatically. The name of the index includes the table name and looks like idx_stickerpack_attrname. You need to drop such index, and Pony will create new index with name idx_pack_attrname

Luckydonald
17.01.2017
18:13:28
I removed any primary key form file_id in that database

Google

Alexander
17.01.2017
18:13:56
I think that the error is not with primary key, but with additional indexes
Some index which belongs to former stickerpack table and starts with idx_stickerpack_
It should start with idx_pack_ now
You can rename Pack back to StickerPack until migrations isnot released and all should work again

Luckydonald
17.01.2017
18:19:04
Okey, I just dropped all Constraints and Indexes I clould find
Nope.

Alexander
17.01.2017
18:24:33
Did you see indexes with names started with idx_?

Luckydonald
17.01.2017
18:35:35

Micaiah
17.01.2017
19:35:50
that's pretty sweet

Luckydonald
17.01.2017
19:36:00
Finally fixed that database
Finally fixed that database
And @StickerTagBot as well as getstickers.me is up again.
(I really need to add a static served replacement for downtime like that.)
Thanks for your support @akozlovsky !!!
Basically the problem was PrimaryKey() not allowing index=True

Alexander
17.01.2017
19:45:56
Time to do backup ;)

Luckydonald
17.01.2017
19:49:06
But I have no idea how I would import that, so I just solved the issue instead :D

Ngalim
17.01.2017
23:29:07
Did ponyorm only allow one large model.py files ?
Or can we separate to few small files?

Alexander
17.01.2017
23:30:32
Yes, you can split it to many files

Ngalim
17.01.2017
23:32:04

Alexander
17.01.2017
23:34:37
yes
# models1.py
db = Database()
class X(db.Entity):
a = Set("Y") # syntax1
b = Set(lambda: db.Z) # syntax 2
# models2.py
from models1 import db
class Y(db.Entity):
c = Required("X")
# models3.py
from models1 import db
class Z(db.Entity):
d = Optional(lambda: db.X)

Google

Alexander
17.01.2017
23:35:55
when writing queries you can do this
from models1 import X
select(x for x in X if ...)
or that:
from models1 import db
select(x for x in db.X if ...)
If you split entities between several files, then you need to not forget to import all of that files

Micaiah
17.01.2017
23:38:04
yeah so they all get mapped

Alexander
17.01.2017
23:38:08
yes
Also, sometimes it may be convenient to define entities inside a function:
def define_entities(db):
class Person(db.Entity):
name = Required(str)
db = Database()
define_entities(db)
db.bind(...)
db.generate_mapping(...)
with db_session:
select(p for p in db.Person)

Ngalim
17.01.2017
23:45:54

Alexander
18.01.2017
00:28:29
Well, you wrote trainings = orm.Set('Training'), but entity Training is not found :)

Ngalim
18.01.2017
00:41:03
sorry
looks like i need coffee

Luckydonald
18.01.2017
18:03:52
The online editor's Cascade delete setting still is broken, False becomes True in the python code export.
(Video uploading)

Alexey
18.01.2017
18:12:25

Luckydonald
18.01.2017
18:16:41
Apparently a != default check
Also still a bug:
If I edit a text field and click in the editor window, it is not safed
As you see, you have to click another field first, else it isn't stored.

Alexey
18.01.2017
18:32:33

Luckydonald
18.01.2017
18:33:11
fixed
The unfocus one, or the Cascade delete?

Alexey
18.01.2017
18:33:20
both

Google

Luckydonald
18.01.2017
18:33:28
both, ok :D

Alexey
18.01.2017
18:33:50
pls confirm

Luckydonald
18.01.2017
18:34:24
Still missing size=64 for ints, and sql_default='NOW()' for datetimes

Alexey
18.01.2017
18:34:43

Luckydonald
18.01.2017
18:35:34
focus ✅
cascade delete ?
Both default (False) and False result in packs = Set('Pack').
Setting it to False should result in
packs = Set('Pack', cascade_delete=False)
?
Setting it to False should result in
packs = Set('Pack')
✅

Alexey
18.01.2017
18:38:41
you're right

stsouko
18.01.2017
18:53:45
Hello!
class Molecule(db.Entity):
_table_ = (schema, 'molecule')
id = PrimaryKey(int, auto=True)
date = Required(datetime, default=datetime.utcnow())
data = Required(Json)
fear = Required(str, unique=True)
fingerprint = Required(str, sql_type='bit(%s)' % (2 ** FP_SIZE))
children = Set('Molecule', cascade_delete=True)
parent = Optional('Molecule')
is it possible delete parent relation without delete data?
e.g. return parent to None

Alexander
18.01.2017
18:57:40
Yes, why not:
m = Molecule[id]
m.parent = None

stsouko
18.01.2017
18:58:22
Thank You!

Alexander
18.01.2017
18:58:27
Sure

Alexey
18.01.2017
18:58:37

Luckydonald
18.01.2017
19:05:57

Alexey
18.01.2017
19:07:47
depending on the attribute type
if the other side is Required then default is True
if the other side is Optional then default is False

Google

Luckydonald
18.01.2017
19:08:42
Oh. Okey, that makes sense.
Is that reflected corretly on the python side?

Alexey
18.01.2017
19:09:48
should be

Luckydonald
18.01.2017
19:10:06
Huh, cool

Alexey
18.01.2017
19:12:43

Luckydonald
18.01.2017
19:13:34
how about now?
And somehow dangerous, could be unexpected if the default differes...
✅

Alexey
18.01.2017
19:14:19
?