-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd084c8
commit d134e2e
Showing
11 changed files
with
279 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
module uim.databases.classes.drivers; | ||
|
||
public { | ||
public { // Main | ||
import uim.databases.classes.drivers.driver; | ||
} | ||
|
||
public { // Sub | ||
import uim.databases.classes.drivers.mysql; | ||
import uim.databases.classes.drivers.postgres; | ||
import uim.databases.classes.drivers.sqlite; | ||
import uim.databases.classes.drivers.sqlserver; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module uim.databases.classes.drivers.postgres; | ||
|
||
import uim.databases; | ||
|
||
@safe: | ||
class DPostgresDriver : DDriver { | ||
mixin(DriverThis!("Postgres")); | ||
|
||
// #region consts | ||
protected const MAX_ALIAS_LENGTH = 63; | ||
// #endregion consts | ||
|
||
override bool initialize(Json[string] initData = null) { | ||
if (!super.initialize(initData)) { | ||
return false; | ||
} | ||
|
||
configuration | ||
.setDefault("persistent", true) | ||
.setDefault("host", "localhost") | ||
.setDefault("username", "root") | ||
.setDefault("password", "") | ||
.setDefault("database", "uim") | ||
.setDefault("schema", "public") | ||
.setDefault("port", 5432) | ||
.setDefault("encoding", "utf8") | ||
.setDefault("timezone", Json(null)) | ||
.setDefault("flags", Json.emptyArray) | ||
.setDefault("init", Json.emptyArray); | ||
|
||
// String used to start a database identifier quoting to make it safe | ||
startQuote("\""); | ||
endQuote("\""); | ||
|
||
return true; | ||
} | ||
|
||
// #region SQL | ||
// Get the SQL for disabling foreign keys. | ||
override string sqlDisableForeignKey() { | ||
return "SET CONSTRAINTS ALL DEFERRED"; | ||
} | ||
|
||
override string sqlEnableForeignKey() { | ||
return "SET CONSTRAINTS ALL IMMEDIATE"; | ||
} | ||
// #endregion SQL | ||
|
||
} | ||
mixin(DriverCalls!("Postgres")); | ||
|
||
unittest { | ||
assert(PostgresDriver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/**************************************************************************************************************** | ||
* Copyright: © 2017-2024 Ozan Nurettin Süel (aka UIManufaktur) * | ||
* License: Subject to the terms of the Apache 2.0 license, as written in the included LICENSE.txt file. * | ||
* Authors: Ozan Nurettin Süel (aka UIManufaktur) * | ||
*****************************************************************************************************************/ | ||
module uim.databases.classes.drivers.sqlite; | ||
|
||
import uim.databases; | ||
|
||
@safe: | ||
|
||
class DSqliteDriver : DDriver { | ||
mixin(DriverThis!("Sqlite")); | ||
|
||
override bool initialize(Json[string] initData = null) { | ||
if (!super.initialize(initData)) { | ||
return false; | ||
} | ||
|
||
// `mask` The mask used for created database | ||
configuration | ||
.merge("persistent", false.toJson) | ||
.merge("username", "".toJson) | ||
.merge("password", "".toJson) | ||
.merge("database", Json(": memory:")) | ||
.merge("encoding", Json("utf8"),) | ||
.merge("mask", Json(/*0*/644)) | ||
.merge("cache", Json(null)) | ||
.merge("mode", Json(null)) | ||
.merge("flags", Json.emptyArray) | ||
.merge("init", Json.emptyArray); | ||
|
||
startQuote("\""); | ||
endQuote("\""); | ||
|
||
return true; | ||
} | ||
|
||
// #region foreignKeySQL | ||
// Get the SQL for disabling foreign keys. | ||
override string sqlDisableForeignKey() { | ||
return "PRAGMA foreign_keys = OFF"; | ||
} | ||
|
||
override string sqlEnableForeignKey() { | ||
return "PRAGMA foreign_keys = ON"; | ||
} | ||
// #endregion foreignKeySQL | ||
} | ||
mixin(DriverCalls!("Sqlite")); | ||
|
||
unittest { | ||
assert(SqliteDriver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/**************************************************************************************************************** | ||
* Copyright: © 2017-2024 Ozan Nurettin Süel (aka UIManufaktur) * | ||
* License: Subject to the terms of the Apache 2.0 license, as written in the included LICENSE.txt file. * | ||
* Authors: Ozan Nurettin Süel (aka UIManufaktur) * | ||
*****************************************************************************************************************/ | ||
module uim.databases.classes.drivers.sqlserver; | ||
|
||
import uim.databases; | ||
|
||
@safe: | ||
class DSqlserverDriver : DDriver { | ||
mixin(DriverThis!("Sqlserver")); | ||
|
||
override bool initialize(Json[string] initData = null) { | ||
if (!super.initialize(initData)) { | ||
return false; | ||
} | ||
|
||
configuration | ||
.merge("host", "localhost\\SQLEXPRESS") | ||
.merge("username", "") | ||
.merge("password", "") | ||
.merge("database", "uim") | ||
.merge("port", "") // PDO.SQLSRV_ENCODING_UTF8 | ||
.merge("encoding", 65_001) | ||
.merge( | ||
["flags", "init", "settings", "attributes"], Json.emptyArray | ||
) | ||
.merge( | ||
[ | ||
"app", "connectionPooling", "failoverPartner", "loginTimeout", | ||
"multiSubnetFailover", "encrypt", "trustServerCertificate" | ||
], | ||
Json(null)); | ||
|
||
startQuote("["); | ||
endQuote("]"); | ||
|
||
return true; | ||
} | ||
|
||
protected const MAX_ALIAS_LENGTH = 128; | ||
|
||
string sqlRollbackSavePoint(string name) { | ||
return "ROLLBACK TRANSACTION t" ~ name; | ||
} | ||
|
||
override string sqlDisableForeignKey() { | ||
return "EXEC sp_MSforeachtable \"ALTER TABLE ? NOCHECK CONSTRAINT all\""; | ||
} | ||
|
||
override string sqlEnableForeignKey() { | ||
return "EXEC sp_MSforeachtable \"ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all\""; | ||
} | ||
|
||
string sqlSavePoint(string name) { | ||
return "SAVE TRANSACTION t" ~ name; | ||
} | ||
} | ||
|
||
mixin(DriverCalls!("Sqlserver")); | ||
|
||
unittest { | ||
assert(SqlserverDriver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ import uim.databases; | |
|
||
@safe: | ||
|
||
interface IExpression {} | ||
interface IExpression { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module uim.databases.interfaces.query; | ||
|
||
import uim.databases; | ||
|
||
@safe: | ||
interface ISQLQuery {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters