从AbstractConcreteBase继承时对混合属性进行多态过滤

时间:2019-02-26 16:30:14

标签: sqlalchemy

我已经成功地通过 AbstractConcreteBase 父级多态加载了项目。是否还可以过滤后代的 hybrid_property 定义?我还想在每个子类的不同列上进行过滤。

查询

data_ex <- data_ex %>% 
      mutate(x2 = cut(x, breaks = 0:10), 
             y2 = cut(y, breaks = c(0,2,4,6,8))) %>%
      group_by(x2, y2) %>%
      mutate(mean_z = mean(z),
             x_mid = floor(x) + (ceiling(x) - floor(x))/2,
             y_mid = floor(y) + (ceiling(y) - floor(y))/2,
             height = ceiling(y) - floor(y),
             width = ceiling(x) - floor(x)) %>%
      ungroup()

data_ex %>% 
      ggplot() +
      geom_rect(aes(xmin = 0, xmax = 10, ymin = 0, ymax = 10), fill = 'white') +
      geom_tile(aes(x = x_mid, y = y_mid,height = height, width = width, fill = mean_z))

型号:

    # Fetching all ItemA and ItemB works well with...
    ItemBase.query.all()

    # Given the models below is it possible to filter on the children's
    # item_id hybrid_property to fetch all ItemB with item_b_id of 1
    # Result is []
    ItemBase.query.filter(ItemBase.item_id == 'B1')

    # This also doesn't work
    # Result is everything unfiltered
    ItemBase.query.filter(ItemB.item_id == 'B1')

我现在停留在表结构上。任何帮助将不胜感激。

0 个答案:

没有答案