Issue Details (XML | Word | Printable)

Key: DNET-937
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jiri Cincura
Reporter: Daniel Richter
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

SQL for DbFunctions.CreateDateTime does not work

Created: 19/Mar/20 08:23 PM   Updated: 21/Sep/20 07:02 PM
Component/s: Entity Framework
Affects Version/s: 7.5.0.0
Fix Version/s: vNext


 Description  « Hide
Calling the DbFunctions method
   CreateDateTime(int? year,int? month,int? day,int? hour,int? minute,double? second)
generates SQL code that is not executable.

The SQL generating method (HandleCanonicalFunctionCreateDateTime) assumes that all parameters are constants and all parameters are not null. Additionally, the parameter for seconds is of type double so the generated SQL contains a CAST inside a timestamp literal (so it won't work even if all parameters a non-null constants).

The call DbFunctions.CreateDateTime(2020,3,19,12,0,0) is translated to
   CAST('2020-3-19 12:0:CAST(0 AS DOUBLE PRECISION)' AS TIMESTAMP)
The call DbFunctions.CreateDateTime(2020,3,19,null,null,null) is translated to
   CAST('2020-3-19 NULL:NULL:NULL' AS TIMESTAMP)
The call DbFunctions.CreateDateTime(c.BirthYear,1,1,null,null,null) is translated to
   CAST('"C"."BIRTHYEAR"-1-1 NULL:NULL:NULL' AS TIMESTAMP)

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order