EF Core 3.1 - ORA-00932: expected CHAR ; got NCLOB

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
kakone
Posts: 12
Joined: Thu 09 Jan 2020 17:30

EF Core 3.1 - ORA-00932: expected CHAR ; got NCLOB

Post by kakone » Wed 19 Feb 2020 10:47

Hello,

With EF Core 3.1, I try to do this simple query (my 'LastName' column is of type VARCHAR2 in the database) :

Code: Select all

var test = dbContext.ThirdParties.Select(tp => tp.Kind == 1 ? tp.LastName : "A string").ToList();
When I run this code, I get the ORA-00932 exception : inconsistent datatypes: expected CHAR ; got NCLOB

Shalex
Site Admin
Posts: 9127
Joined: Thu 14 Aug 2008 12:44

Re: EF Core 3.1 - ORA-00932: expected CHAR ; got NCLOB

Post by Shalex » Tue 25 Feb 2020 15:44

The bug with using a discriminator in EF Core 3 is fixed in v9.11.951.

Please upgrade. If this doesn't help, send us a small test project with the corresponding DDL/DML script for reproducing.

kakone
Posts: 12
Joined: Thu 09 Jan 2020 17:30

Re: EF Core 3.1 - ORA-00932: expected CHAR ; got NCLOB

Post by kakone » Wed 26 Feb 2020 12:06

No, it is not the bug with a discriminator, it's not fixed in 9.11.951.

Other sample with a simple table of users ('Name' and 'Login' are of type VARCHAR2 in the database) :

Code: Select all

var test = dbContext.Users.Select(u => u.Name.StartsWith("Admin") ? "ADMINISTRATOR" : u.Login).ToList();
When I run this code, I get the ORA-00932 exception : inconsistent datatypes: expected NCLOB ; got CHAR

The generated SQL is :

Code: Select all

SELECT (CASE
    WHEN "u".NAME IS NOT NULL AND ("u".NAME LIKE 'Admin%') THEN TO_NCLOB('ADMINISTRATOR')
    ELSE "u".LOGIN
END)
FROM USER "u"
There shouldn't be the TO_NCLOB function.

Shalex
Site Admin
Posts: 9127
Joined: Thu 14 Aug 2008 12:44

Re: EF Core 3.1 - ORA-00932: expected CHAR ; got NCLOB

Post by Shalex » Fri 06 Mar 2020 15:53

We cannot reproduce the issue with v9.11.951:

Code: Select all

    modelBuilder.Entity<DEPT>().Property<string>(x => x.DNAME).HasColumnName(@"DNAME").HasColumnType(@"VARCHAR2").ValueGeneratedNever().HasMaxLength(14);
    modelBuilder.Entity<DEPT>().Property<string>(x => x.LOC).HasColumnName(@"LOC").HasColumnType(@"VARCHAR2").ValueGeneratedNever().HasMaxLength(13);

...

   var test = context.DEPTs.Select(u => u.DNAME.StartsWith("Admin") ? "ADMINISTRATOR" : u.LOC).ToList();
   
->
   
      SELECT (CASE
          WHEN "d".DNAME IS NOT NULL AND ("d".DNAME LIKE 'Admin%') THEN 'ADMINISTRATOR'
          ELSE "d".LOC
      END)
      FROM DEPT "d"
1. Specify the mapping of your Name and Login properties.

2. Run your code in the debug mode, navigate to Debug > Windows > Modules and make sure that the only Devart assemblies loaded in the process are:
* Devart.Data.dll v5.0.2375.0
* Devart.Data.Oracle.dll v9.11.951.0
* Devart.Data.Oracle.Entity.EFCore.dll v9.11.951.0

3. Tell us the version of your Oracle Server.

kakone
Posts: 12
Joined: Thu 09 Jan 2020 17:30

Re: EF Core 3.1 - ORA-00932: expected CHAR ; got NCLOB

Post by kakone » Mon 09 Mar 2020 09:31

Thanks for the answer. I use an existing database and I forgot to indicate .HasColumnType("VARCHAR2"). It works well when I specify the column type.

Post Reply