mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Database specific collate utf8 nocase
making and work
This commit is contained in:
parent
d16bb5cc08
commit
c6b1b08355
|
@ -26,6 +26,8 @@ public:
|
|||
// explicitly convert before inserting timestamps, NOTE: CURRENT_TIMESTAMP in SQLite is UTC by
|
||||
// default and doesn't have to be converted
|
||||
virtual const char *InsertTimestampAsUtc() const = 0;
|
||||
// can be used in the context of `LIKE Map`, adds `? COLLATE`
|
||||
virtual const char *CollateNocase() const = 0;
|
||||
|
||||
enum Status
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
virtual const char *BinaryCollate() const { return "utf8mb4_bin"; }
|
||||
virtual void ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize);
|
||||
virtual const char *InsertTimestampAsUtc() const { return "?"; }
|
||||
virtual const char *CollateNocase() const { return "CONVERT(? USING utf8mb4) COLLATE utf8mb4_general_ci"; }
|
||||
|
||||
virtual Status Connect();
|
||||
virtual void Disconnect();
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
virtual const char *BinaryCollate() const { return "BINARY"; }
|
||||
virtual void ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize);
|
||||
virtual const char *InsertTimestampAsUtc() const { return "DATETIME(?, 'utc')"; }
|
||||
virtual const char *CollateNocase() const { return "? COLLATE NOCASE"; }
|
||||
|
||||
virtual Status Connect();
|
||||
virtual void Disconnect();
|
||||
|
|
|
@ -291,13 +291,13 @@ bool CScore::MapVoteThread(IDbConnection *pSqlServer, const ISqlData *pGameData)
|
|||
str_format(aBuf, sizeof(aBuf),
|
||||
"SELECT Map, Server "
|
||||
"FROM %s_maps "
|
||||
"WHERE Map LIKE convert(? using utf8mb4) COLLATE utf8mb4_general_ci "
|
||||
"WHERE Map LIKE %s "
|
||||
"ORDER BY "
|
||||
"CASE WHEN Map = ? THEN 0 ELSE 1 END, "
|
||||
"CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, "
|
||||
"LENGTH(Map), Map "
|
||||
"LIMIT 1;",
|
||||
pSqlServer->GetPrefix());
|
||||
pSqlServer->GetPrefix(), pSqlServer->CollateNocase());
|
||||
pSqlServer->PrepareStatement(aBuf);
|
||||
pSqlServer->BindString(1, aFuzzyMap);
|
||||
pSqlServer->BindString(2, pData->m_Name);
|
||||
|
@ -362,7 +362,7 @@ bool CScore::MapInfoThread(IDbConnection *pSqlServer, const ISqlData *pGameData)
|
|||
"(SELECT MIN(Time) FROM %s_race WHERE Map = l.Map AND Name = ?) AS OwnTime "
|
||||
"FROM ("
|
||||
"SELECT * FROM %s_maps "
|
||||
"WHERE Map LIKE convert(? using utf8mb4) COLLATE utf8mb4_general_ci "
|
||||
"WHERE Map LIKE %s "
|
||||
"ORDER BY "
|
||||
"CASE WHEN Map = ? THEN 0 ELSE 1 END, "
|
||||
"CASE WHEN Map LIKE ? THEN 0 ELSE 1 END, "
|
||||
|
@ -372,7 +372,8 @@ bool CScore::MapInfoThread(IDbConnection *pSqlServer, const ISqlData *pGameData)
|
|||
") as l;",
|
||||
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(), pSqlServer->GetPrefix(),
|
||||
aTimestamp, aCurrentTimestamp, aTimestamp,
|
||||
pSqlServer->GetPrefix(), pSqlServer->GetPrefix()
|
||||
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(),
|
||||
pSqlServer->CollateNocase()
|
||||
);
|
||||
pSqlServer->PrepareStatement(aBuf);
|
||||
pSqlServer->BindString(1, pData->m_RequestingPlayer);
|
||||
|
|
Loading…
Reference in a new issue