From 23d478f2fa06d1dedabfb24cf6ff763b586173ce Mon Sep 17 00:00:00 2001
From: Kunnis
Date: Sun, 9 Aug 2009 02:01:21 -0500
Subject: Adding in Reflection-based testing, to ensure that all properties are
covered.
---
OpenSim/Data/MySQL/MySQLAssetData.cs | 1 +
OpenSim/Data/MySQL/MySQLInventoryData.cs | 11 ++++++-----
OpenSim/Data/MySQL/MySQLRegionData.cs | 17 ++++++++++-------
OpenSim/Data/MySQL/Tests/MySQLGridTest.cs | 8 ++++++++
OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs | 12 +++++++++---
5 files changed, 34 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Data/MySQL')
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 26cdd06..5d87649 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -168,6 +168,7 @@ namespace OpenSim.Data.MySQL
}
asset.Name = (string) dbReader["name"];
asset.Type = (sbyte) dbReader["assetType"];
+ asset.Temporary = (bool)dbReader["temporary"];
}
dbReader.Close();
cmd.Dispose();
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index a4b8663..121ef7a 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -342,7 +342,7 @@ namespace OpenSim.Data.MySQL
item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
item.GroupPermissions = (uint) reader["inventoryGroupPermissions"];
item.SalePrice = (int) reader["salePrice"];
- item.SaleType = Convert.ToByte(reader["saleType"]);
+ item.SaleType = unchecked((byte)(Convert.ToSByte(reader["saleType"])));
item.CreationDate = (int) reader["creationDate"];
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
item.Flags = (uint) reader["flags"];
@@ -423,7 +423,7 @@ namespace OpenSim.Data.MySQL
///
/// Returns a specified inventory folder
///
- /// The folder to return
+ /// The folder to return
/// A folder class
public InventoryFolderBase getInventoryFolder(UUID folderID)
{
@@ -438,8 +438,9 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?uuid", folderID.ToString());
MySqlDataReader reader = result.ExecuteReader();
- reader.Read();
- InventoryFolderBase folder = readInventoryFolder(reader);
+ InventoryFolderBase folder = null;
+ if(reader.Read())
+ folder = readInventoryFolder(reader);
reader.Close();
result.Dispose();
@@ -506,7 +507,7 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
result.Parameters.AddWithValue("?salePrice", item.SalePrice);
- result.Parameters.AddWithValue("?saleType", item.SaleType);
+ result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
result.Parameters.AddWithValue("?creationDate", item.CreationDate);
result.Parameters.AddWithValue("?groupID", item.GroupID);
result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2166845..9c2ee4a 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -834,7 +834,10 @@ namespace OpenSim.Data.MySQL
// explicit conversion of integers is required, which sort
// of sucks. No idea if there is a shortcut here or not.
prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
- prim.Name = (String) row["Name"];
+ if (row["Name"] != DBNull.Value)
+ prim.Name = (String)row["Name"];
+ else
+ prim.Name = string.Empty;
// various text fields
prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
@@ -945,12 +948,12 @@ namespace OpenSim.Data.MySQL
prim.DIE_AT_EDGE = true;
prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
- prim.ObjectSaleType = Convert.ToByte(row["SaleType"]);
+ prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"]));
- prim.Material = Convert.ToByte(row["Material"]);
+ prim.Material = unchecked((byte)Convert.ToSByte(row["Material"]));
if (!(row["ClickAction"] is DBNull))
- prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]);
+ prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"]));
prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
@@ -1277,12 +1280,12 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("DieAtEdge", 0);
cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
- cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType));
+ cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType)));
byte clickAction = prim.ClickAction;
- cmd.Parameters.AddWithValue("ClickAction", clickAction);
+ cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction)));
- cmd.Parameters.AddWithValue("Material", prim.Material);
+ cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material)));
cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
index 7c36375..d1d5c2a 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
@@ -62,11 +62,18 @@ namespace OpenSim.Data.MySQL.Tests
m_log.Error("Exception {0}", e);
Assert.Ignore();
}
+
+ // This actually does the roll forward assembly stuff
+ Assembly assem = GetType().Assembly;
+ Migration m = new Migration(database.Connection, assem, "GridStore");
+
+ m.Update();
}
[TestFixtureTearDown]
public void Cleanup()
{
+ m_log.Warn("Cleaning up.");
if (db != null)
{
db.Dispose();
@@ -74,6 +81,7 @@ namespace OpenSim.Data.MySQL.Tests
// if a new table is added, it has to be dropped here
if (database != null)
{
+ database.ExecuteSql("drop table migrations");
database.ExecuteSql("drop table regions");
}
}
diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
index 23c1ec5..a3a32dc 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Data.MySQL.Tests
try
{
database = new MySQLManager(connect);
+ DropTables();
db = new MySQLInventoryData();
db.Initialise(connect);
}
@@ -72,10 +73,15 @@ namespace OpenSim.Data.MySQL.Tests
}
if (database != null)
{
- database.ExecuteSql("drop table inventoryitems");
- database.ExecuteSql("drop table inventoryfolders");
- database.ExecuteSql("drop table migrations");
+ DropTables();
}
}
+
+ private void DropTables()
+ {
+ database.ExecuteSql("drop table IF EXISTS inventoryitems");
+ database.ExecuteSql("drop table IF EXISTS inventoryfolders");
+ database.ExecuteSql("drop table IF EXISTS migrations");
+ }
}
}
--
cgit v1.1
From d2e5380cb2325ad42917c528c52a8ad42ec0176f Mon Sep 17 00:00:00 2001
From: Kunnis
Date: Sat, 15 Aug 2009 10:54:48 -0500
Subject: * Fixed MySQL/MySQLAssetData.cs to properly do updates * Removed an
extra parameter from MySQL/MySQLInventoryData.cs * Fixed a bug in
SQLite/SQLiteAssetData.cs that was causing a NRE when updating an asset. *
Improved the BasicAssetTest.cs to do full create/update/get testing *
Improved the BasicInventoryTest.cs to do full create/update/get of both a
folder and an item * Moved the null ref tests to the start of the
PropertyCompareConstraint.cs, so that it doesn't throw when passing in a null
item
---
OpenSim/Data/MySQL/MySQLAssetData.cs | 9 +--------
OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +-
2 files changed, 2 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Data/MySQL')
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 5d87649..0865083 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -196,18 +196,11 @@ namespace OpenSim.Data.MySQL
{
lock (_dbConnection)
{
- //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID);
- if (ExistsAsset(asset.FullID))
- {
- //m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
- return;
- }
-
_dbConnection.CheckConnection();
MySqlCommand cmd =
new MySqlCommand(
- "insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
+ "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
_dbConnection.Connection);
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 121ef7a..849c246 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -604,7 +604,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
cmd.Parameters.AddWithValue("?folderName", folderName);
- cmd.Parameters.AddWithValue("?type", (short) folder.Type);
+ cmd.Parameters.AddWithValue("?type", folder.Type);
cmd.Parameters.AddWithValue("?version", folder.Version);
try
--
cgit v1.1
From 82c888fc6c103ec345bf656cd469f4260b678bcb Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Mon, 17 Aug 2009 10:29:06 +0900
Subject: Add copyright headers. Formatting cleanup. Fix a compiler warning.
---
OpenSim/Data/MySQL/MySQLInventoryData.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Data/MySQL')
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 849c246..4521a0f 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -439,7 +439,7 @@ namespace OpenSim.Data.MySQL
MySqlDataReader reader = result.ExecuteReader();
InventoryFolderBase folder = null;
- if(reader.Read())
+ if (reader.Read())
folder = readInventoryFolder(reader);
reader.Close();
result.Dispose();
--
cgit v1.1