Skip to content

Commit

Permalink
Fix InvalidCastException during job fetch with older schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
odinserj committed Dec 3, 2024
1 parent 0e9ea33 commit 58ec10d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Hangfire.SqlServer/SqlServerJobQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ private SqlServerTimeoutJob FetchJob(string[] queues)

if (!reader.Read()) return null;

var id = reader.GetInt64(reader.GetOrdinal("Id"));
var jobId = reader.GetInt64(reader.GetOrdinal("JobId"));
var id = Convert.ToInt64(reader.GetValue(reader.GetOrdinal("Id")), CultureInfo.InvariantCulture); // Can be Int32 in older schemas
var jobId = Convert.ToInt64(reader.GetValue(reader.GetOrdinal("JobId")), CultureInfo.InvariantCulture); // Can be Int32 in older schemas
var queue = reader.GetString(reader.GetOrdinal("Queue"));
var fetchedAt = reader.GetDateTime(reader.GetOrdinal("FetchedAt"));

Expand Down Expand Up @@ -243,7 +243,7 @@ private SqlServerTransactionJob DequeueUsingTransaction(string[] queues, Cancell
{
if (reader.Read())
{
var jobId = reader.GetInt64(reader.GetOrdinal("JobId"));
var jobId = Convert.ToInt64(reader.GetValue(reader.GetOrdinal("JobId")), CultureInfo.InvariantCulture); // Can be Int32 in older schemas
var queue = reader.GetString(reader.GetOrdinal("Queue"));

if (reader.Read())
Expand Down

0 comments on commit 58ec10d

Please sign in to comment.