fulcro

Yab Mas 2025-08-26T09:50:20.222399Z

I have an issue in the following report that I don't fully understand:

(report/defsc-report GroupCourseEnrollementsReport
  [this _props]
  {ro/source-attribute :report.group/course-enrollments
   ro/row-pk group-course-timeframe/id
   ro/columns [course/name course/administrators]
   ro/row-query-inclusion [{:course/administrators [{:course.administrator/user [:user/first-name :user/last-name]}]}]})
results in this query
[({:report.group/course-enrollments
   [{:course/administrators
     [{:course.administrator/user [:user/first-name :user/last-name]}]}
    :course/name
    :course/administrators
    :group-course-timeframe/id]} 
  {:group-id 1001})]
which gives this results:
{:report.group/course-enrollments
 [{:course/administrators [{:course.administrator/id 400}],
   :course/name "My Course", 
   :group-course-timeframe/id 1}]}
Note: • in the result the :course/administrators doesnt have the sub-entity info requested in the row-query-inclusion. • in the query we have a double entry for :course/administrators (one with the sub-query, one just for the root-level key) Now, when I remove this double entry (manually), removing the extra root-level key; I do get the result Im after. I guess the issue stems from having administrators in both the colmn definition and the row-inclusions. But this seems to me like a completely valid thing to want. And something that fulcro could/should(?) be able to cleanup. For now I worked around it by using ro/column-EQL on the administrators attribute. But I would prefer to configure this per report.

Eric Dvorsak 2025-08-28T06:53:14.011659Z

> it’s used in 2 places in report.cljc…I would think you’d want (fn [report-class] EQL), ah but it’s in a macro, and might be hard to get the body class…since we’re in the midst of defining it Wouldn't it make more sense to have ro/columns-EQL option in the reports to override the attribute ro/column-EQL on a specific report?

Eric Dvorsak 2025-08-28T06:54:07.640039Z

otherwise with the fn there's a circular dependency since the report requires the attributes and the model will refer to the class of the report

Yab Mas 2025-08-28T07:03:07.274789Z

I actually had a quick look at this yesterday, its just this line that is blocking the (assoc Attr ro/column-EQL ...) solution: https://github.com/fulcrologic/fulcro-rad/blob/main/src/main/com/fulcrologic/rad/report.cljc#L617 Even without the circular dependency thing eric is mentioning; I struggle to see the value of that direction (I do see the value for the other report-options, just not what it solves here)

tony.kay 2025-08-28T07:40:06.476269Z

So, I think the right option is what Eric is suggesting…it is what I do everywhere else: Allow a default in the attr, and a report-specific override

tony.kay 2025-08-28T07:40:41.721149Z

The trick with this specific option is that because the macro builds the component query, it has to be able to resolve the value at compile time.

tony.kay 2025-08-28T07:41:09.558079Z

I’ll patch it shortly…working on something else at the moment

tony.kay 2025-08-28T08:25:48.535649Z

Released in 1.6.15. This follows the pattern of all other options like it: The column-EQL attribute option is kind of a “global default” for all reports, and each report can optionally override with the plural ro/columns-EQL.

🙏 1
Yab Mas 2025-08-26T09:50:50.153459Z

I could look into providing a fix if its indeed a bug in fulro, but im first trying to understand if thats indeed the case or if im missing something.

tony.kay 2025-08-26T15:05:16.595359Z

you should not be using a row query inclusion. Add a ro/column-eql to the attribute instead

tony.kay 2025-08-26T15:05:30.813419Z

and also a ro/column-formatter

tony.kay 2025-08-26T15:06:40.316259Z

both on the attribute

tony.kay 2025-08-26T15:07:38.069699Z

query inclusions are for data unrelated to the specific columns. For example :ui/wiggly? to do some custom UI thing on your report UI

👍 1
Yab Mas 2025-08-26T15:08:03.080329Z

Yes, thats actually what I did to work around it. But doesnt it make sense to want the option to define this on the report level as well? I dont necessarily always want the same sub-query for every report.

tony.kay 2025-08-26T15:08:27.589729Z

That’s why ro/column-eql (and most options in RAD) support a function

Yab Mas 2025-08-26T15:09:08.445839Z

ok, nice. l'll look into that. thanks

tony.kay 2025-08-26T15:10:32.297459Z

actually, that one doesn’t appear to support a function (which I guess I’ve never needed, but that is the pattern for what you are saying). That said, you can also just assoc an alternate option on the attr when using it on a report… (assoc course/administrator ro/column-EQL …)

tony.kay 2025-08-26T15:10:54.511379Z

but I would accept a patch to support a fn variant on column-EQL

tony.kay 2025-08-26T15:13:58.602789Z

it’s used in 2 places in report.cljc…I would think you’d want (fn [report-class] EQL), ah but it’s in a macro, and might be hard to get the body class…since we’re in the midst of defining it

tony.kay 2025-08-26T15:14:32.233139Z

which is why I probably left it as it is

Yab Mas 2025-08-26T15:18:00.057339Z

> That said, you can also just assoc an alternate option on the attr when using it on a report… > > (assoc course/administrator ro/column-EQL …) I tried this, but it didnt want to compile; I presummed due to checks within the macro, but didnt check. Maybe thats what you're getting at later in your message, not clear to me.

Yab Mas 2025-08-26T15:23:30.363999Z

I would prefer a solution along those lines I think, not sure what a fn arg option would bring me; I "just" want to define what nested data is relevant for this report from a particular attribute onward. Defining it purely on the report seems cleanest to me. When/if I find the time I'll look into whats keeping me from doing (assoc course/administrator ro/column-EQL …)and see if i can find a ok structure to support it.