jakob / Postico

Public issue tracking for Postico
https://eggerapps.at/postico/
475 stars 9 forks source link

Make sequences viewable and editable #412

Open qwesda opened 7 years ago

qwesda commented 7 years ago

This one is like the editing functions request but probably way easier to implement.

Writing ALTER SEQUENCE statement is always annoying since it is al lot of boilerplate text for a really small change.

jakob commented 7 years ago

Do you need to change anything besides the next value of the sequence?

qwesda commented 7 years ago

For my use case the ability to run setval('foo', 42, false) (i.e. set the next upcoming value) and ALTER SEQUENCE ... RENAME TO ...; would be enough.

I never really used the min, max, start, cycle or cache options.

I also think the only datatype used for sequences is bigint - so there is no need to include this. I first thought that serial and bigserialproduce different sequences, but this doesn't seem to be the case.

Sadly there doesn't seem to be a good way for getting the currently upcoming value.

jakob commented 7 years ago

OK, thanks.

You can get the upcoming value of a sequence with SELECT CASE WHEN is_called THEN last_value + 1 ELSE last_value END AS next_value FROM sequence_name

qwesda commented 7 years ago

God damn it, they could have made this more obvious in the documentation! Where does it even mention that you can just select * from "sequence"?

Well, even better, the next upcoming value would also be a must.

I don't know if anybody uses the other sequence options, but I guess you are going to here from them if you don't include these.