Skip to content

Bug: RepoDb.SqlServer Enum picking up 2 types when upgraded from 1.1.1 -> 1.1.2 #736

@simmohall

Description

@simmohall

Bug Description

When running a query using an enum in the WHERE clause, if I use 2 enum values, the first uses INT and the second uses the STRING value

Exception Message:

No exception from RepoDb, but the underlying SQL fails as it can't convert the column to 2 different data types

Generated T-SQL example
exec sp_executesql N'SELECT [source_system], [incoming_payload], [Id], [correlation_id], [event_type], [external_ticket_id], [internal_ticket_id], [created_timestamp], [arrival_timestamp], [completion_timestamp], [retries_remaining], [last_retry_timestamp], [Status], [error_description] FROM [incoming_event_queue] WHERE (([Status] = @Status) OR ([Status] = @Status_1)) ;',N'@Status int,@Status_1 nvarchar(4000)',@Status=0,@Status_1=N'awaiting_retry'

exception in T-SQL when manually executing the run SQL. 
Msg 245, Level 16, State 1, Line 10
Conversion failed when converting the nvarchar value 'awaiting_retry' to data type int.

Schema and Model:
create table incoming_event_queue(id int, status int)

_localDbContext.Connection.Query<IncomingQueueEvent>(e => e.Status == EventStatus.queued || e.Status == EventStatus.awaiting_retry)

And also the model that corresponds the schema.

[Map("incoming_event_queue")]
public class IncomingQueueEvent
{
public int Id { get; set; }
[TypeMap(DbType.Int32)]
public EventStatus Status { get; set; }
}

public enum EventStatus
    {
        queued = 0,
..
awaiting_retry = 4
}
}

Library Version:

Example: RepoDb v1.12.5 and RepoDb.SqlServer v1.1.2

(note: this worked ok in v1.1.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions