Open php- opened 5 years ago
@harikt @pmjones please can you take look at this?
Hi @php- ,
I am wondering how you are using @@session.time_zone
. Is this a field ? Can you show exact issue on a Pull request how you are using the feature.
I can't promise I will fix it, but I can look into it.
For example: convert_tz(field, @@session.time_zone, to_desired_timezone)
, and this does not matter you use in selection or in where clause.
There are many different cases as I mentioned before like COUNT(DISTINCT field))
, I think you should add config to enable/disable it. because they way it works, is really limiting some good features of SQL language.
Thanks
Hi @php-
It would be nice if you provide minimal, self-contained, reproducing test case that shows the problem you are reporting.
Hi @php- ,
I believe you can enable / disable it via setting the parser to NullParser
.
// https://github.com/auraphp/Aura.Sql/tree/2be02d5dfd9fdee6df199de1a19572aa490bb744/src/Parser
$parser = new \Aura\Sql\Parser\NullParser();
$pdo->setParser($parser);
Remember once you unset to new parser you may want to set it again if you want to make sure other quoting related functionalities is working fine.
Hope that helps to resolve your issue / use case .
Is this still relevant? It seems to work fine now for me :thinking:
@francislavoie yes, issue still exists. The query you run might not have issues, but when you use builder like:
$query = $queryFactory->newSelect();
$query->from("customer");
$query->cols(['convert_tz(open_from, customer.time_zone, @@session.time_zone) open_now']);
$query->where('customer.id=123');
@francislavoie yes, issue still exists. The query you run might not have issues, but when you use builder like:
$query = $queryFactory->newSelect();
$query->from("customer");
$query->cols(['convert_tz(open_from, customer.time_zone, @@session.time_zone) open_now']);
$query->where('customer.id=123');
Sorry, but your code example has no reference to aura/sql
. There is no query builder in this package.
This is so annoying, for example using:
@@session.time_zone
will add ticks tosession
andtime_zone
, like this @@`session`.`time_zone`. Is there a way I can disable this feature? This also happens if you usecount(distinct x)
and many more cases.