banshee r4981 - in trunk/banshee: . build build/pkg-config docs/Hyena/en/Hyena.Data.Sqlite src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Libraries/Hyena src/Libraries/Hyena/Hyena.Data.Sqlite
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4981 - in trunk/banshee: . build build/pkg-config docs/Hyena/en/Hyena.Data.Sqlite src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Libraries/Hyena src/Libraries/Hyena/Hyena.Data.Sqlite
- Date: Wed, 28 Jan 2009 01:29:08 +0000 (UTC)
Author: gburt
Date: Wed Jan 28 01:29:07 2009
New Revision: 4981
URL: http://svn.gnome.org/viewvc/banshee?rev=4981&view=rev
Log:
2009-01-27 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs:
* src/Core/Banshee.Services/Banshee.Services.csproj:
* src/Core/Banshee.Services/Banshee.Database/QueuedSqliteDatabase.cs:
* src/Libraries/Hyena/Makefile.am:
* src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs:
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteArrayDataReader.cs:
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs:
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs:
* docs/Hyena/en/Hyena.Data.Sqlite/ExecutingEventArgs.xml:
* build/pkg-config/banshee-1-hyena.pc.in:
* build/build.environment.mk:
* configure.ac: Patch from John Millikin transitioning us from
Mono.Data.SqliteClient to Mono.Data.Sqlite (BGO #568787). He solved the
threading issue I found when I tried about a year ago; SqliteClient read
the entire result into an array before handing it back, so we just do that
with the M.D.Sqlite results. This should be all we need to start using
prepared SQL statements and custom extension functions in Sqlite.
Added:
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteArrayDataReader.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/build/build.environment.mk
trunk/banshee/build/pkg-config/banshee-1-hyena.pc.in
trunk/banshee/configure.ac
trunk/banshee/docs/Hyena/en/Hyena.Data.Sqlite/ExecutingEventArgs.xml
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/QueuedSqliteDatabase.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
trunk/banshee/src/Libraries/Hyena/Makefile.am
Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk (original)
+++ trunk/banshee/build/build.environment.mk Wed Jan 28 01:29:07 2009
@@ -10,7 +10,7 @@
# External libraries to link against, generated from configure
LINK_SYSTEM = -r:System
LINK_SYSTEM_WEB = -r:System.Web
-LINK_SQLITE = -r:System.Data -r:Mono.Data.SqliteClient
+LINK_SQLITE = -r:System.Data -r:Mono.Data.Sqlite
LINK_CAIRO = -r:Mono.Cairo
LINK_MONO_POSIX = -r:Mono.Posix
LINK_ICSHARP_ZIP_LIB = -r:ICSharpCode.SharpZipLib
Modified: trunk/banshee/build/pkg-config/banshee-1-hyena.pc.in
==============================================================================
--- trunk/banshee/build/pkg-config/banshee-1-hyena.pc.in (original)
+++ trunk/banshee/build/pkg-config/banshee-1-hyena.pc.in Wed Jan 28 01:29:07 2009
@@ -6,5 +6,5 @@
Name: Banshee Hyena
Description: Hyena libraries for the Banshee Media Framework
Version: @VERSION@
-Libs: -r:System -r:System.Data -r:Mono.Data.SqliteClient -r:Mono.Posix -r:${bansheedir}/Hyena.dll
+Libs: -r:System -r:System.Data -r:Mono.Data.Sqlite -r:Mono.Posix -r:${bansheedir}/Hyena.dll
Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac (original)
+++ trunk/banshee/configure.ac Wed Jan 28 01:29:07 2009
@@ -42,7 +42,7 @@
System.Web
System.Web.Services
Mono.Cairo
- Mono.Data.SqliteClient
+ Mono.Data.Sqlite
Mono.Posix
ICSharpCode.SharpZipLib
])
Modified: trunk/banshee/docs/Hyena/en/Hyena.Data.Sqlite/ExecutingEventArgs.xml
==============================================================================
--- trunk/banshee/docs/Hyena/en/Hyena.Data.Sqlite/ExecutingEventArgs.xml (original)
+++ trunk/banshee/docs/Hyena/en/Hyena.Data.Sqlite/ExecutingEventArgs.xml Wed Jan 28 01:29:07 2009
@@ -16,20 +16,20 @@
<Members>
<Member MemberName=".ctor">
- <MemberSignature Language="C#" Value="public ExecutingEventArgs (Mono.Data.SqliteClient.SqliteCommand command);" />
+ <MemberSignature Language="C#" Value="public ExecutingEventArgs (Mono.Data.Sqlite.SqliteCommand command);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.3.1.0</AssemblyVersion><AssemblyVersion>1.4.0.0</AssemblyVersion></AssemblyInfo>
- <Parameters><Parameter Name="command" Type="Mono.Data.SqliteClient.SqliteCommand" /></Parameters>
+ <Parameters><Parameter Name="command" Type="Mono.Data.Sqlite.SqliteCommand" /></Parameters>
<Docs><param name="command">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks></Docs>
</Member><Member MemberName="Command">
- <MemberSignature Language="C#" Value="public readonly Mono.Data.SqliteClient.SqliteCommand Command;" />
+ <MemberSignature Language="C#" Value="public readonly Mono.Data.Sqlite.SqliteCommand Command;" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.3.1.0</AssemblyVersion><AssemblyVersion>1.4.0.0</AssemblyVersion></AssemblyInfo>
- <ReturnValue><ReturnType>Mono.Data.SqliteClient.SqliteCommand</ReturnType></ReturnValue>
+ <ReturnValue><ReturnType>Mono.Data.Sqlite.SqliteCommand</ReturnType></ReturnValue>
<Docs><summary>To be added.</summary><remarks>To be added.</remarks></Docs>
</Member>
</Members>
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs Wed Jan 28 01:29:07 2009
@@ -121,7 +121,7 @@
return a != null && b != null &&
a.TrackId == b.TrackId &&
a.CacheModelId == b.CacheModelId &&
- (int)a.CacheEntryId == (int)b.CacheEntryId;
+ (long)a.CacheEntryId == (long)b.CacheEntryId;
}
public DatabaseArtistInfo Artist {
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/QueuedSqliteDatabase.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/QueuedSqliteDatabase.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/QueuedSqliteDatabase.cs Wed Jan 28 01:29:07 2009
@@ -29,7 +29,7 @@
using System;
using System.Threading;
using System.Collections.Generic;
-using Mono.Data.SqliteClient;
+using Mono.Data.Sqlite;
namespace Banshee.Database
{
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj Wed Jan 28 01:29:07 2009
@@ -28,7 +28,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
- <Reference Include="Mono.Data.SqliteClient" />
+ <Reference Include="Mono.Data.Sqlite" />
<Reference Include="Mono.Posix" />
<Reference Include="NDesk.DBus, Version=1.0.0.0, Culture=neutral" />
<Reference Include="NDesk.DBus.GLib, Version=1.0.0.0, Culture=neutral" />
Added: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteArrayDataReader.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteArrayDataReader.cs Wed Jan 28 01:29:07 2009
@@ -0,0 +1,392 @@
+//
+// HyenaSqliteArrayDataReader.cs
+//
+// Authors:
+// Vladimir Vukicevic <vladimir pobox com>
+// Everaldo Canuto <everaldo_canuto yahoo com br>
+// Joshua Tauberer <tauberer for net>
+// John Millikin <jmillikin gmail com>
+//
+// Copyright (C) 2002 Vladimir Vukicevic
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Data.Common;
+using System.Text;
+using System.Collections;
+using Mono.Data.Sqlite;
+
+namespace Hyena.Data.Sqlite
+{
+ /** Adapted from Mono.Data.SqliteClient.SqliteDataReader
+ *
+ * The new data reader in Mono.Data.Sqlite lazily loads the resultset
+ * from the underlying database cursor. This class reads the entire
+ * resultset into memory, allowing further queries to be executed before
+ * all data readers have been exhausted.
+ **/
+ internal class HyenaSqliteArrayDataReader : MarshalByRefObject, IEnumerable, IDataReader, IDisposable, IDataRecord
+ {
+ #region Fields
+
+ private ArrayList rows;
+ private string[] columns;
+ private Hashtable column_names_sens, column_names_insens;
+ private int current_row;
+ private bool closed;
+ private int records_affected;
+ private string[] decltypes;
+
+ #endregion
+
+ #region Constructors and destructors
+
+ internal HyenaSqliteArrayDataReader (SqliteDataReader reader)
+ {
+ rows = new ArrayList ();
+ column_names_sens = new Hashtable ();
+ column_names_insens = new Hashtable (StringComparer.InvariantCultureIgnoreCase);
+ closed = false;
+ current_row = -1;
+ ReadAllRows (reader);
+ }
+
+ #endregion
+
+ #region Properties
+
+ public int Depth {
+ get { return 0; }
+ }
+
+ public int FieldCount {
+ get { return columns.Length; }
+ }
+
+ public object this[string name] {
+ get {
+ return GetValue (GetOrdinal (name));
+ }
+ }
+
+ public object this[int i] {
+ get { return GetValue (i); }
+ }
+
+ public bool IsClosed {
+ get { return closed; }
+ }
+
+ public int RecordsAffected {
+ get { return records_affected; }
+ }
+
+ #endregion
+
+ #region Internal Methods
+
+ internal void ReadAllRows (SqliteDataReader reader)
+ {
+ int ii, field_count = reader.FieldCount;
+
+ /* Metadata */
+ records_affected = reader.RecordsAffected;
+
+ decltypes = new string[field_count];
+ for (ii = 0; ii < field_count; ii++)
+ decltypes[ii] = reader.GetDataTypeName (ii);
+
+ columns = new string[field_count];
+ for (ii = 0; ii < field_count; ii++)
+ {
+ string column_name = reader.GetName (ii);
+ columns[ii] = column_name;
+ column_names_sens[column_name] = ii;
+ column_names_insens[column_name] = ii;
+ }
+
+ /* Read all rows, store in this->rows */
+ while (reader.Read ())
+ {
+ object[] data_row = new object[field_count];
+ for (ii = 0; ii < field_count; ii++)
+ {
+ object value = reader.GetValue (ii);
+ if (Convert.IsDBNull (value))
+ value = null;
+ data_row[ii] = value;
+ }
+ rows.Add (data_row);
+ }
+ }
+
+ #endregion
+
+ #region Public Methods
+
+ public void Close ()
+ {
+ closed = true;
+ }
+
+ public void Dispose ()
+ {
+ Close ();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return new DbEnumerator (this);
+ }
+
+ public DataTable GetSchemaTable ()
+ {
+ DataTable dataTableSchema = new DataTable ();
+
+ dataTableSchema.Columns.Add ("ColumnName", typeof (String));
+ dataTableSchema.Columns.Add ("ColumnOrdinal", typeof (Int32));
+ dataTableSchema.Columns.Add ("ColumnSize", typeof (Int32));
+ dataTableSchema.Columns.Add ("NumericPrecision", typeof (Int32));
+ dataTableSchema.Columns.Add ("NumericScale", typeof (Int32));
+ dataTableSchema.Columns.Add ("IsUnique", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsKey", typeof (Boolean));
+ dataTableSchema.Columns.Add ("BaseCatalogName", typeof (String));
+ dataTableSchema.Columns.Add ("BaseColumnName", typeof (String));
+ dataTableSchema.Columns.Add ("BaseSchemaName", typeof (String));
+ dataTableSchema.Columns.Add ("BaseTableName", typeof (String));
+ dataTableSchema.Columns.Add ("DataType", typeof(Type));
+ dataTableSchema.Columns.Add ("AllowDBNull", typeof (Boolean));
+ dataTableSchema.Columns.Add ("ProviderType", typeof (Int32));
+ dataTableSchema.Columns.Add ("IsAliased", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsExpression", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsIdentity", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsAutoIncrement", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsRowVersion", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsHidden", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsLong", typeof (Boolean));
+ dataTableSchema.Columns.Add ("IsReadOnly", typeof (Boolean));
+
+ dataTableSchema.BeginLoadData();
+ for (int i = 0; i < this.FieldCount; i += 1 ) {
+
+ DataRow schemaRow = dataTableSchema.NewRow ();
+
+ schemaRow["ColumnName"] = columns[i];
+ schemaRow["ColumnOrdinal"] = i;
+ schemaRow["ColumnSize"] = 0;
+ schemaRow["NumericPrecision"] = 0;
+ schemaRow["NumericScale"] = 0;
+ schemaRow["IsUnique"] = false;
+ schemaRow["IsKey"] = false;
+ schemaRow["BaseCatalogName"] = "";
+ schemaRow["BaseColumnName"] = columns[i];
+ schemaRow["BaseSchemaName"] = "";
+ schemaRow["BaseTableName"] = "";
+ schemaRow["DataType"] = typeof(string);
+ schemaRow["AllowDBNull"] = true;
+ schemaRow["ProviderType"] = 0;
+ schemaRow["IsAliased"] = false;
+ schemaRow["IsExpression"] = false;
+ schemaRow["IsIdentity"] = false;
+ schemaRow["IsAutoIncrement"] = false;
+ schemaRow["IsRowVersion"] = false;
+ schemaRow["IsHidden"] = false;
+ schemaRow["IsLong"] = false;
+ schemaRow["IsReadOnly"] = false;
+
+ dataTableSchema.Rows.Add (schemaRow);
+ schemaRow.AcceptChanges();
+ }
+ dataTableSchema.EndLoadData();
+
+ return dataTableSchema;
+ }
+
+ public bool NextResult ()
+ {
+ current_row++;
+
+ return (current_row < rows.Count);
+ }
+
+ public bool Read ()
+ {
+ return NextResult ();
+ }
+
+ #endregion
+
+ #region IDataRecord getters
+
+ public bool GetBoolean (int i)
+ {
+ return Convert.ToBoolean (((object[]) rows[current_row])[i]);
+ }
+
+ public byte GetByte (int i)
+ {
+ return Convert.ToByte (((object[]) rows[current_row])[i]);
+ }
+
+ public long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferOffset, int length)
+ {
+ byte[] data = (byte[])(((object[]) rows[current_row])[i]);
+ if (buffer != null)
+ Array.Copy (data, fieldOffset, buffer, bufferOffset, length);
+ return data.LongLength - fieldOffset;
+ }
+
+ public char GetChar (int i)
+ {
+ return Convert.ToChar (((object[]) rows[current_row])[i]);
+ }
+
+ public long GetChars (int i, long fieldOffset, char[] buffer, int bufferOffset, int length)
+ {
+ char[] data = (char[])(((object[]) rows[current_row])[i]);
+ if (buffer != null)
+ Array.Copy (data, fieldOffset, buffer, bufferOffset, length);
+ return data.LongLength - fieldOffset;
+ }
+
+ public IDataReader GetData (int i)
+ {
+ return ((IDataReader) this [i]);
+ }
+
+ public string GetDataTypeName (int i)
+ {
+ if (decltypes != null && decltypes[i] != null)
+ return decltypes[i];
+ return "text"; // SQL Lite data type
+ }
+
+ public DateTime GetDateTime (int i)
+ {
+ return Convert.ToDateTime (((object[]) rows[current_row])[i]);
+ }
+
+ public decimal GetDecimal (int i)
+ {
+ return Convert.ToDecimal (((object[]) rows[current_row])[i]);
+ }
+
+ public double GetDouble (int i)
+ {
+ return Convert.ToDouble (((object[]) rows[current_row])[i]);
+ }
+
+ public Type GetFieldType (int i)
+ {
+ int row = current_row;
+ if (row == -1 && rows.Count == 0) return typeof(string);
+ if (row == -1) row = 0;
+ object element = ((object[]) rows[row])[i];
+ if (element != null)
+ return element.GetType();
+ else
+ return typeof (string);
+
+ // Note that the return value isn't guaranteed to
+ // be the same as the rows are read if different
+ // types of information are stored in the column.
+ }
+
+ public float GetFloat (int i)
+ {
+ return Convert.ToSingle (((object[]) rows[current_row])[i]);
+ }
+
+ public Guid GetGuid (int i)
+ {
+ object value = GetValue (i);
+ if (!(value is Guid)) {
+ if (value is DBNull)
+ throw new SqliteExecutionException ("Column value must not be null");
+ throw new InvalidCastException ("Type is " + value.GetType ().ToString ());
+ }
+ return ((Guid) value);
+ }
+
+ public short GetInt16 (int i)
+ {
+ return Convert.ToInt16 (((object[]) rows[current_row])[i]);
+ }
+
+ public int GetInt32 (int i)
+ {
+ return Convert.ToInt32 (((object[]) rows[current_row])[i]);
+ }
+
+ public long GetInt64 (int i)
+ {
+ return Convert.ToInt64 (((object[]) rows[current_row])[i]);
+ }
+
+ public string GetName (int i)
+ {
+ return columns[i];
+ }
+
+ public int GetOrdinal (string name)
+ {
+ object v = column_names_sens[name];
+ if (v == null)
+ v = column_names_insens[name];
+ if (v == null)
+ throw new ArgumentException("Column does not exist.");
+ return (int) v;
+ }
+
+ public string GetString (int i)
+ {
+ return (((object[]) rows[current_row])[i]).ToString();
+ }
+
+ public object GetValue (int i)
+ {
+ return ((object[]) rows[current_row])[i];
+ }
+
+ public int GetValues (object[] values)
+ {
+ int num_to_fill = System.Math.Min (values.Length, columns.Length);
+ for (int i = 0; i < num_to_fill; i++) {
+ if (((object[]) rows[current_row])[i] != null) {
+ values[i] = ((object[]) rows[current_row])[i];
+ } else {
+ values[i] = null;
+ }
+ }
+ return num_to_fill;
+ }
+
+ public bool IsDBNull (int i)
+ {
+ return (((object[]) rows[current_row])[i] == null);
+ }
+
+ #endregion
+ }
+}
+// vi:tabstop=4:expandtab
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs Wed Jan 28 01:29:07 2009
@@ -32,11 +32,7 @@
using System.Data;
using System.Text;
using System.Threading;
-
-// NOTE: Mono.Data.Sqlite has serious threading issues. You cannot access
-// its results from any thread but the one the SqliteConnection belongs to.
-// That is why we still use Mono.Data.SqliteClient.
-using Mono.Data.SqliteClient;
+using Mono.Data.Sqlite;
namespace Hyena.Data.Sqlite
{
@@ -124,7 +120,9 @@
switch (command_type) {
case HyenaCommandType.Reader:
- result = sql_command.ExecuteReader ();
+ using (SqliteDataReader reader = sql_command.ExecuteReader ()) {
+ result = new HyenaSqliteArrayDataReader (reader);
+ }
break;
case HyenaCommandType.Scalar:
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs Wed Jan 28 01:29:07 2009
@@ -31,11 +31,7 @@
using System.Data;
using System.Threading;
using System.Collections.Generic;
-
-// NOTE: Mono.Data.Sqlite has serious threading issues. You cannot access
-// its results from any thread but the one the SqliteConnection belongs to.
-// That is why we still use Mono.Data.SqliteClient.
-using Mono.Data.SqliteClient;
+using Mono.Data.Sqlite;
namespace Hyena.Data.Sqlite
{
@@ -135,14 +131,14 @@
{
command.CommandType = HyenaCommandType.Reader;
QueueCommand (command);
- return command.WaitForResult (this) as SqliteDataReader;
+ return command.WaitForResult (this) as IDataReader;
}
public IDataReader Query (HyenaSqliteCommand command, params object [] param_values)
{
command.CommandType = HyenaCommandType.Reader;
QueueCommand (command, param_values);
- return command.WaitForResult (this) as SqliteDataReader;
+ return command.WaitForResult (this) as IDataReader;
}
public IDataReader Query (string command_str, params object [] param_values)
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/SqliteUtils.cs Wed Jan 28 01:29:07 2009
@@ -73,6 +73,9 @@
public static object FromDbFormat (Type type, object value)
{
+ if (Convert.IsDBNull (value))
+ value = null;
+
if (type == typeof (DateTime)) {
return value == null
? DateTime.MinValue
@@ -90,7 +93,7 @@
} else if (type.IsEnum) {
return Enum.ToObject (type, value);
} else if (type == typeof (bool)) {
- return ((int)value == 1);
+ return ((long)value == 1);
} else {
return Convert.ChangeType (value, type);
}
Modified: trunk/banshee/src/Libraries/Hyena/Makefile.am
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Makefile.am (original)
+++ trunk/banshee/src/Libraries/Hyena/Makefile.am Wed Jan 28 01:29:07 2009
@@ -21,6 +21,7 @@
Hyena.CommandLine/LayoutOption.cs \
Hyena.Data.Sqlite/DatabaseColumn.cs \
Hyena.Data.Sqlite/DatabaseColumnAttribute.cs \
+ Hyena.Data.Sqlite/HyenaSqliteArrayDataReader.cs \
Hyena.Data.Sqlite/HyenaSqliteCommand.cs \
Hyena.Data.Sqlite/HyenaSqliteConnection.cs \
Hyena.Data.Sqlite/ICacheableDatabaseModel.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]