diff --git a/src/tink/sql/drivers/MySql.hx b/src/tink/sql/drivers/MySql.hx index fccc887..dd642ec 100644 --- a/src/tink/sql/drivers/MySql.hx +++ b/src/tink/sql/drivers/MySql.hx @@ -29,7 +29,11 @@ private class MySqlSanitizer implements Sanitizer { if (Std.is(v, Bool)) return v ? 'true' : 'false'; if (v == null || Std.is(v, Int)) return '$v'; if (Std.is(v, Bytes)) v = (cast v: Bytes).toString(); - if (Std.is(v, Date)) return 'DATE_ADD(FROM_UNIXTIME(0), INTERVAL ${(v:Date).getTime()/1000} SECOND)'; + + if (Std.is(v, Date)) return + #if mysql_session_timezone string((v: Date).toString()) + #else 'DATE_ADD(FROM_UNIXTIME(0), INTERVAL ${(v: Date).getTime() / 1000} SECOND)' #end; + return string('$v'); } diff --git a/src/tink/sql/drivers/node/MySql.hx b/src/tink/sql/drivers/node/MySql.hx index 9bc5914..0f7c5e7 100755 --- a/src/tink/sql/drivers/node/MySql.hx +++ b/src/tink/sql/drivers/node/MySql.hx @@ -137,8 +137,9 @@ class MySqlConnection implements Connection implements Sanitizer { } public function value(v:Any):String { - if (Std.is(v, Date)) - return 'DATE_ADD(FROM_UNIXTIME(0), INTERVAL ${(v : Date).getTime() / 1000} SECOND)'; + if (Std.is(v, Date)) return + #if mysql_session_timezone NativeDriver.escape((v: Date).toString()) + #else 'DATE_ADD(FROM_UNIXTIME(0), INTERVAL ${(v: Date).getTime() / 1000} SECOND)' #end; if (Int64.isInt64(v)) return Int64.toStr(v);