Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 9d7fbfc

Browse files
Merge pull request #5770 from livecodemichael/bugfix-20013
[[ Bug 20013 ]] RevDB database types should be case insensitive.
2 parents 699a83c + 7155cbe commit 9d7fbfc

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

docs/notes/bugfix-20013.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Database type passed to revOpenDatabase should be case insensitive

revdb/src/revdb.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,30 @@ DATABASEREC *LoadDatabaseDriver(const char *p_type)
291291
{
292292
DATABASEREC *t_database_rec = nullptr;
293293

294+
char t_type[32];
295+
strcpy(t_type, p_type);
296+
strlwr(t_type);
297+
294298
if (revdbdriverpaths != nullptr)
295299
{
296300
t_database_rec = LoadDatabaseDriverInFolder(revdbdriverpaths, p_type);
297301
}
298302
else
299303
{
300-
t_database_rec = LoadDatabaseDriverInFolder(".", p_type);
304+
t_database_rec = LoadDatabaseDriverInFolder(".", t_type);
301305

302306

303307
if (t_database_rec == nullptr)
304308
t_database_rec = LoadDatabaseDriverInFolder("./Database Drivers",
305-
p_type);
309+
t_type);
306310

307311
if (t_database_rec == nullptr)
308312
t_database_rec = LoadDatabaseDriverInFolder("./database_drivers",
309-
p_type);
313+
t_type);
310314

311315
if (t_database_rec == nullptr)
312316
t_database_rec = LoadDatabaseDriverInFolder("./drivers",
313-
p_type);
317+
t_type);
314318
}
315319

316320
if (t_database_rec != nullptr)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
script "case-senstive-db-type"
2+
/*
3+
Copyright (C) 2017 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
local sDBDir
20+
21+
on TestSetup
22+
TestSkipIfNot "database", "sqlite"
23+
TestLoadExternal "revdb"
24+
25+
put TestGetEngineRepositoryPath() & "/_tests/_build/case-sensitive-db-type" into sDBDir
26+
create directory sDBDir
27+
end TestSetup
28+
29+
on TestTeardown
30+
delete directory sDBDir
31+
end TestTeardown
32+
33+
on TestOpenDBWithMixedCaseForType
34+
local tDBpath, tConnectionID
35+
36+
put sDBDir & "/test1-sqlite.db" into tDBPath
37+
put revOpenDatabase("sqlite", tDBPath) into tConnectionID
38+
TestAssert "open database of type sqlite" && tConnectionID, tConnectionID is an integer
39+
40+
put sDBDir & "/test2-SQLite.db" into tDBPath
41+
put revOpenDatabase("SQLite", tDBPath) into tConnectionID
42+
TestAssert "open database of type SQLite" && tConnectionID, tConnectionID is an integer
43+
end TestOpenDBWithMixedCaseForType

0 commit comments

Comments
 (0)