Merge pull request #1816 from Pryaxis/region-mysql
Missing backtick from RegionManager Group table.
This commit is contained in:
commit
ddb77adb79
2 changed files with 5 additions and 4 deletions
|
|
@ -49,6 +49,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
## TShock 4.4.0 (Pre-release 5)
|
## TShock 4.4.0 (Pre-release 5)
|
||||||
* Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder)
|
* Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder)
|
||||||
* Make sqlite db path configurable. (@AxeelAnder)
|
* Make sqlite db path configurable. (@AxeelAnder)
|
||||||
|
* Make TShock database MySQL 8 compatible by escaping column names in our IQueryBuilder code. (Name `Groups` is a reserved element in this version, which is used in our `Region` table.)
|
||||||
* Terraria 1.4.0.3 experimental support. (@Patrikkk)
|
* Terraria 1.4.0.3 experimental support. (@Patrikkk)
|
||||||
* Updated changelog. (@hakusaro)
|
* Updated changelog. (@hakusaro)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,12 +192,12 @@ namespace TShockAPI.DB
|
||||||
var columns =
|
var columns =
|
||||||
table.Columns.Select(
|
table.Columns.Select(
|
||||||
c =>
|
c =>
|
||||||
"{0} {1} {2} {3} {4} {5}".SFormat(c.Name, DbTypeToString(c.Type, c.Length),
|
"`{0}` {1} {2} {3} {4} {5}".SFormat(c.Name, DbTypeToString(c.Type, c.Length),
|
||||||
c.Primary ? "PRIMARY KEY" : "",
|
c.Primary ? "PRIMARY KEY" : "",
|
||||||
c.AutoIncrement ? "AUTO_INCREMENT" : "",
|
c.AutoIncrement ? "AUTO_INCREMENT" : "",
|
||||||
c.NotNull ? "NOT NULL" : "",
|
c.NotNull ? "NOT NULL" : "",
|
||||||
c.DefaultCurrentTimestamp ? "DEFAULT CURRENT_TIMESTAMP" : ""));
|
c.DefaultCurrentTimestamp ? "DEFAULT CURRENT_TIMESTAMP" : ""));
|
||||||
var uniques = table.Columns.Where(c => c.Unique).Select(c => c.Name);
|
var uniques = table.Columns.Where(c => c.Unique).Select(c => $"`{c.Name}`");
|
||||||
return "CREATE TABLE {0} ({1} {2})".SFormat(EscapeTableName(table.Name), string.Join(", ", columns),
|
return "CREATE TABLE {0} ({1} {2})".SFormat(EscapeTableName(table.Name), string.Join(", ", columns),
|
||||||
uniques.Count() > 0
|
uniques.Count() > 0
|
||||||
? ", UNIQUE({0})".SFormat(string.Join(", ", uniques))
|
? ", UNIQUE({0})".SFormat(string.Join(", ", uniques))
|
||||||
|
|
@ -299,7 +299,7 @@ namespace TShockAPI.DB
|
||||||
var create = CreateTable(to);
|
var create = CreateTable(to);
|
||||||
// combine all columns in the 'from' variable excluding ones that aren't in the 'to' variable.
|
// combine all columns in the 'from' variable excluding ones that aren't in the 'to' variable.
|
||||||
// exclude the ones that aren't in 'to' variable because if the column is deleted, why try to import the data?
|
// exclude the ones that aren't in 'to' variable because if the column is deleted, why try to import the data?
|
||||||
var columns = string.Join(", ", from.Columns.Where(c => to.Columns.Any(c2 => c2.Name == c.Name)).Select(c => c.Name));
|
var columns = string.Join(", ", from.Columns.Where(c => to.Columns.Any(c2 => c2.Name == c.Name)).Select(c => $"`{c.Name}`"));
|
||||||
var insert = "INSERT INTO {0} ({1}) SELECT {1} FROM {2}".SFormat(escapedTable, columns, tmpTable);
|
var insert = "INSERT INTO {0} ({1}) SELECT {1} FROM {2}".SFormat(escapedTable, columns, tmpTable);
|
||||||
var drop = "DROP TABLE {0}".SFormat(tmpTable);
|
var drop = "DROP TABLE {0}".SFormat(tmpTable);
|
||||||
return "{0}; {1}; {2}; {3};".SFormat(alter, create, insert, drop);
|
return "{0}; {1}; {2}; {3};".SFormat(alter, create, insert, drop);
|
||||||
|
|
@ -396,7 +396,7 @@ namespace TShockAPI.DB
|
||||||
if (0 == wheres.Count)
|
if (0 == wheres.Count)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
return "WHERE {0}".SFormat(string.Join(", ", wheres.Select(v => v.Name + " = " + v.Value)));
|
return "WHERE {0}".SFormat(string.Join(", ", wheres.Select(v => $"{v.Name}" + " = " + v.Value)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue