-
- Notifications
You must be signed in to change notification settings - Fork 33
pg driver: fixed %dt with interval #18
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
Conversation
Mikulas commented Oct 28, 2015
| This should not introduce any bc break. Pg allows type cast nesting and select '2015-11-27 11:49:36.002+02'::timestamptz::timestamptz 2015-11-27 10:49:36.002+01 |
| Opened Tester issue nette/tester#268. |
SELECT Now() <= %dt::timestamptz + (INTERVAL '2 DAYS')doesn't work? |
| I'm not sure, if passing parameters should automatically cast them. We may do the same for integers, booleans, ... |
| Not quite, this type cast does not loose any precision and is in fact the cast postgres would love to do internally, but does not have enough information about. The string could be a generic (even composite) type, but orm knows it's a simple ymd his format. The cast is not strictly required in orm, but it never breaks anything and is very convenient. |
I do not claim it does.
but we are in Dbal, not in ORM layer. Since Nextras ORM doesn't allow you to use interval expression and you always have to write it manually using dbal's interface, I still don't see the usecase even for Orm. |
I misspoke, dbal indeed, but the argument holds.
Not a requirement, interval is simply the case I chose to put in test as it's afaik the most common case. The cast is required anywhere pg can't type cast it automatically. Is there any negative effect of this change? |
| At least inconsitence. Also sql clutter.
@JanTvrdik what do you think? |
| Fair point. I would obviously like to see this merged, but it's up to you. Int and bool typecasts are either not required as dbal sends the correct type (eg |
| Could you provide your real-worl usecase, when you discovered such drawback? |
| Interval, complex query but the test case is the minimal version of that already. It would also be required for any function or operator that is defined for both string and a |
| Another way of thinking about it is that orm is currently relying on automatic type cast. |
src/Drivers/Pgsql/PgsqlDriver.php Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to timestamp and I will merge this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was original implementation. I choose to rebase it with this simply for it's semantic value: I interpret tz as the timezone is known (in contrast to timestamp, which might indicate a time from application in unknown tz).
Without the timezone specified in the format string, those are all equivalent (as in interchangeable)
select '2015-01-01 16:00:00'::timestamp; select '2015-01-01 16:00:00'::timestamptz::timestamp; select '2015-01-01 16:00:00'::timestamptz; select '2015-01-01 16:00:00'::timestamp::timestamptz;but I wouldn't mind timestamp either; is there a reason you requested timestamp?
| I'm ok if this does not get merged, but we will need Mikulas@d9c9245 anyway (that's why #16 is broken) |
| Sorry, I forget to fully think it out. I'm definitelly against timestampttz for both cases. If the behavior is the same as you pointed out, it doesn't make sence at all. |
d9c9245 to 1a705c3 Compare | Oh no, seems that you still didn't understand the dbal approach :)) Please, keep timestamptz for %dt :) |
1a705c3 to 4ee73f0 Compare | Sorry, that makes no sense (to me, anyway). I rebased it, though. edit: misclick |
pg driver: fixed %dt with interval
| great! thanks! |