#9: Fixes bug 9, all tests pass...
But I'm not utterly confident there won't be regressions.
This commit is contained in:
parent
8f24c314a1
commit
b472bd4950
4 changed files with 92 additions and 25 deletions
|
|
@ -423,7 +423,7 @@
|
|||
(is (= actual expected))))
|
||||
(testing "Convenience entity field - is an entity field, should emit"
|
||||
(let [property (child-with-tag address-entity :property #(= (-> % :attrs :name) "district_id"))
|
||||
expected "districts.name AS district_id_expanded"
|
||||
expected "district_id.name AS district_id_expanded"
|
||||
actual (emit-convenience-entity-field property address-entity application)]
|
||||
(is (= actual expected))))
|
||||
|
||||
|
|
@ -435,3 +435,64 @@
|
|||
(is (= actual expected))))
|
||||
|
||||
))
|
||||
|
||||
(deftest bug-9-test
|
||||
(testing "Correct reference to aliased tables in convenience view select queries
|
||||
see [bug 9](https://github.com/simon-brooke/adl/issues/9)"
|
||||
(let [app
|
||||
{:tag :application,
|
||||
:attrs {:version "0.0.1",
|
||||
:name "pastoralist",
|
||||
:xmlns:adl "http://bowyer.journeyman.cc/adl/1.4.1/",
|
||||
:xmlns:html "http://www.w3.org/1999/xhtml",
|
||||
:xmlns "http://bowyer.journeyman.cc/adl/1.4.1/"},
|
||||
:content [{:tag :documentation,
|
||||
:attrs nil,
|
||||
:content ["A web-app intended to be used by pastoralists in managing
|
||||
pastures, grazing, and animals."]}
|
||||
{:tag :entity,
|
||||
:attrs {:volatility "5", :magnitude "9", :name "animal" :table "animal"},
|
||||
:content
|
||||
[{:tag :key,
|
||||
:attrs nil,
|
||||
:content
|
||||
[{:tag :property,
|
||||
:attrs
|
||||
{:distinct "system",
|
||||
:immutable "true",
|
||||
:column "id",
|
||||
:name "id",
|
||||
:type "integer",
|
||||
:required "true"},
|
||||
:content
|
||||
[{:tag :generator, :attrs {:action "native"}, :content nil}]}]}
|
||||
{:tag :property,
|
||||
:attrs {:entity "animal", :type "entity", :name "dam"},
|
||||
:content nil}
|
||||
{:tag :property,
|
||||
:attrs {:entity "animal", :type "entity", :name "sire"},
|
||||
:content nil}
|
||||
{:tag :property,
|
||||
:attrs
|
||||
{:required "true",
|
||||
:distinct "user",
|
||||
:size "64",
|
||||
:type "string",
|
||||
:name "animal-identifier"},
|
||||
:content
|
||||
[{:tag :prompt,
|
||||
:attrs {:locale "en_GB.UTF-8", :prompt "Ear-tag Number"},
|
||||
:content nil}]}
|
||||
{:tag :property,
|
||||
:attrs {:distinct "user", :size "64", :type "string", :name "name"},
|
||||
:content nil}]}]}
|
||||
animal (child app #(= (-> % :attrs :name) "animal"))
|
||||
dam (child animal #(= (-> % :attrs :name) "dam"))]
|
||||
(let [actual (emit-convenience-view animal app)
|
||||
should-find #"dam.animal_identifier"
|
||||
should-not-find #"animal.name AS dam_expanded"]
|
||||
;; (print actual) ;; see what we've got
|
||||
(is (re-find should-find actual))
|
||||
(is (nil? (re-find should-not-find actual))))
|
||||
|
||||
)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue