Bug 5768 - InvalidCastException when retrieving a boolean value from sqlite reader
Summary: InvalidCastException when retrieving a boolean value from sqlite reader
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-20 00:25 UTC by Kevin
Modified: 2012-06-25 06:00 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Kevin 2012-06-20 00:25:07 UTC
SELECT eventID,
	   eventDate,
	   title,
	   redeem_tickets,
	   sold,
	   a.accountID,
	   a.key,
	   a.name
  FROM event AS e
 INNER JOIN account AS a ON e.accountID = a.accountID
 WHERE e.accountID = @accountID
   AND e.eventDate >= @from_date
   AND e.eventDate <= @thru_date
   
 using (var reader = command.ExecuteReader()) {
	var events = from e in reader.Cast<DbDataRecord> () 
	select new EventListItem {
				ID = e.GetInt32 (0),
				EventDate = e.GetDateTime (1),
				Title = e.GetString (2),
				RedeemTickets = e.GetBoolean (3),    <= THROWS EXCEPTION WITH 5.3.x 
				Sold = e.GetInt32 (4),
				Context = new EventContext {
					Owner = new TicketBiscuit.Users.Account {
						ID = e.GetInt32 (5),
						Key = e.GetString (6),
						Name = e.GetString (7)
					}
				}
			};
	return events.ToList ();
} 


with the latest beta build. the value is changed from a boolean in the datareader to an int when the reader is cast to a dbdatarecord.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-06-20 06:14:27 UTC
How is redeem_tickets defined in the database?
Comment 2 Kevin 2012-06-20 09:34:46 UTC
CREATE TABLE event 
(
	eventID 		INT 			NOT NULL CONSTRAINT event_primary_key PRIMARY KEY, 
	eventDate 		DATETIME 		NOT NULL, 
	accountID 		INT 			NOT NULL, 
	title 			NVARCHAR(128)	NOT NULL, 
	redeem_tickets 	BOOLEAN 		NOT NULL DEFAULT(0),
	sold			INT				NOT NULL,
	floorPlanID		INT				NOT NULL
)
Comment 3 Kevin 2012-06-20 09:36:23 UTC
this is a sqlite database.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-06-25 06:00:06 UTC
Fixed (monotouch: d1effc94a20d869d4dbb72936098e3ea526f3261).

The fix will be included when 5.3.5 is released.


In the mean-time you can use BOOL instead of BOOELAN. If that doesn't work out, I can provide a hotfix release until the next beta release.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2012-06-25 06:00:06 UTC
Fixed (monotouch: d1effc94a20d869d4dbb72936098e3ea526f3261).

The fix will be included when 5.3.5 is released.


In the mean-time you can use BOOL instead of BOOELAN. If that doesn't work out, I can provide a hotfix release until the next beta release.