Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/src/wheels/databaseAdapters/H2/H2Model.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,12 @@ component extends="wheels.databaseAdapters.Base" output=false {
return local.columns;
}

/**
* Define H2 reserved words.
*/
public string function $escapeReservedWords(required string word) {
// TODO
return arguments.word;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,16 @@ component extends="wheels.databaseAdapters.Base" output=false {
);
if (!ListFindNoCase(local.columnList, ListFirst(arguments.primaryKey))) {
local.rv = {};

// Use @@IDENTITY instead of SCOPE_IDENTITY() for BoxLang compatibility
// SCOPE_IDENTITY() returns empty values in BoxLang with SQL Server
query = $query(sql = "SELECT @@IDENTITY AS lastId", argumentCollection = arguments.queryAttributes);

// Fallback to SCOPE_IDENTITY() if @@IDENTITY fails (for other CFML engines)
if (!len(query.lastId)) {
query = $query(sql = "SELECT SCOPE_IDENTITY() AS lastId", argumentCollection = arguments.queryAttributes);
}

local.rv[$generatedKey()] = query.lastId;
return local.rv;
}
Expand All @@ -258,5 +258,12 @@ component extends="wheels.databaseAdapters.Base" output=false {
return "NEWID()";
}

/**
* Define MSSQL reserved words.
*/
public string function $escapeReservedWords(required string word) {
// TODO
return arguments.word;
}

}
274 changes: 274 additions & 0 deletions core/src/wheels/databaseAdapters/MySQL/MySQLModel.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,279 @@ component extends="wheels.databaseAdapters.Base" output=false {
return "() VALUES()";
}

/**
* Define MySQL reserved words.
*/
public string function $escapeReservedWords(required string word) {
local.reservedWords = {
"accessible" = true,
"add" = true,
"all" = true,
"alter" = true,
"analyze" = true,
"and" = true,
"as" = true,
"asc" = true,
"asensitive" = true,
"before" = true,
"between" = true,
"bigint" = true,
"binary" = true,
"blob" = true,
"both" = true,
"by" = true,
"call" = true,
"cascade" = true,
"case" = true,
"change" = true,
"char" = true,
"character" = true,
"check" = true,
"collate" = true,
"column" = true,
"condition" = true,
"constraint" = true,
"continue" = true,
"convert" = true,
"create" = true,
"cross" = true,
"cube" = true,
"cume_dist" = true,
"current_date" = true,
"current_time" = true,
"current_timestamp" = true,
"current_user" = true,
"cursor" = true,
"database" = true,
"databases" = true,
"day_hour" = true,
"day_microsecond" = true,
"day_minute" = true,
"day_second" = true,
"dec" = true,
"decimal" = true,
"declare" = true,
"default" = true,
"delayed" = true,
"delete" = true,
"dense_rank" = true,
"desc" = true,
"describe" = true,
"deterministic" = true,
"distinct" = true,
"distinctrow" = true,
"div" = true,
"double" = true,
"drop" = true,
"dual" = true,
"each" = true,
"else" = true,
"elseif" = true,
"empty" = true,
"enclosed" = true,
"escaped" = true,
"except" = true,
"exists" = true,
"exit" = true,
"explain" = true,
"false" = true,
"fetch" = true,
"first_value" = true,
"float" = true,
"float4" = true,
"float8" = true,
"for" = true,
"force" = true,
"foreign" = true,
"from" = true,
"fulltext" = true,
"function" = true,
"generated" = true,
"get" = true,
"grant" = true,
"group" = true,
"grouping" = true,
"groups" = true,
"having" = true,
"high_priority" = true,
"hour_microsecond" = true,
"hour_minute" = true,
"hour_second" = true,
"if" = true,
"ignore" = true,
"in" = true,
"index" = true,
"infile" = true,
"inner" = true,
"inout" = true,
"insensitive" = true,
"insert" = true,
"int" = true,
"int1" = true,
"int2" = true,
"int3" = true,
"int4" = true,
"int8" = true,
"integer" = true,
"interval" = true,
"into" = true,
"io_after_gtids" = true,
"io_before_gtids" = true,
"is" = true,
"iterate" = true,
"join" = true,
"json_table" = true,
"key" = true,
"keys" = true,
"kill" = true,
"lag" = true,
"last_value" = true,
"lead" = true,
"leading" = true,
"leave" = true,
"left" = true,
"like" = true,
"limit" = true,
"linear" = true,
"lines" = true,
"load" = true,
"localtime" = true,
"localtimestamp" = true,
"lock" = true,
"long" = true,
"longblob" = true,
"longtext" = true,
"loop" = true,
"low_priority" = true,
"master_bind" = true,
"master_ssl_verify_server_cert" = true,
"match" = true,
"maxvalue" = true,
"mediumblob" = true,
"mediumint" = true,
"mediumtext" = true,
"middleint" = true,
"minute_microsecond" = true,
"minute_second" = true,
"mod" = true,
"modifies" = true,
"natural" = true,
"not" = true,
"no_write_to_binlog" = true,
"nth_value" = true,
"ntile" = true,
"null" = true,
"numeric" = true,
"of" = true,
"on" = true,
"optimize" = true,
"optimizer_costs" = true,
"option" = true,
"optionally" = true,
"or" = true,
"order" = true,
"out" = true,
"outer" = true,
"outfile" = true,
"over" = true,
"partition" = true,
"percent_rank" = true,
"persist" = true,
"persist_only" = true,
"precision" = true,
"primary" = true,
"procedure" = true,
"purge" = true,
"range" = true,
"rank" = true,
"read" = true,
"reads" = true,
"read_write" = true,
"real" = true,
"recursive" = true,
"references" = true,
"regexp" = true,
"release" = true,
"rename" = true,
"repeat" = true,
"replace" = true,
"require" = true,
"resignal" = true,
"restrict" = true,
"return" = true,
"revoke" = true,
"right" = true,
"rlike" = true,
"row" = true,
"rows" = true,
"row_number" = true,
"schema" = true,
"schemas" = true,
"second_microsecond" = true,
"select" = true,
"sensitive" = true,
"separator" = true,
"set" = true,
"show" = true,
"signal" = true,
"smallint" = true,
"spatial" = true,
"specific" = true,
"sql" = true,
"sqlexception" = true,
"sqlstate" = true,
"sqlwarning" = true,
"sql_big_result" = true,
"sql_calc_found_rows" = true,
"sql_small_result" = true,
"ssl" = true,
"starting" = true,
"stored" = true,
"straight_join" = true,
"system" = true,
"table" = true,
"terminated" = true,
"then" = true,
"tinyblob" = true,
"tinyint" = true,
"tinytext" = true,
"to" = true,
"trailing" = true,
"trigger" = true,
"true" = true,
"undo" = true,
"union" = true,
"unique" = true,
"unlock" = true,
"unsigned" = true,
"update" = true,
"usage" = true,
"use" = true,
"using" = true,
"utc_date" = true,
"utc_time" = true,
"utc_timestamp" = true,
"values" = true,
"varbinary" = true,
"varchar" = true,
"varcharacter" = true,
"varying" = true,
"virtual" = true,
"when" = true,
"where" = true,
"while" = true,
"window" = true,
"with" = true,
"write" = true,
"xor" = true,
"year_month" = true,
"zerofill" = true
};

if (StructKeyExists(local.reservedWords, arguments.word)) {
return "`#local.rv#`";
}
return arguments.word;
}

}
7 changes: 7 additions & 0 deletions core/src/wheels/databaseAdapters/Oracle/OracleModel.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,12 @@ component extends="wheels.databaseAdapters.Base" output=false {
return arguments.table & " " & arguments.alias;
}

/**
* Define Oracle reserved words.
*/
public string function $escapeReservedWords(required string word) {
// TODO
return arguments.word;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,12 @@ component extends="wheels.databaseAdapters.Base" output=false {
return "random()";
}

/**
* Define Postgres reserved words.
*/
public string function $escapeReservedWords(required string word) {
// TODO
return arguments.word;
}

}
10 changes: 9 additions & 1 deletion core/src/wheels/databaseAdapters/SQLite/SQLiteModel.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ component extends="wheels.databaseAdapters.Base" output=false {
",,"
);
}

// If the primary key column wasn't part of the INSERT, we fetch last inserted ID
if (!ListFindNoCase(local.columnList, ListFirst(arguments.primaryKey))) {
local.rv = {};
Expand All @@ -126,4 +126,12 @@ component extends="wheels.databaseAdapters.Base" output=false {
return " DEFAULT VALUES";
}

/**
* Define SQLite reserved words.
*/
public string function $escapeReservedWords(required string word) {
// TODO
return arguments.word;
}

}
Loading
Loading