Mikki 
    
    
        
        
        
        And hello to you two too!
    
 
    
    Иван 
    
    
        
        
        
        Ahoj
    
 
    
    Mikki 
    
    
        
        
        
        Welcome!
    
 
    
    Алекс 
    
    
        
        
        
        Hello, thank you!
    
 
    
    Rozen 
    
    
        
        
        
        mm i don't get it very well, what's the point of getattr for databases?
    
 
    
    Alexey 
    
    
        
        
        
        you are talking about this feature https://docs.ponyorm.com/api_reference.html#getattr, right?
    
 
    
    Rozen 
    
    
        
        
        
        yep 😆
    
 
    
    Alexey 
    
    
        
        
        
        it gives you more flexibility in writing queries
    
 
    
    Alexey 
    
    
        
        
        
        you don't need to hardcode which attribute you extract or compare, but can pass the name of these attributes as a parameter
    
 
    
    Alexander 
    
    
        
        
        
        This may be useful when somebody write some generic code for filtering. For example, when the name of the attribute may be received from the frontend as a GET parameter
    
 
    
    Mikki 
    
    
        
        
        
        Welcome!
    
 
    
    លី រិទធ៍ - Rit 
    
    
        
        
        
        Thank you. The switch to Apache License showed up on my twitter feed. I'm going forward to try it.
    
 
    
    លី រិទធ៍ - Rit 
    
    
        
        
        
        looking*
    
 
    
    Rozen 
    
    
 
    
    Rozen 
    
    
        
        
        
        (sorry sorry, i got tempted)
    
 
    
    Mikki 
    
    
        
        
        
        Welcome!
    
 
    
    Mikki 
    
    
        
        
        
        Welcome! :)
    
 
    
    Anonymous 
    
    
        
        
        
        Thanks! Never used pony before 'cause of the license, somehow I had the wrong idea it was too restrictive
    
 
    
    Anonymous 
    
    
        
        
        
        it really is a beautiful ORM, kudos!
    
 
    
    Mikki 
    
    
        
        
        
        Glad to hear that you're liking it! ^.^
    
 
    
    Mikki 
    
    
        
        
        
        (note, Im not a dev but just an enthousiastic user :p )
    
 
    
    Mikaelo 
    
    
        
        
        
        Same, usually used peewee for small projects, but now license allows to use pony; watching videos on youtube so far, testing, interesting.
    
 
    
    Mikki 
    
    
        
        
        
        Nice nice :)
    
 
    
    Serge 
    
    
        
        
        
        Hi guys! Great to see Apache 2 license and 4 spaces indentation!:)
    
 
    
    Alexey 
    
    
 
    
    Rustam.T 
    
    
        
        
        
        Как мир тесен )))
    
 
    
    Rozen 
    
    
        
        
        
        whut?
    
 
    
    Rozen 
    
    
        
        
        
        i don't speak russian, sorry :(
    
 
    
    Rozen 
    
    
        
        
        
        well yeah, but i don't get the joke this time
    
 
    
    Rustam.T 
    
    
 
    
    Alexander 
    
    
        
        
        
        It seems that several members of this chat know each other for a long time
    
 
    
    Serge 
    
    
        
        
        
        That is what you typically expect to happen, imo
    
 
    
    Serge 
    
    
 
    
    Alexander 
    
    
        
        
        
        Yeah :)
    
 
    
    Rozen 
    
    
        
        
        
        oh
    
 
    
    Rozen 
    
    
        
        
        
        awww
    
 
    
    Rozen 
    
    
        
        
        
        sweet
    
 
    
    Alexey 
    
    
 
    
    Alexander 
    
    
        
        
        
        It was in Netrika
    
 
    
    Alexey 
    
    
        
        
        
        Yeah, I figured
    
 
    
    Serge 
    
    
        
                    
                        
                            
                            How was it?)
                        
                    
                
        
        
        Interview was great. Though I cannot say the same about the concept
    
 
 
    
    Serge 
    
    
        
        
        
        😉
    
 
    
    Alexey 
    
    
 
    
    Serge 
    
    
        
        
        
        I felt like I don't swing that way
    
 
    
    Alexey 
    
    
 
    
    Alexey 
    
    
 
    
    Serge 
    
    
        
        
        
        There were the second and the third layers of the joke to be honest...:)
    
 
    
    Serge 
    
    
        
        
        
        You know me. I'm almost complete jerk in such a jokes
    
 
    
    Alexey 
    
    
        
        
        
        hehe)
    
 
    
    Lucky 
    
    
        
        
        
        Hello Telegram Group :D
    
 
    
    Lucky 
    
    
        
        
        
        Can I bother you guys with helping me write queries?
    
 
    
    Alexey 
    
    
        
        
        
        Sure, go ahead
    
 
    
    Lucky 
    
    
        
        
        
        https://editor.ponyorm.com/user/luckydonald/RssFeedStuff
    
 
    
    Lucky 
    
    
 
    
    Lucky 
    
    
        
        
        
        I am very new to pony and aren't so good with it.
        I want to retrieve all Messages of a FeedEntry with status "UNREAD"
    
 
    
    Lucky 
    
    
        
        
        
        If I modelled correctly, the feed entry can have multible links, each have a own message.
        And the feed entry has his own message too
    
 
    
    Lucky 
    
    
        
        
        
        So the message is either Feed or Link->Feed
    
 
    
    Alexey 
    
    
        
        
        
        feed_entry = FeedEntry[1] # instance of Feed Entry
        select(m for m in Message if m.feed_entry == feed_entry and m.feed_entry.status == 'UNREAD')
    
 
    
    Alexey 
    
    
 
    
    Alexey 
    
    
        
        
        
        Oh, we need to check the other relationship in Message too, hold on
    
 
    
    Lucky 
    
    
        
        
                    
                
        
        This is what I came up with.
        Message is here called AMessage, otherwise is it the same?
    
 
 
    
    Lucky 
    
    
        
        
        
        I assume FeedEntry[1] is the FeedEntry with ID 1?
    
 
    
    Alexey 
    
    
        
        
        
        yes
    
 
    
    Alexey 
    
    
        
        
        
        here we check both relationships of the Message entity
    
 
    
    Lucky 
    
    
        
        
        
        And together with doing that for each feed_entry it would look like this?
        for m in select(
            m for m in AMessage if
            (
              m.feed_entry == feed_entry
              or m.link.feed_entry == feed_entry
            ) and feed_entry.status == 'UNREAD'
            for feed_entry in FeedEntry
        ):
            do_post(m)
    
 
    
    Lucky 
    
    
 
    
    Alexey 
    
    
        
        
        
        if you want to use two 'for' this is going to be this way
    
 
    
    Alexey 
    
    
        
        
        
        select(m for m in Message for feed_entry in FeedEntry 
                               if (m.feed_entry == feed_entry or m.link.feed_entry == feed_entry) 
                               and feed_entry.status == 'UNREAD')
    
 
    
    Alexey 
    
    
        
        
        
        in the first case:
        select(m for m in Message if 
                         (m.feed_entry == feed_entry and m.feed_entry.status == 'UNREAD') 
                    or (m.link.feed_entry == feed_entry and m.link.feed_entry.status == 'UNREAD'))
        you iterate over the Message entity and check both relationships
    
 
    
    Alexey 
    
    
        
        
        
        actually, I think you should use the first case scenario
    
 
    
    Lucky 
    
    
 
    
    Alexey 
    
    
        
        
        
        correct
        if you want to retriewe messages for all of them, you need to remove this condition
    
 
    
    Lucky 
    
    
        
        
        
        Right, I want to get all of them.
    
 
    
    Alexey 
    
    
        
        
        
        select(m for m in Message 
                                   if m.feed_entry.status == 'UNREAD' or m.link.feed_entry.status == 'UNREAD')