Bug 21666 - SQLiteException when using Link All Assemblies
Summary: SQLiteException when using Link All Assemblies
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.2.5
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-29 13:14 UTC by John Miller [MSFT]
Modified: 2014-07-29 16:38 UTC (History)
2 users (show)

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


Attachments
TestCase (412.89 KB, application/zip)
2014-07-29 13:14 UTC, John Miller [MSFT]
Details


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 FEATURE

Description John Miller [MSFT] 2014-07-29 13:14:50 UTC
Created attachment 7519 [details]
TestCase

### Overview: 

    When using Link All Assemblies, the SQLite library throws an exception in the CreateTable method.

### Steps to Reproduce: 

    1. Run the attached sample project. Make sure the Link All Assemblies is set. 

### Actual Results: 

    An exception is thrown in databasetest.cs line 26:

>Unhandled Exception:
>SQLite.Net.SQLiteException: near ")": syntax error
>  at SQLite.Net.Platform.XamarinIOS.SQLiteApiIOS.Prepare2 (IDbHandle db, System.String query) [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteCommand.Prepare () [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteCommand.ExecuteNonQuery () [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteConnection.Execute (System.String query, System.Object[] args) [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteConnection.CreateTable (System.Type ty, CreateFlags createFlags) [0x00000] in <filename unknown>:0 
>  at App1.databasetest.CreateDatabase () [0x0005e] in /Users/John/Downloads/App1/App1/databasetest.cs:26 
>  at App1.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00016] >in /Users/John/Downloads/App1/App1/AppDelegate.cs:30 
>  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
>  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String >delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38 
>  at App1.Application.Main (System.String[] args) [0x00008] in /Users/John/Downloads/App1/App1/Main.cs:17 
>2014-07-29 09:49:36.934 App1[91533:70b] Unhandled managed exception: near ")": syntax error (SQLite.Net.SQLiteException)
>  at SQLite.Net.Platform.XamarinIOS.SQLiteApiIOS.Prepare2 (IDbHandle db, System.String query) [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteCommand.Prepare () [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteCommand.ExecuteNonQuery () [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteConnection.Execute (System.String query, System.Object[] args) [0x00000] in <filename unknown>:0 
>  at SQLite.Net.SQLiteConnection.CreateTable (System.Type ty, CreateFlags createFlags) [0x00000] in <filename unknown>:0 
>  at App1.databasetest.CreateDatabase () [0x0005e] in /Users/John/Downloads/App1/App1/databasetest.cs:26 
>  at App1.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00016] >in /Users/John/Downloads/App1/App1/AppDelegate.cs:30 
>  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
>  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String >delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38 
>  at App1.Application.Main (System.String[] args) [0x00008] in /Users/John/Downloads/App1/App1/Main.cs:17 

### Expected Results: 

    No Exception.

### Build Date & Platform: 

    XI 7.2.5
Comment 1 Sebastien Pouliot 2014-07-29 16:38:22 UTC
hey, we had a little misunderstanding on the mailing - the bug was if not linking the (table) type did _not_ work ;-)

The solution is simply to add [Preserve] on `RecentItem` so the linker won't remove anything from it (that's not used in the app), e.g.

    [Preserve (AllMembers = true)]
    public class RecentItem
    {
        [PrimaryKey]
        public string Id { get; set; }
        public int ItemType { get; set; }
        public string AccessDate { get; set; }

        public RecentItem() { }
    }

You can even delete the SQLite.Net.xml (it's not needed).