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?

2
  • 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. Commented Jun 9, 2017 at 15:15
  • @EvanCarroll probably just trying to visually differentiate between "integer" and "interval".
    – Jacob H
    Commented Jun 9, 2017 at 19:30

1 Answer 1

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.