def trained_unit(object_ids, before_tech):
    """Returns matches where only *1* of the object ids is played prior to before_tech."""
    query = """
        select oi.match_id, oi.initial_player_number as number, (case when count(distinct initial_object_id) = 1 then true else false end) as value
        from object_instances as oi join ({sq}) as sq on oi.match_id=sq.id
        where initial_class_id=70 and initial_object_id=any(:object_ids) and created > '00:01:00'
        and created < (select finished from research where match_id=oi.match_id and player_number=oi.initial_player_number and technology_id=:before_tech)
        group by oi.match_id, oi.initial_player_number
        having (case when count(distinct initial_object_id) = 1 then true else false end)=true
    """
    return (
        query,
        dict(object_ids=object_ids, before_tech=before_tech)
    )