2

The PostgreSQL date functions documentation contains the following example:

date '2001-09-28' + integer '7'

Why does it consist of converting a string to an integer? Why not phrase it like this:

date '2001-09-28' + 7

Is there some tangible reason why integer '7' is preferable to plain old 7?

closed as primarily opinion-based by a_horse_with_no_name, Marco, Tom V, Andriy M, McNets Jun 9 '17 at 15:03

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • The table is ancient, it's been maintained in essentially the same form since 7.2. It needs to be broken up into right and left operand types, like the newer JSON table. Most of the Pg operator stuff is horrible unstandardized with wide variations but awesomely detailed and easy to understand. My assumption: prior to having right/left operand types on tables, they used this to show the type that the operator was expecting and just overshot on clarity and explicitness in that dynamic. – Evan Carroll Jun 9 '17 at 15:15
  • @EvanCarroll probably just trying to visually differentiate between "integer" and "interval". – Jacob H Jun 9 '17 at 19:30
0

Interesting question, and I don't know the answer. My best guess is that all the other examples use the same way of casting, and someone thought it is better having it consistent. If you are pissed off irked by this, you can scroll to the bottom of the page and send a complaint using the form linked there.

Not the answer you're looking for? Browse other questions tagged or ask your own question.