        [:join
         [:properties
          {[:simple users]
-          [[:prefixed-properties {:base db
-                                  :children [[:property [:simple id]]]}]
-           [:prefixed-properties {:base user
-                                  :children [[:property [:simple name]]]}]
+          [[:prefixed-properties
+            {:base db
+             :children [[:property [:simple id]]]}]
+           [:prefixed-properties
+            {:base user
+             :children [[:property [:simple name]]]}]
            [:property
-            [:join [:properties
-                    {[:simple friends]
-                     [[:prefixed-properties
-                       {:base db
-                        :children [[:property [:simple id]]]}]
-                      [:prefixed-properties
-                       {:base user
-                        :children [[:property [:simple name]]]}]]}]]]]}]]]]
+            [:join
+             [:properties
+              {[:simple friends]
+               [[:prefixed-properties
+                 {:base db
+                  :children [[:property [:simple id]]]}]
+                [:prefixed-properties
+                 {:base user
+                  :children [[:property [:simple name]]]}]]}]]]]}]]]]
     '[{users [db [id]
               user [name]
               {friends [db [id]

       [:join
        [:properties
         {[:link [user 1]]
          [[:prefixed-properties {:base db
                                  :children [[:aliased-property
                                              {:property [:simple id]
                                               :as :as :alias db-id}]]}]
           [:aliased-property {:property [:simple name]
                               :as :as :alias nm}]]}]]]]
    '[{[user 1] [db [id :as db-id] name :as nm]}]))


    '[{:name users :type :join
       :join-source {:name users :type :property}
       :join-target
       [{:name friends :type :join
         :join-source {:name friends :type :property}
         :join-target
         [{:name friends :type :join
           :join-source {:name friends :type :property}
           :join-target [{:name db/id :type :property}]}]}]}]
    '[{users [{friends [{friends [db [id]]}]}]}]))

(deftest om-next-query-for-joins-with-sub-joins
