return _keyInfo.GetDataTypeName(i - VisibleFieldCount);\r
\r
SQLiteType typ = GetSQLiteType(i);\r
- if (typ.Type == DbType.Object) return SqliteConvert.SQLiteTypeToType(typ).Name;\r
return _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity);\r
}\r
\r
return GetSchemaTable(true, false);\r
}\r
\r
+ static bool hasColumnMetadataSupport = true;\r
+\r
internal DataTable GetSchemaTable(bool wantUniqueInfo, bool wantDefaultValue)\r
{\r
CheckClosed();\r
DataTable tblIndexes = null;\r
DataTable tblIndexColumns;\r
DataRow row;\r
+#if !MONOTOUCH\r
string temp;\r
+#endif\r
string strCatalog = "";\r
string strTable = "";\r
string strColumn = "";\r
row[SchemaTableColumn.DataType] = GetFieldType(n);\r
row[SchemaTableOptionalColumn.IsHidden] = false;\r
\r
+ // HACK: Prevent exploding if Sqlite was built without the SQLITE_ENABLE_COLUMN_METADATA option.\r
+ //\r
+ // This code depends on sqlite3_column_origin_name, which only exists if Sqlite was built with\r
+ // the SQLITE_ENABLE_COLUMN_METADATA option. This is not the case on iOS, MacOS or (most?)\r
+ // Androids, so we exclude it from the MONOTOUCH build, and degrade on other systems by simply\r
+ // omitting the metadata from the result.\r
+ //\r
+ // TODO: we could implement better fallbacks as proposed in\r
+ // https://bugzilla.xamarin.com/show_bug.cgi?id=2128\r
+ //\r
#if !MONOTOUCH\r
- strColumn = _command.Connection._sql.ColumnOriginalName(_activeStatement, n);\r
- if (String.IsNullOrEmpty(strColumn) == false) row[SchemaTableColumn.BaseColumnName] = strColumn;\r
+ if (hasColumnMetadataSupport) {\r
+ try {\r
+ strColumn = _command.Connection._sql.ColumnOriginalName(_activeStatement, n);\r
+ if (String.IsNullOrEmpty(strColumn) == false) row[SchemaTableColumn.BaseColumnName] = strColumn;\r
\r
- row[SchemaTableColumn.IsExpression] = String.IsNullOrEmpty(strColumn);\r
- row[SchemaTableColumn.IsAliased] = (String.Compare(GetName(n), strColumn, true, CultureInfo.InvariantCulture) != 0);\r
+ row[SchemaTableColumn.IsExpression] = String.IsNullOrEmpty(strColumn);\r
+ row[SchemaTableColumn.IsAliased] = (String.Compare(GetName(n), strColumn, true, CultureInfo.InvariantCulture) != 0);\r
\r
- temp = _command.Connection._sql.ColumnTableName(_activeStatement, n);\r
- if (String.IsNullOrEmpty(temp) == false) row[SchemaTableColumn.BaseTableName] = temp;\r
+ temp = _command.Connection._sql.ColumnTableName(_activeStatement, n);\r
+ if (String.IsNullOrEmpty(temp) == false) row[SchemaTableColumn.BaseTableName] = temp;\r
\r
- temp = _command.Connection._sql.ColumnDatabaseName(_activeStatement, n);\r
- if (String.IsNullOrEmpty(temp) == false) row[SchemaTableOptionalColumn.BaseCatalogName] = temp;\r
+ temp = _command.Connection._sql.ColumnDatabaseName(_activeStatement, n);\r
+ if (String.IsNullOrEmpty(temp) == false) row[SchemaTableOptionalColumn.BaseCatalogName] = temp;\r
+ } catch (EntryPointNotFoundException) {\r
+ hasColumnMetadataSupport = false;\r
+ }\r
+ }\r
#endif\r
\r
string dataType = null;\r