Skip to content
Merged
1 change: 1 addition & 0 deletions .github/workflows/docs-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: false

- name: Sync to shared docs folder
run: |
Expand Down
8 changes: 4 additions & 4 deletions core/src/wheels/Global.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ component output="false" {
) {
local.adapter = $get("adapterName");

if (local.adapter == "SQLServer") {
if (local.adapter == "MicrosoftSQLServerModel") {
local.sql = "
SELECT
DB_NAME() AS TABLE_CAT,
Expand Down Expand Up @@ -248,7 +248,7 @@ component output="false" {
return local.rv;
}

if (local.adapter == "Oracle") {
if (local.adapter == "OracleModel") {
local.sql = "
SELECT
NULL AS TABLE_CAT,
Expand Down Expand Up @@ -278,7 +278,7 @@ component output="false" {
if (
structKeyExists(arguments, "type") &&
arguments.type eq "index" &&
$get("adapterName") eq "SQLite"
$get("adapterName") eq "SQLiteModel"
) {
local.sql = "
SELECT
Expand Down Expand Up @@ -833,7 +833,7 @@ component output="false" {
}

// Handle SQLite (TEXT storage)
if (get("adapterName") == "SQLite") {
if (get("adapterName") == "SQLiteModel") {
// Store as quoted ISO 8601 string (standard for SQLite)
if (IsDate(local.rv)) {
local.rv = "'#DateFormat(local.rv, 'yyyy-mm-dd')# #TimeFormat(local.rv, 'HH:mm:ss')#'";
Expand Down
22 changes: 14 additions & 8 deletions core/src/wheels/Model.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ component output="false" displayName="Model" extends="wheels.Global"{
variables.wheels.class.properties[local.property].datatype eq "TEXT"
&& variables.wheels.class.properties[local.property].type eq "cf_sql_varchar"
&& ReFindNoCase("\b(date|time|dob|birthday|birthTime|created|updated)\b", variables.wheels.class.properties[local.property].column)
&& get("adapterName") eq "SQLite"
&& get("adapterName") eq "SQLiteModel"
) {
// Override only validation type
variables.wheels.class.properties[local.property].validationtype = "datetime";
Expand Down Expand Up @@ -385,17 +385,23 @@ component output="false" displayName="Model" extends="wheels.Global"{
);
}
if (FindNoCase("SQLServer", local.info.driver_name) || FindNoCase("SQL Server", local.info.driver_name)) {
local.adapterName = "SQLServer";
local.adapterNamespace = "MicrosoftSQLServer";
local.adapterName = "MicrosoftSQLServerModel";
} else if (FindNoCase("MySQL", local.info.driver_name) || FindNoCase("MariaDB", local.info.driver_name)) {
local.adapterName = "MySQL";
local.adapterNamespace = "MySQL";
local.adapterName = "MySQLModel";
} else if (FindNoCase("PostgreSQL", local.info.driver_name)) {
local.adapterName = "PostgreSQL";
local.adapterNamespace = "PostgreSQL";
local.adapterName = "PostgreSQLModel";
} else if (FindNoCase("H2", local.info.driver_name)) {
local.adapterName = "H2";
local.adapterNamespace = "H2";
local.adapterName = "H2Model";
} else if (FindNoCase("Oracle", local.info.driver_name)) {
local.adapterName = "Oracle";
local.adapterNamespace = "Oracle";
local.adapterName = "OracleModel";
} else if (FindNoCase("SQLite", local.info.driver_name)) {
local.adapterName = "SQLite";
local.adapterNamespace = "SQLite";
local.adapterName = "SQLiteModel";
} else {
Throw(
type = "Wheels.DatabaseNotSupported",
Expand All @@ -404,7 +410,7 @@ component output="false" displayName="Model" extends="wheels.Global"{
);
}
$set(adapterName = local.adapterName);
return CreateObject("component", "wheels.model.adapters.#local.adapterName#").$init(
return CreateObject("component", "wheels.databaseAdapters.#local.adapterNamespace#.#local.adapterName#").$init(
dataSource = variables.wheels.class.dataSource,
username = variables.wheels.class.username,
password = variables.wheels.class.password
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Abstract" {
component extends="wheels.databaseAdapters.Abstract" {

variables.sqlTypes = {};
variables.sqlTypes['biginteger'] = {name = 'BIGINT'};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Base" output=false {
component extends="wheels.databaseAdapters.Base" output=false {

/**
* Map database types to the ones used in CFML.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Abstract" {
component extends="wheels.databaseAdapters.Abstract" {

variables.sqlTypes = {};
variables.sqlTypes['primaryKey'] = "int NOT NULL IDENTITY (1, 1)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Base" output=false {
component extends="wheels.databaseAdapters.Base" output=false {

/**
* Map database types to the ones used in CFML.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Abstract" {
component extends="wheels.databaseAdapters.Abstract" {

variables.sqlTypes = {};
variables.sqlTypes['biginteger'] = {name = 'BIGINT UNSIGNED'};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Base" output=false {
component extends="wheels.databaseAdapters.Base" output=false {

/**
* Map database types to the ones used in CFML.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Abstract" {
component extends="wheels.databaseAdapters.Abstract" {

/**
* SQL type mappings specific to Oracle Database 12c+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Base" output=false {
component extends="wheels.databaseAdapters.Base" output=false {

/**
* Map database types to the ones used in CFML.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Abstract" {
component extends="wheels.databaseAdapters.Abstract" {

variables.sqlTypes = {};
variables.sqlTypes['binary'] = {name = 'BYTEA'};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Base" output=false {
component extends="wheels.databaseAdapters.Base" output=false {

/**
* Map database types to the ones used in CFML.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Abstract" {
component extends="wheels.databaseAdapters.Abstract" {

// SQLite type mapping (simpler type system)
variables.sqlTypes = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="Base" output=false {
component extends="wheels.databaseAdapters.Base" output=false {

/**
* Map SQLite types to CFML types.
Expand Down
6 changes: 3 additions & 3 deletions core/src/wheels/migrator/Migration.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ component extends="Base" {
extendedInfo = "Use SQL Server, MySQL, MariaDB, PostgreSQL, Oracle, SQLite or H2."
);
} else {
this.adapter = CreateObject("component", "adapters.#dbType#");
this.adapter = CreateObject("component", "wheels.databaseAdapters.#dbType#.#dbType#Migrator");
}
return this;
}
Expand Down Expand Up @@ -424,7 +424,7 @@ component extends="Base" {
} else if (IsBoolean(arguments[local.key])) {
local.columnValues = ListAppend(local.columnValues, IIf(arguments[local.key], 1, 0));
} else if (IsDate(arguments[local.key])) {
if(get("adapterName") == "SQLite" && $isTimestampLiteral(arguments[local.key])){
if(get("adapterName") == "SQLiteModel" && $isTimestampLiteral(arguments[local.key])){
local.columnValues = '"#$convertToString(arguments[local.key])#"';
} else {
local.columnValues = ListAppend(local.columnValues, "#arguments[local.key]#");
Expand Down Expand Up @@ -486,7 +486,7 @@ component extends="Base" {
} else if (IsBoolean(arguments[local.key])) {
local.update = local.update & "#IIf(arguments[local.key], 1, 0)#";
} else if (IsDate(arguments[local.key])) {
if(get("adapterName") == "SQLite" && $isTimestampLiteral(arguments[local.key])){
if(get("adapterName") == "SQLiteModel" && $isTimestampLiteral(arguments[local.key])){
local.update = local.update & '"#$convertToString(arguments[local.key])#"';
} else {
local.update = local.update & "#arguments[local.key]#";
Expand Down
6 changes: 3 additions & 3 deletions core/src/wheels/model/sql.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ component {
ArrayAppend(arguments.sql, "UPDATE #tableName()# SET #variables.wheels.class.softDeleteColumn# = ");
}
// Use cf_sql_varchar in SQLite for TEXT timestamps
if(get("adapterName") eq "SQLite") {
if(get("adapterName") eq "SQLiteModel") {
local.type = "cf_sql_varchar";
} else {
local.type = "cf_sql_timestamp";
Expand All @@ -40,9 +40,9 @@ component {
local.rv = "";
if (StructKeyExists(arguments.useIndex, arguments.modelName)) {
local.indexName = arguments.useIndex[arguments.modelName];
if (arguments.adapterName == "MySQL") {
if (arguments.adapterName == "MySQLModel") {
local.rv = "USE INDEX(#local.indexName#)";
} else if (arguments.adapterName == "SQLServer") {
} else if (arguments.adapterName == "MicrosoftSQLServerModel") {
local.rv = "WITH (INDEX(#local.indexName#))";
}
}
Expand Down
7 changes: 3 additions & 4 deletions core/src/wheels/tests_testbox/specs/global/dbinfoSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ component extends="wheels.Testbox" {
type = "index",
table = variables.prefix & "roles"
);

switch( variables.dbAdapter ) {
case "Oracle":
case "SQLServer":
case "OracleModel":
case "MicrosoftSQLServerModel":
// If running in BoxLang, expect 1 instead of 2
if ( structKeyExists(server, "boxlang") ) {
expect( local.result.recordCount ).toBe( 1 );
Expand Down Expand Up @@ -209,7 +208,7 @@ component extends="wheels.Testbox" {
");
}

if(get('adapterName') eq 'SQLite') {
if(get('adapterName') eq 'SQLiteModel') {
cfquery(datasource=variables.datasource) {
writeOutput("
CREATE TABLE #variables.prefix#users (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ component extends="wheels.Testbox" {

it("tests same output", () => {
binaryData = FileReadBinary(ExpandPath('/wheels/tests_testbox/_assets/files/cfwheels-logo.png'));
if( application.wheels.adapterName eq 'SQLite' ){
if( application.wheels.adapterName eq 'SQLiteModel' ){
binaryData = toBase64(binaryData)
}
transaction action="begin" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ component extends="wheels.Testbox" {
describe("Tests changeColumn", () => {

it("is changing column", () => {
if(get("adapterName") eq 'SQLite') {
if(get("adapterName") eq 'SQLiteModel') {
skip("SQLite does not allow altering Columns.")
}
tableName = "dbm_changecolumn_tests"
Expand Down Expand Up @@ -915,7 +915,7 @@ component extends="wheels.Testbox" {
describe("Tests dropForeignKey", () => {

it("drops a foreign key constraint", () => {
if(get("adapterName") eq 'SQLite') {
if(get("adapterName") eq 'SQLiteModel') {
skip("SQLite does not allow altering CONSTRAINTS.")
}
tableName = "dbm_dfk_foos"
Expand Down
14 changes: 7 additions & 7 deletions core/src/wheels/tests_testbox/specs/model/crudSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ component extends="wheels.Testbox" {

beforeEach(() => {
binaryData = FileReadBinary(ExpandPath('/wheels/tests_testbox/_assets/files/cfwheels-logo.png'))
if( application.wheels.adapterName eq 'SQLite' ){
if( application.wheels.adapterName eq 'SQLiteModel' ){
binaryData = toBase64(binaryData)
}
})
Expand Down Expand Up @@ -287,7 +287,7 @@ component extends="wheels.Testbox" {
expect(photo.hasChanged('fileData')).toBeFalse()

binaryData = FileReadBinary(ExpandPath('/wheels/tests_testbox/_assets/files/cfwheels-logo.png'))
if( application.wheels.adapterName eq 'SQLite' ){
if( application.wheels.adapterName eq 'SQLiteModel' ){
binaryData = toBase64(binaryData)
}
photo.fileData = binaryData
Expand All @@ -304,7 +304,7 @@ component extends="wheels.Testbox" {
expect(photo.hasChanged('fileData')).toBeFalse()

binaryData = FileReadBinary(ExpandPath('/wheels/tests_testbox/_assets/files/cfwheels-logo.txt'))
if( application.wheels.adapterName eq 'SQLite' ){
if( application.wheels.adapterName eq 'SQLiteModel' ){
binaryData = toBase64(binaryData)
}
photo.fileData = binaryData
Expand Down Expand Up @@ -1206,20 +1206,20 @@ component extends="wheels.Testbox" {
actual = g.model("author").$indexHint(
useIndex = {author = "idx_authors_123"},
modelName = "author",
adapterName = "MySQL"
adapterName = "MySQLModel"
)

expect(actual).toBe("USE INDEX(idx_authors_123)")
})

it("is working with index hint mysql", () => {
actual = g.model("author").$fromClause(include = "", useIndex = {author = "idx_authors_123"}, adapterName = "MySQL")
actual = g.model("author").$fromClause(include = "", useIndex = {author = "idx_authors_123"}, adapterName = "MySQLModel")

expect(actual).toBe("FROM c_o_r_e_authors USE INDEX(idx_authors_123)")
})

it("is working with index hint sqlserver", () => {
actual = g.model("author").$fromClause(include = "", useIndex = {author = "idx_authors_123"}, adapterName = "SQLServer")
actual = g.model("author").$fromClause(include = "", useIndex = {author = "idx_authors_123"}, adapterName = "MicrosoftSQLServerModel")

expect(actual).toBe("FROM c_o_r_e_authors WITH (INDEX(idx_authors_123))")
})
Expand All @@ -1238,7 +1238,7 @@ component extends="wheels.Testbox" {
actual = g.model("author").$fromClause(
include = "posts",
useIndex = {author = "idx_authors_123", post = "idx_posts_123"},
adapterName = "MySQL"
adapterName = "MySQLModel"
)

expect(actual).toBe("FROM c_o_r_e_authors USE INDEX(idx_authors_123) LEFT OUTER JOIN c_o_r_e_posts USE INDEX(idx_posts_123) ON c_o_r_e_authors.id = c_o_r_e_posts.authorid AND c_o_r_e_posts.deletedat IS NULL")
Expand Down
6 changes: 3 additions & 3 deletions core/src/wheels/tests_testbox/specs/model/propertiesSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ component extends="wheels.Testbox" {
author = g.model("Author").findOne()
post = author.createPost(title = "test post", body = "here is some text")

if (get("adapterName") == "SQLite") {
if (get("adapterName") == "SQLiteModel") {
// Store as quoted ISO 8601 string (standard for SQLite)
if (IsDate(utctime)) {
utctime = "#DateFormat(utctime, 'yyyy-mm-dd')# #TimeFormat(utctime, 'HH:mm:ss')#";
Expand All @@ -521,7 +521,7 @@ component extends="wheels.Testbox" {
author = g.model("Author").findOne()
post = author.createPost(title = "test post", body = "here is some text")

if (get("adapterName") == "SQLite") {
if (get("adapterName") == "SQLiteModel") {
// Store as quoted ISO 8601 string (standard for SQLite)
if (IsDate(localtime)) {
localtime = "#DateFormat(localtime, 'yyyy-mm-dd')# #TimeFormat(localtime, 'HH:mm:ss')#";
Expand Down Expand Up @@ -637,7 +637,7 @@ component extends="wheels.Testbox" {
createdAt = CreateDate(1969, 4, 1),
updatedAt = CreateDate(1970, 4, 1)
)
if (get("adapterName") == "SQLite") {
if (get("adapterName") == "SQLiteModel") {
// Store as quoted ISO 8601 string (standard for SQLite)
if (IsDate(utctime)) {
utctime = "#DateFormat(utctime, 'yyyy-mm-dd')# #TimeFormat(utctime, 'HH:mm:ss')#";
Expand Down
Loading