Strange differences in handling of LUA tables between edge and v2?

I want do generate a nice list of all my tags with counts of them.

In edge that works quite well (already using LUA!):

  local inputTable = query[[
      from t = index.tag "tag"
      order by t.name 
  ]]

I get all my tags listed, some appear multiple times, if they are used on multiple pages. That`s what I want…

However in v2 that does not work as expected. Here I see each tag only once. Looks like the result table is some sort of unified (like “uniq”).
Is there a way to turn that off? (e.g. using tho “old” behaviour?)

I managed to get a list (kind of) how I want by using this:

  local inputTable = query[[
      from t = index.tag "tag"
      order by t.name 
      select {N = t.name, P = t.parent}
  ]]

But with this my script does not work anymore, e.g. table.sort(inputTable) doesn’t work anymore…

Yes, this is by design. The way queries worked in the past (the old-style queries) is that it would always do a DINSTINCT on the rows. I brought this back in v2. However, it should do this based on the fields that you select so as long as you have unique values based on whatever appears in the selected values.

What do you mean this doesn’t work anymore?

In fact, it turned out, that my last sentence is nonsense… It still works, I just looked wrong :wink:
In the end I could change my queries and script, so I got it to work (and it was more easy than expected.

So thanks for your confirmation that this is expected behaviour!

1 Like