superset icon indicating copy to clipboard operation
superset copied to clipboard

HOURS OFFSET applies only to 1 time column, it should apply to all temporal columns in the dataset

Open saghatelian opened this issue 2 years ago • 4 comments

In Dataset Settings there is an option called "HOURS OFFSET". When you have only one time column, it's working as expected: it adds the corresponding number of hours to the time column while outputting it on the chart. However, when you have more than one temporal columns, the number of hours is logically expected to be added to all of them. Now it adds to only the one column that is selected as the "TIME COLUMN" in the chart.

How to reproduce the bug

  1. Create a dataset with more than one temporal field (e.g. Creation and expiration dates, as in the screencast),
  2. Add "HOURS OFFSET" to the dataset settings (e.g. 4) and save the dataset,
  3. Choose a "TIME COLUMN" in the Time settings of the chart and click Update,
  4. Choose another "TIME COLUMN" and click Update

Expected results

X hours (set in "HOURS OFFSET") should be added to all temporal fields, regardless of the "TIME COLUMN" selected.

Actual results

X hours are added to only one column, the one that is selected as the "TIME COLUMN" in the chart.

Note, that in the screencast, the "Expire Date" of the bottom row is actually equal to the "Agreement Creation Date" of the top row, but they are displayed with a 4-hour difference either way, because of the "HOURS OFFSET" option set.

Screenshots

https://user-images.githubusercontent.com/43491361/220833739-32950223-19ba-40e4-be12-d09804c40fde.mp4

Note, that the "Expire Date" of the bottom row is actually equal to the "Agreement Creation Date" of the top row, but they are displayed with a 4-hour difference either way, because of the "HOURS OFFSET" option set.

Environment

(please complete the following information):

  • browser type and version: Version 110.0.5481.112 (Official Build) (64-bit)
  • superset version: latest (checked on latest-dev too)
  • any feature flags active: "DASHBOARD_CROSS_FILTERS": True, "ALERT_REPORTS": True, "ENABLE_TEMPLATE_PROCESSING": True, "ENABLE_TEMPLATE_REMOVE_FILTERS": True, "GENERIC_CHART_AXES": True

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [x] I have reproduced the issue with at least the latest released version of superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

saghatelian avatar Feb 23 '23 06:02 saghatelian

EDIT Ok I think I misread your intent

You want both relationships to be from entityA to entityA - ok

  1. create 2 ManyToMany relationships between entityA and itself
  2. edit the resulting file and add table names to the relationships using @ORM\JoinTable

Example of 2 ManyToMany relationships between EntityA and itself with inverse mapping:

    /**
     * @ORM\ManyToMany(targetEntity=EntityA::class, inversedBy="children1")
     * @ORM\JoinTable(name="relationshipA")
     */
    private $parent1;

    /**
     * @ORM\ManyToMany(targetEntity=EntityA::class, mappedBy="parent1")
     */
    private $children1;

   /**
     * @ORM\ManyToMany(targetEntity=EntityA::class, inversedBy="children2")
     * @ORM\JoinTable(name="relationshipB")
     */
    private $parent2;

    /**
     * @ORM\ManyToMany(targetEntity=EntityA::class, mappedBy="parent2")
     */
    private $children2;

This will create tables relationshipA and relationshipB

Old answer below

Never tried 2 ManyToMany relationships between the same 2 entities but here's something you could try (should work theoretically):

  1. bin/console make:entity entityAname
  2. create a ManyToMany relationship with entity entityBname - should create table entityAname_entityBname
  3. exit entity editing
  4. bin/console make:entity entityBname
  5. create a ManyToMany relationship with entity entityAname - should create table entityBname_entityAname

you should now have 2 tables that do a ManyToMany relationship between those 2 entities

537mfb avatar Aug 24 '21 15:08 537mfb

@537mfb's solution worked for me! In my case, I was creating multiple many-to-many between EntityA and EntityB for different columns in EntityA

mathiasayivor avatar Jan 09 '23 00:01 mathiasayivor

I think a unique relationship name should be automatically generated when the user does not explicitly state the @ORM\JoinTable(name="relationshipName") to prevent this duplicate error

mathiasayivor avatar Jan 09 '23 00:01 mathiasayivor

It does create a name - however the name (if i remember correctly) is entityAHasentityB by default so both would many to many relationships would have the same name (hence the duplicate error) I guess if the two entities aren't the same (which they were in @Lukas-Sander's case) you could possibly edit entityA, add a ManyToMany relationship to entityB then edit entityB and add a ManyToMany relationship to entityA If done corretly that would produce one mappedBy and one InversedBy property in each entity, and an EntityAHasEntityB and EntityBHasEntityA relationship entities - but I haven't tested this as I prefer a bit more control in complex cases like this (check my Old answer at the bottom of my answer above for details)

537mfb avatar Jan 09 '23 19:01 537mfb