Skip to content

Commit a3dbcd7

Browse files
authored
Merge pull request #1824 from wheels-dev/database-structure-refactor
Database structure Refactor
2 parents 4925519 + c9848a4 commit a3dbcd7

File tree

24 files changed

+53
-47
lines changed

24 files changed

+53
-47
lines changed

.github/workflows/docs-sync.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: actions/checkout@v3
1818
with:
1919
fetch-depth: 0
20+
submodules: false
2021

2122
- name: Sync to shared docs folder
2223
run: |

core/src/wheels/Global.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ component output="false" {
215215
) {
216216
local.adapter = $get("adapterName");
217217

218-
if (local.adapter == "SQLServer") {
218+
if (local.adapter == "MicrosoftSQLServerModel") {
219219
local.sql = "
220220
SELECT
221221
DB_NAME() AS TABLE_CAT,
@@ -248,7 +248,7 @@ component output="false" {
248248
return local.rv;
249249
}
250250

251-
if (local.adapter == "Oracle") {
251+
if (local.adapter == "OracleModel") {
252252
local.sql = "
253253
SELECT
254254
NULL AS TABLE_CAT,
@@ -278,7 +278,7 @@ component output="false" {
278278
if (
279279
structKeyExists(arguments, "type") &&
280280
arguments.type eq "index" &&
281-
$get("adapterName") eq "SQLite"
281+
$get("adapterName") eq "SQLiteModel"
282282
) {
283283
local.sql = "
284284
SELECT
@@ -833,7 +833,7 @@ component output="false" {
833833
}
834834

835835
// Handle SQLite (TEXT storage)
836-
if (get("adapterName") == "SQLite") {
836+
if (get("adapterName") == "SQLiteModel") {
837837
// Store as quoted ISO 8601 string (standard for SQLite)
838838
if (IsDate(local.rv)) {
839839
local.rv = "'#DateFormat(local.rv, 'yyyy-mm-dd')# #TimeFormat(local.rv, 'HH:mm:ss')#'";

core/src/wheels/Model.cfc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ component output="false" displayName="Model" extends="wheels.Global"{
187187
variables.wheels.class.properties[local.property].datatype eq "TEXT"
188188
&& variables.wheels.class.properties[local.property].type eq "cf_sql_varchar"
189189
&& ReFindNoCase("\b(date|time|dob|birthday|birthTime|created|updated)\b", variables.wheels.class.properties[local.property].column)
190-
&& get("adapterName") eq "SQLite"
190+
&& get("adapterName") eq "SQLiteModel"
191191
) {
192192
// Override only validation type
193193
variables.wheels.class.properties[local.property].validationtype = "datetime";
@@ -385,17 +385,23 @@ component output="false" displayName="Model" extends="wheels.Global"{
385385
);
386386
}
387387
if (FindNoCase("SQLServer", local.info.driver_name) || FindNoCase("SQL Server", local.info.driver_name)) {
388-
local.adapterName = "SQLServer";
388+
local.adapterNamespace = "MicrosoftSQLServer";
389+
local.adapterName = "MicrosoftSQLServerModel";
389390
} else if (FindNoCase("MySQL", local.info.driver_name) || FindNoCase("MariaDB", local.info.driver_name)) {
390-
local.adapterName = "MySQL";
391+
local.adapterNamespace = "MySQL";
392+
local.adapterName = "MySQLModel";
391393
} else if (FindNoCase("PostgreSQL", local.info.driver_name)) {
392-
local.adapterName = "PostgreSQL";
394+
local.adapterNamespace = "PostgreSQL";
395+
local.adapterName = "PostgreSQLModel";
393396
} else if (FindNoCase("H2", local.info.driver_name)) {
394-
local.adapterName = "H2";
397+
local.adapterNamespace = "H2";
398+
local.adapterName = "H2Model";
395399
} else if (FindNoCase("Oracle", local.info.driver_name)) {
396-
local.adapterName = "Oracle";
400+
local.adapterNamespace = "Oracle";
401+
local.adapterName = "OracleModel";
397402
} else if (FindNoCase("SQLite", local.info.driver_name)) {
398-
local.adapterName = "SQLite";
403+
local.adapterNamespace = "SQLite";
404+
local.adapterName = "SQLiteModel";
399405
} else {
400406
Throw(
401407
type = "Wheels.DatabaseNotSupported",
@@ -404,7 +410,7 @@ component output="false" displayName="Model" extends="wheels.Global"{
404410
);
405411
}
406412
$set(adapterName = local.adapterName);
407-
return CreateObject("component", "wheels.model.adapters.#local.adapterName#").$init(
413+
return CreateObject("component", "wheels.databaseAdapters.#local.adapterNamespace#.#local.adapterName#").$init(
408414
dataSource = variables.wheels.class.dataSource,
409415
username = variables.wheels.class.username,
410416
password = variables.wheels.class.password
File renamed without changes.

core/src/wheels/migrator/adapters/H2.cfc renamed to core/src/wheels/databaseAdapters/H2/H2Migrator.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
component extends="Abstract" {
1+
component extends="wheels.databaseAdapters.Abstract" {
22

33
variables.sqlTypes = {};
44
variables.sqlTypes['biginteger'] = {name = 'BIGINT'};

core/src/wheels/model/adapters/H2.cfc renamed to core/src/wheels/databaseAdapters/H2/H2Model.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
component extends="Base" output=false {
1+
component extends="wheels.databaseAdapters.Base" output=false {
22

33
/**
44
* Map database types to the ones used in CFML.

core/src/wheels/migrator/adapters/MicrosoftSQLServer.cfc renamed to core/src/wheels/databaseAdapters/MicrosoftSQLServer/MicrosoftSQLServerMigrator.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
component extends="Abstract" {
1+
component extends="wheels.databaseAdapters.Abstract" {
22

33
variables.sqlTypes = {};
44
variables.sqlTypes['primaryKey'] = "int NOT NULL IDENTITY (1, 1)";

core/src/wheels/model/adapters/SQLServer.cfc renamed to core/src/wheels/databaseAdapters/MicrosoftSQLServer/MicrosoftSQLServerModel.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
component extends="Base" output=false {
1+
component extends="wheels.databaseAdapters.Base" output=false {
22

33
/**
44
* Map database types to the ones used in CFML.

core/src/wheels/migrator/adapters/MySQL.cfc renamed to core/src/wheels/databaseAdapters/MySQL/MySQLMigrator.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
component extends="Abstract" {
1+
component extends="wheels.databaseAdapters.Abstract" {
22

33
variables.sqlTypes = {};
44
variables.sqlTypes['biginteger'] = {name = 'BIGINT UNSIGNED'};

0 commit comments

Comments
 (0)