Anatoliy
packs = Pack.select(
lambda p: (p.main.uid == service) and
(tsTo is None or p.tsFrom <= tsTo) and
(tsFrom is None or p.tsTo is None
or tsFrom < p.tsTo)
)
Anatoliy
my select
Anatoliy
I think it just translate in NULL
Alexander
if tsTo is None than it is incorrect to have SQL expression like p.tsFrom <= NULL, because, due to three-value logic in SQL, the result of this expression is UKNOWN
Alexander
you can to add such comparison conditionally
if tsTo is not None:
query = query.filter(lambda p: p.tsFrom <= tsTo)
Anatoliy
Okay
Lucky
Alexander
What's exactly here is confusing you?
Lucky
Which tag is which
Alexander
After you choose type of relation there will appear textareas for names
Lucky
Basically I have Tags.
Now I want a tag alias, that means one tag can be pointing to exactly one other tag which would replace it.
Also I would like to have implied tags, so if one tag which has 0 or many implied tags, those should be added as well.
Lucky
Maybe I'm just having problems to wrap my head around it
Alexander
Maybe we can invent another representation when defining self-reference attributes, but right now I have no idea how it may look
Lucky
This would be the idea for alias (i.e. tag replacement).
I want one tag to be replaced by another one.
What do I enter for the second relation?
Alexander
I think it is the following:
Each Tag may have multiple aliases
Each alias relates to exactly one canonic version of tag
Lucky
Does that makes sense then?
Alexander
Check symmetrical probably
Alexander
In this case I think your definition is fine
Alexander
But MLP cannot be used for My Little Pony?
Alexander
Or, MLP to mlp
Alexander
If you have one "caconical" form of tag which can be used instead of all other aliases, then your definition looks fine
Lucky
Lucky
What do I put into the index field?
Alexander
True or index_name
Alexander
But in your case Index will be ignored since you have unique.
Lucky
Hey, those automatic backwards attributes are very confusing as they are not distinguishable from real fields (See Tag-to-Tag entity)
Maybe the automatic ones could be marked cursive in the editor?
Lucky
I think there just were removed a few of my messages?
Alexander
Luckydonald, I agree that it is better to mark "virtual" attributes such as collections by cursive
Alexander
I just removed some joke of Alexander which was off-topic
Lucky
So it would be usages being italic, and replaces but not replaced_by.
Alexander
yes
Lucky
I think that could really help in the future.
Alexander
I created issue for that
https://github.com/ponyorm/editor/issues/9
Lucky
:+1:
Lucky
So, how far did migrations come now?
Alexander
They mostly work on SQLite and Postgres, should add Oracle and MySQL but I think it will not take too much time. Right now we are working on correct automatic upgrade procedure from current tables to new ones, because there are some changes in how columns are named, etc.
Lucky
Just checking if I have hope of doing an update with that, or if I should keep using pony_up for now
Alexander
Right now use pony_up, but I hope we will be able to show beta version in a few weeks
Lucky
Do you guys keep extensibility with blueprint like approach in mind?
Alexander
yes
Lucky
Will that be a separate release or something we can benefit in the upgrade branch already?
Lucky
I imagine that would need some thought up front how to handle tables in libraries.
Lucky
Like my Telestate Library.
It has to create a table on it's own or use an existing one.
But a library can't really just do import database.
Right now I found a really ugly way of making it work, but that's really not usable, as it very easily blows up in your face with circular import issues and the like...
Lucky
Especially I'd like to provide a state table
https://github.com/luckydonald/telestate/blob/deploy2/telestate/contrib/pony.py#L56-L62
but give users the ability to make a custom subclass with I.e. a bit different data structure. Currently I have to resort to using json as data column.
Permalink Bot
Alexander
Thanks for the info, I think I understand your use-case and need to think about it a little more. Maybe we can add support of it
Lucky
Value 17777558211705431939 of attr Hash.average is greater than the maximum allowed value 9223372036854775807
I'm a but stuck.
I'm trying to have image hashes in a database.
Lucky
I would later need to compare them, that I need to cover somehow as well
Alexander
How do you calculate it? Is it int32 or int64? And why it has "average" attribute, I think calculating averages for hashes is a bit meaningless
Matthew
A hash is usually stored as bytes (or a hex string)
Matthew
Any common hash will be more than 64 bits
Lucky
I'm basically using the ImageHash
pip libarary.
The aim is to have a hash representing image content which would not change greatly for small changes in the image.
Lucky
Lucky
In the end I would need to caluclate the Hamming distance to a given new hash
Lucky
Not sure what the best approch for databases would be
Alexander
How do you define Hash.average attribute?
Alexander
I think you need to specify it as Required(int, size=64, unsigned=True)
Lucky
Lucky
I was thinking maybe have a boolean field for each bit?
Alexander
According to description of average hashing, it uses unsigned int 64
Lucky
Oh, so changing it to unsigned should fix it.
Alexander
Yes, I think so
Lucky
Any idea how I can calculate the hamming distance efficiently?
Lucky
Probably need some raw SQL, huh?
Alexander
What database do you use?
Lucky
sqlite and later posgres
Alexander
In PostgreSQL you can define bit_count function and test the result of XOR on two hashes
https://stackoverflow.com/questions/46280722/bit-count-function-in-postgresql
Alexander
In SQLite you can get raw connection and call connection.create_function('but_count', 1, some_python_implementation_of_bit_count)
Alexander
Ans then use bit_count in raw_sql fragment
Lucky
Lucky
Postgres appearantly too.
Alexander
Then you probably can convert hash to hexademical form and store it as a string. Not sure how to efficiently calculate hamming distance, though
Lucky
Lucky
The auto save isn't working 😂
Lucky
I just lost a bunch of relations 👍
Lucky
Hey, I'm getting an error "Something went wrong: name 'Tag' is not defined" in any SQL/Export view in https://editor.ponyorm.com/user/luckydonald/Tags/designer
Lucky
Permalink https://editor.ponyorm.com/user/luckydonald/Tags/snapshots/43/designer