Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Ticket state: Use native sort of enumerations instead of separate sort column #173

Open
pegro opened this issue May 15, 2018 · 5 comments

Comments

@pegro
Copy link
Member

pegro commented May 15, 2018

tbl_ticket_state has a column sort to store the order of the ticket states.

PostgreSQL supports native ordering of enumeration types and relies on the order of the values when the type was created. So this could replace the sort column for ordering ticket states.

Note: To replace a enum type which is in use, the following migration is proposed:

  1. Introduce the new enum type with a temporary name
  2. add temporary columns to all related tables
  3. copy the values from the old column
  4. remove the old columns
  5. remove the now unused enum type
  6. rename the enum type back to the old name
  7. rename the columns back to their old name
@a-tze
Copy link
Collaborator

a-tze commented May 15, 2018

Note: This can AFAIK not replace the sort column completely, because there is no native support for (ordered) enums in PHP. To have the states ordered there, the sort is still needed.
Nevertheless, it would reduce lots of things in the SQL part.

@jjeising
Copy link
Member

because there is no native support for (ordered) enums in PHP.

Where would we need this? I can't finde any reference to 'sort'. There is

https://github.com/crs-tools/tracker/blob/master/src/Application/Model/Project.php#L78-L79

but this is only a query. As we only use strings in PHP, we don't do additional sorting there.

@a-tze
Copy link
Collaborator

a-tze commented Jun 12, 2018

Where would we need this? I can't finde any reference to 'sort'.

There is an order in every dropdown where a state can be selected (Ticket edit / mass edit). Additionally, in the "States" view of project settings the states are in the correct order as well as in the dropdown for the dependee ticket trigger state.

So e.g. it is used additionally here:
https://github.com/crs-tools/tracker/blob/master/src/Application/Controller/Projects.php#L156

The other mentioned functionalities seem to derive correct order from the $States property of a project model instance.

@jjeising
Copy link
Member

There is an order in every dropdown where a state can be selected (Ticket edit / mass edit).

We need ordering, sure, but ordering in PostgreSQL would still work, doesn't it?

What I was trying to say: We don't need support for ordered enums in PHP, as we don't use enums anyway. Arrays in PHP are ordered maps, so when we get ordered results from PostgreSQL this would be enough.

@a-tze
Copy link
Collaborator

a-tze commented Jun 13, 2018

Correct, my concern was just to get the order from the database into PHP. Since most code seems to rely on a central logic for this, it might be a lot easier than I initially thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants