diff options
author | Sean Dague | 2008-10-15 18:15:43 +0000 |
---|---|---|
committer | Sean Dague | 2008-10-15 18:15:43 +0000 |
commit | fa8c0d7683d567743f5138813f08a502aff8e3d0 (patch) | |
tree | 7ac4d9dbb9979fcc4734e4a1898c24287bc3b6d3 /OpenSim/Data/SQLite | |
parent | Removed some comments (diff) | |
download | opensim-SC_OLD-fa8c0d7683d567743f5138813f08a502aff8e3d0.zip opensim-SC_OLD-fa8c0d7683d567743f5138813f08a502aff8e3d0.tar.gz opensim-SC_OLD-fa8c0d7683d567743f5138813f08a502aff8e3d0.tar.bz2 opensim-SC_OLD-fa8c0d7683d567743f5138813f08a502aff8e3d0.tar.xz |
- Makes MySQL reject inserting UUID 0
- Makes SQLite mimick MySQL default behavior on first
and last name already on db: it does not insert the
new record.
- Added tests for UUID 0 and for new UUID with existing
first and last name.
Diffstat (limited to 'OpenSim/Data/SQLite')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserData.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index 420b6e5..448ef85 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs | |||
@@ -481,6 +481,37 @@ namespace OpenSim.Data.SQLite | |||
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | private bool ExistsFirstLastName(String fname, String lname) | ||
485 | { | ||
486 | string FindUser = "select * from users where (username=:username and surname=:surname)"; | ||
487 | using (SqliteCommand cmd = new SqliteCommand(FindUser, g_conn)) | ||
488 | { | ||
489 | cmd.Parameters.Add(new SqliteParameter(":username", fname)); | ||
490 | cmd.Parameters.Add(new SqliteParameter(":surname", lname)); | ||
491 | try | ||
492 | { | ||
493 | using (IDataReader reader = cmd.ExecuteReader()) | ||
494 | { | ||
495 | if(reader.Read()) | ||
496 | { | ||
497 | reader.Close(); | ||
498 | return true; | ||
499 | } | ||
500 | else | ||
501 | { | ||
502 | reader.Close(); | ||
503 | return false; | ||
504 | } | ||
505 | } | ||
506 | } | ||
507 | catch (Exception ex) | ||
508 | { | ||
509 | m_log.Error("[USER DB]: Exception searching for user's first and last name: " + ex.ToString()); | ||
510 | return false; | ||
511 | } | ||
512 | } | ||
513 | } | ||
514 | |||
484 | /// <summary> | 515 | /// <summary> |
485 | /// Creates a new user profile | 516 | /// Creates a new user profile |
486 | /// </summary> | 517 | /// </summary> |
@@ -488,6 +519,10 @@ namespace OpenSim.Data.SQLite | |||
488 | override public void AddNewUserProfile(UserProfileData user) | 519 | override public void AddNewUserProfile(UserProfileData user) |
489 | { | 520 | { |
490 | DataTable users = ds.Tables["users"]; | 521 | DataTable users = ds.Tables["users"]; |
522 | UUID zero = UUID.Zero; | ||
523 | if (ExistsFirstLastName(user.FirstName, user.SurName) || user.ID == zero) | ||
524 | return; | ||
525 | |||
491 | lock (ds) | 526 | lock (ds) |
492 | { | 527 | { |
493 | DataRow row = users.Rows.Find(Util.ToRawUuidString(user.ID)); | 528 | DataRow row = users.Rows.Find(Util.ToRawUuidString(user.ID)); |