Parameter substitution for MySQL TIME value bug

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Parameter substitution for MySQL TIME value bug

Post by NoComprende » Wed 18 Feb 2009 14:25

If I put the following code in a TMyQuery

select * from MySQLTable where TimeValue > :ParamTimeValue;

and ParamTimeValue is taken from a MasterSource table where the value is 14:10:00 then the final text that is sent to the MySQL server is

select * from MySQLTable where TimeValue > '14:10:0';

The missing '0' in the substitution means the result contains records where the value of TimeValue was 14:10:00 because
'14:10:00' > '14:10:0'

NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Post by NoComprende » Wed 18 Feb 2009 14:56

It's also missing out the trailing zero in the minute field as well if the minute field is zero e.g. the substitution for 17:00:00 is '17:0:0'.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 19 Feb 2009 14:28

I could not reproduce the problem.
The point is that MySQL compares Time fields as time, but not as string. Therefore '14:10:00' = '14:10:0'.

NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Post by NoComprende » Thu 19 Feb 2009 16:19

Dimon wrote:I could not reproduce the problem.
The point is that MySQL compares Time fields as time, but not as string. Therefore '14:10:00' = '14:10:0'.
Dimon, I simplified the code in the above example. It may be because I am using the following code

where (MyDate,MyTime,MyString)>(:MyDate,:MyTime,:MyString)

in my query rather than writing out the long winded version of that comparison. Try to reproduce it using

select * from MySQLTable where (TimeValue,StringValue) > (:TimeValue,:StringValue);

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 24 Feb 2009 10:01

Plase try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Post by NoComprende » Tue 24 Feb 2009 17:59

In the MySQL query browser

select time('12:50:00')=time('12:50:0');

returns 1

and

select time('12:50:00')='12:50:00';

returns 1

but

select time('12:50:00')='12:50:0';

returns 0.


While this error may be down to MySQL it would be easily solved if MyDAC substituted the full number of digits.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 26 Feb 2009 10:49

Ok. We will fix this problem. This fix will be included in the next MyDAC build.

NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Post by NoComprende » Thu 26 Feb 2009 14:32

Thanks Dimon.

Post Reply