diff --git a/Migration.cfc b/Migration.cfc index 6f32b35..fb5ca8b 100644 --- a/Migration.cfc +++ b/Migration.cfc @@ -201,84 +201,56 @@ var loc = {}; - loc.columnNames = ""; - loc.columnValues = ""; + loc.values = {}; for (loc.key in arguments) { if(loc.key neq "table") { - loc.columnNames = ListAppend(loc.columnNames,this.adapter.quoteColumnName(loc.key)); - if(IsNumeric(arguments[loc.key])) { - loc.columnValues = ListAppend(loc.columnValues,arguments[loc.key]); - } else if(IsBoolean(arguments[loc.key])) { - loc.columnValues = ListAppend(loc.columnValues,IIf(arguments[loc.key],1,0)); - } else if(IsDate(arguments[loc.key])) { - loc.columnValues = ListAppend(loc.columnValues,"#arguments[loc.key]#"); - } else { - loc.columnValues = ListAppend(loc.columnValues,"'#ReplaceNoCase(arguments[loc.key],"'","''","all")#'"); - } + loc.values[ loc.key ] = arguments[ loc.key ]; } } - if(loc.columnNames != '') { - if(ListContainsNoCase(loc.columnnames, "[id]")) { - $execute(this.adapter.addRecordPrefix(arguments.table)); - } - $execute("INSERT INTO #this.adapter.quoteTableName(LCase(arguments.table))# ( #loc.columnNames# ) VALUES ( #loc.columnValues# )"); - if(ListContainsNoCase(loc.columnnames, "[id]")) { - $execute(this.adapter.addRecordSuffix(arguments.table)); - } + if( NOT structIsEmpty( loc.values ) ) { + $execute( this.adapter.addRecord( arguments.table, loc.values ) ); announce("Added record to table #arguments.table#"); } + var loc = {}; - loc.columnUpdates = ""; + loc.values = {}; for (loc.key in arguments) { - if(loc.key neq "table" && loc.key neq "where") { - loc.update = "#this.adapter.quoteColumnName(loc.key)# = "; - if(IsNumeric(arguments[loc.key])) { - loc.update = loc.update & "#arguments[loc.key]#"; - } else if(IsBoolean(arguments[loc.key])) { - loc.update = loc.update & "#IIf(arguments[loc.key],1,0)#"; - } else if(IsDate(arguments[loc.key])) { - loc.update = loc.update & "#arguments[loc.key]#"; - } else { - arguments[loc.key] = ReplaceNoCase(arguments[loc.key], "'", "''", "all"); - loc.update = loc.update & "'#arguments[loc.key]#'"; - } - loc.columnUpdates = ListAppend(loc.columnUpdates,loc.update); + if(loc.key neq "table" AND loc.key neq "where") { + loc.values[ loc.key ] = arguments[ loc.key ]; } } - if(loc.columnUpdates != '') { - loc.sql = 'UPDATE #this.adapter.quoteTableName(LCase(arguments.table))# SET #loc.columnUpdates#'; + if( NOT structIsEmpty( loc.values ) ) { + $execute( this.adapter.updateRecord( arguments.table, arguments.where, loc.values ) ); loc.message = 'Updated record(s) in table #arguments.table#'; if(arguments.where != '') { - loc.sql = loc.sql & ' WHERE #arguments.where#'; loc.message = loc.message & ' where #arguments.where#'; } - $execute(loc.sql); announce(loc.message); } + var loc = {}; - loc.sql = 'DELETE FROM #this.adapter.quoteTableName(LCase(arguments.table))#'; + $execute( this.adapter.removeRecord( arguments.table, arguments.where ) ); loc.message = 'Removed record(s) from table #arguments.table#'; if(arguments.where != '') { - loc.sql = loc.sql & ' WHERE #arguments.where#'; loc.message = loc.message & ' where #arguments.where#'; } - $execute(loc.sql); announce(loc.message); - \ No newline at end of file + + diff --git a/TableDefinition.cfc b/TableDefinition.cfc index 93255f4..a5923d3 100755 --- a/TableDefinition.cfc +++ b/TableDefinition.cfc @@ -34,7 +34,7 @@ - + @@ -68,28 +68,28 @@ - - + + + var loc = {}; arguments.adapter = this.adapter; arguments.name = arguments.columnName; arguments.type = arguments.columnType; - loc.column = CreateObject("component","ColumnDefinition").init(argumentCollection=arguments); + loc.column = createObject("component","ColumnDefinition").init(argumentCollection=arguments); ArrayAppend(this.columns,loc.column); - + - var loc = {}; - arguments.columnType = "biginteger"; + arguments.columnType = "binary"; loc.iEnd = ListLen(arguments.columnNames); for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { arguments.columnName = ListGetAt(arguments.columnNames,loc.i); @@ -99,13 +99,13 @@ - + var loc = {}; - arguments.columnType = "binary"; + arguments.columnType = "boolean"; loc.iEnd = ListLen(arguments.columnNames); for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { arguments.columnName = ListGetAt(arguments.columnNames,loc.i); @@ -115,13 +115,13 @@ - + var loc = {}; - arguments.columnType = "boolean"; + arguments.columnType = "date"; loc.iEnd = ListLen(arguments.columnNames); for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { arguments.columnName = ListGetAt(arguments.columnNames,loc.i); @@ -131,13 +131,14 @@ - + + var loc = {}; - arguments.columnType = "date"; + arguments.columnType = "datetime"; loc.iEnd = ListLen(arguments.columnNames); for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { arguments.columnName = ListGetAt(arguments.columnNames,loc.i); @@ -146,14 +147,16 @@ - - + + + + var loc = {}; - arguments.columnType = "datetime"; + arguments.columnType = "decimal"; loc.iEnd = ListLen(arguments.columnNames); for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { arguments.columnName = ListGetAt(arguments.columnNames,loc.i); @@ -163,15 +166,15 @@ - + - + var loc = {}; - arguments.columnType = "decimal"; + arguments.columnType = "money"; loc.iEnd = ListLen(arguments.columnNames); for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { arguments.columnName = ListGetAt(arguments.columnNames,loc.i); @@ -199,7 +202,7 @@ - + @@ -214,11 +217,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + var loc = {}; arguments.columnType = "string"; @@ -231,10 +271,29 @@ + + + + + + + + var loc = {}; + arguments.columnType = "char"; + loc.iEnd = ListLen(arguments.columnNames); + for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { + arguments.columnName = ListGetAt(arguments.columnNames,loc.i); + column(argumentCollection=arguments); + } + + + + + var loc = {}; arguments.columnType = "text"; diff --git a/adapters/Abstract.cfc b/adapters/Abstract.cfc index 5b95ae1..506ae30 100755 --- a/adapters/Abstract.cfc +++ b/adapters/Abstract.cfc @@ -132,7 +132,7 @@ var loc = {}; - loc.sql = "CREATE TABLE #quoteTableName(LCase(arguments.name))# (#chr(13)##chr(10)#"; + loc.sql = "CREATE TABLE #quoteTableName(arguments.name)# (#chr(13)##chr(10)#"; loc.iEnd = ArrayLen(arguments.primaryKeys); @@ -180,44 +180,44 @@ - + - + - + - + - + - + - + @@ -230,7 +230,7 @@ - var loc = { sql = "CONSTRAINT #quoteTableName(arguments.name)# FOREIGN KEY (#quoteColumnName(arguments.column)#) REFERENCES #LCase(arguments.referenceTable)#(#quoteColumnName(arguments.referenceColumn)#)" }; + var loc = { sql = "CONSTRAINT #quoteTableName(arguments.name)# FOREIGN KEY (#quoteColumnName(arguments.column)#) REFERENCES #quoteTableName(arguments.referenceTable)#(#quoteColumnName(arguments.referenceColumn)#)" }; for (loc.item in listToArray("onUpdate,onDelete")) { if (len(arguments[loc.item])) @@ -280,13 +280,105 @@ + + + + + + var loc = {}; + loc.columnNames = $getColumns( arguments.table ); + // pre-fill createdAt column + if( NOT structKeyExists( arguments.values, "createdAt" ) AND listFindNoCase( loc.columnNames, "createdAt" ) ) { + arguments.values.createdAt = now(); + } + // pre-fill updatedAt column + if( NOT structKeyExists( arguments.values, "updatedAt" ) AND listFindNoCase( loc.columnNames, "updatedAt" ) ) { + arguments.values.updatedAt = now(); + } + + loc.sql = ""; + loc.columnNames = ""; + loc.columnValues = ""; + for (loc.key in arguments.values) { + loc.columnNames = ListAppend(loc.columnNames,quoteColumnName(loc.key)); + if(arguments.values[loc.key] IS "NULL") { + loc.columnValues = ListAppend(loc.columnValues,arguments.values[loc.key]); + } else if(IsNumeric(arguments.values[loc.key])) { + loc.columnValues = ListAppend(loc.columnValues,arguments.values[loc.key]); + } else if(IsBoolean(arguments.values[loc.key])) { + loc.columnValues = ListAppend(loc.columnValues,IIf(arguments.values[loc.key],1,0)); + } else if(IsDate(arguments.values[loc.key])) { + loc.columnValues = ListAppend(loc.columnValues,arguments.values[loc.key]); + } else { + loc.columnValues = ListAppend(loc.columnValues,"'#ReplaceNoCase(arguments.values[loc.key],"'","''","all")#'"); + } + } + loc.sql = "INSERT INTO #quoteTableName(arguments.table)# ( #loc.columnNames# ) VALUES ( #loc.columnValues# )"; + + + + - - + + + + + + + var loc = {}; + loc.columnNames = $getColumns( arguments.table ); + // pre-fill updatedAt column + if( NOT structKeyExists( arguments.values, "updatedAt" ) AND listFindNoCase( loc.columnNames, "updatedAt" ) ) { + arguments.values.updatedAt = now(); + } + + loc.columnUpdates = ""; + for (loc.key in arguments.values) { + loc.update = "#quoteColumnName(loc.key)# = "; + if(arguments.values[loc.key] IS "NULL") { + loc.update = loc.update & arguments.values[loc.key]; + } else if(IsNumeric(arguments.values[loc.key])) { + loc.update = loc.update & "#arguments.values[loc.key]#"; + } else if(IsBoolean(arguments.values[loc.key])) { + loc.update = loc.update & "#IIf(arguments.values[loc.key],1,0)#"; + } else if(IsDate(arguments.values[loc.key])) { + loc.update = loc.update & "#arguments.values[loc.key]#"; + } else { + arguments.values[loc.key] = ReplaceNoCase(arguments.values[loc.key], "'", "''", "all"); + loc.update = loc.update & "'#arguments.values[loc.key]#'"; + } + loc.columnUpdates = ListAppend(loc.columnUpdates,loc.update); + } + if(loc.columnUpdates != '') { + loc.sql = 'UPDATE #quoteTableName(arguments.table)# SET #loc.columnUpdates#'; + if(arguments.where != '') { + loc.sql = loc.sql & ' WHERE #arguments.where#'; + } + $execute(loc.sql); + } + - - + + + + + + var loc = {}; + loc.columnNames = $getColumns( arguments.table ); + // pre-fill deleteAt column for a "soft-delete" + if( listFindNoCase( loc.columnNames, "deletedAt" ) ) { + loc.values = {}; + loc.values.deletedAt = now(); + updateRecord( arguments.table, arguments.where, loc.values ); + } else { + loc.sql = 'DELETE FROM #quoteTableName(arguments.table)#'; + if(arguments.where != '') { + loc.sql = loc.sql & ' WHERE #arguments.where#'; + } + $execute(loc.sql); + } + \ No newline at end of file diff --git a/adapters/MicrosoftSQLServer.cfc b/adapters/MicrosoftSQLServer.cfc old mode 100755 new mode 100644 index 3bc8d16..440630f --- a/adapters/MicrosoftSQLServer.cfc +++ b/adapters/MicrosoftSQLServer.cfc @@ -4,15 +4,17 @@ - + + + @@ -40,17 +42,17 @@ var loc = {}; - - loc.sql = "CONSTRAINT [PK_#arguments.name#] PRIMARY KEY CLUSTERED ("; - - for (loc.i = 1; loc.i lte ArrayLen(arguments.primaryKeys); loc.i++) - { - if (loc.i != 1) - loc.sql = loc.sql & ", "; - loc.sql = loc.sql & arguments.primaryKeys[loc.i].toColumnNameSQL() & " ASC"; - } - - loc.sql = loc.sql & ")"; + + loc.sql = "CONSTRAINT [PK_#arguments.name#] PRIMARY KEY CLUSTERED ("; + + for (loc.i = 1; loc.i lte ArrayLen(arguments.primaryKeys); loc.i++) + { + if (loc.i != 1) + loc.sql = loc.sql & ", "; + loc.sql = loc.sql & arguments.primaryKeys[loc.i].toColumnNameSQL() & " ASC"; + } + + loc.sql = loc.sql & ")"; @@ -58,7 +60,7 @@ - + @@ -76,26 +78,26 @@ - + - + - + - + @@ -104,7 +106,7 @@ - + @@ -112,7 +114,7 @@ - + @@ -142,7 +144,7 @@ - + @@ -152,7 +154,7 @@ - EXEC sp_helpconstraint #quoteTableName(LCase(arguments.name))#, 'nomsg' + EXEC sp_helpconstraint #quoteTableName(arguments.name)#, 'nomsg' @@ -165,7 +167,7 @@ - + @@ -205,52 +207,91 @@ - var sql = ''; - if(IsDefined("variables.sqlTypes") && structKeyExists(variables.sqlTypes,arguments.type)) { - if(IsStruct(variables.sqlTypes[arguments.type])) { - sql = variables.sqlTypes[arguments.type]['name']; - if(arguments.type == 'decimal') { - if(!StructKeyExists(arguments.options,'precision') && StructKeyExists(variables.sqlTypes[arguments.type],'precision')) { - arguments.options.precision = variables.sqlTypes[arguments.type]['precision']; - } - if(!StructKeyExists(arguments.options,'scale') && StructKeyExists(variables.sqlTypes[arguments.type],'scale')) { - arguments.options.scale = variables.sqlTypes[arguments.type]['scale']; - } - if(StructKeyExists(arguments.options,'precision')) { - if(StructKeyExists(arguments.options,'scale')) { - sql = sql & '(#arguments.options.precision#,#arguments.options.scale#)'; - } else { - sql = sql & '(#arguments.options.precision#)'; - } - } - } else if(arguments.type == 'integer') { - if(StructKeyExists(arguments.options,'limit')) { - sql = sql; - } - } else { - if(!StructKeyExists(arguments.options,'limit') && StructKeyExists(variables.sqlTypes[arguments.type],'limit')) { - arguments.options.limit = variables.sqlTypes[arguments.type]['limit']; - } - if(StructKeyExists(arguments.options,'limit')) { - sql = sql & '(#arguments.options.limit#)'; + var sql = super.typeToSQL( argumentCollection = arguments ); + if(arguments.type IS 'DATETIME' AND StructKeyExists(arguments.options,'limit') AND arguments.options.limit IS 'SMALL') { + sql = 'SMALLDATETIME'; + } else if(arguments.type IS 'DATETIME' AND StructKeyExists(arguments.options,'limit') AND isNumeric( arguments.options.limit )) { + sql = 'DATETIME2(#arguments.options.limit#)'; + } else if(arguments.type IS 'MONEY' AND StructKeyExists(arguments.options,'limit') AND arguments.options.limit IS 'SMALL') { + sql = 'SMALLMONEY'; + } else if(arguments.type IS 'INTEGER' AND StructKeyExists(arguments.options,'limit') AND arguments.options.limit IS 'BIG') { + sql = 'BIGINT'; + } else if(arguments.type IS 'INTEGER' AND StructKeyExists(arguments.options,'limit') AND arguments.options.limit IS 'SMALL') { + sql = 'SMALLINT'; + } else if(arguments.type IS 'INTEGER' AND StructKeyExists(arguments.options,'limit') AND arguments.options.limit IS 'TINY') { + sql = 'TINYINT'; + } else if(arguments.type IS 'INTEGER' ) { + sql = 'INT'; + } else if(listFindNoCase('CHAR,STRING,TEXT', arguments.type) AND structKeyExists(arguments.options,'encoding') AND listFindNoCase( "utf8,unicode", arguments.options.encoding ) ) { + sql = 'N' & sql; // for NCHAR, NVARCHAR, NTEXT + } + + + + + + + + + if(StructKeyExists(arguments.options,'type') && arguments.options.type != 'primaryKey') { + if(StructKeyExists(arguments.options,'default') && optionsIncludeDefault(argumentCollection=arguments.options)) { + if(arguments.options.default eq "NULL" || (arguments.options.default eq "" && ListFindNoCase("boolean,date,datetime,time,timestamp,decimal,float,integer",arguments.options.type))) { + arguments.sql = arguments.sql & " DEFAULT NULL"; + } else if( find( "(", arguments.options.default ) AND find( ")", arguments.options.default ) ) { // SQL Functions + arguments.sql = arguments.sql & " DEFAULT #arguments.options.default#"; + } else if(arguments.options.type == 'boolean') { + arguments.sql = arguments.sql & " DEFAULT #IIf(arguments.options.default,1,0)#"; + } else if(arguments.options.type == 'string' && arguments.options.default eq "") { + arguments.sql = arguments.sql & " DEFAULT ''"; + } else { + arguments.sql = arguments.sql & " DEFAULT #quote(value=arguments.options.default,options=arguments.options)#"; } } - } else { - sql = variables.sqlTypes[arguments.type]; + if(StructKeyExists(arguments.options,'null') && !arguments.options.null) { + arguments.sql = arguments.sql & " NOT NULL"; + } + } + + + + + + + + + loc = {}; + loc.columns = $dbinfo(type="columns",table=arguments.tableName,datasource=application.wheels.dataSourceName,username=application.wheels.dataSourceUserName,password=application.wheels.dataSourcePassword); + loc.identityCol = ""; + loc.iEnd = loc.columns.RecordCount; + for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { + if( listFindNoCase( loc.columns["TYPE_NAME"][loc.i], "identity", " " ) ) { + loc.identityCol = listAppend( loc.identityCol, loc.columns["COLUMN_NAME"][loc.i] ); + break; } } - + - - - - - + - + + + var loc = {}; + loc.sql = super.addRecord( arguments.table, arguments.values ); + loc.identityCol= $getIdentityColumn( arguments.table ); + + // if trying to insert into an identity column wrap it with IDENTITY_INSERT ON/OFF + if( len( loc.identityCol ) AND listFindNoCase( structKeyList( arguments.values ), loc.identityCol ) ) { + loc.sql = "SET IDENTITY_INSERT #quoteTableName(arguments.table)# ON;" & chr(10) + & loc.sql & ";" & chr(10) + & "SET IDENTITY_INSERT #quoteTableName(arguments.table)# OFF;" & chr(10); + } + + - \ No newline at end of file + + + diff --git a/adapters/MySQL.cfc b/adapters/MySQL.cfc index 50f7015..5c66139 100755 --- a/adapters/MySQL.cfc +++ b/adapters/MySQL.cfc @@ -1,19 +1,20 @@ - - + + + @@ -36,10 +37,10 @@ - + - + @@ -64,7 +65,7 @@ - + @@ -74,4 +75,41 @@ + + + + + var sql = super.typeToSQL( argumentCollection = arguments ); + if(arguments.type == 'INTEGER' AND StructKeyExists(arguments.options,'limit') ) { + if(arguments.options.limit IS 'BIG') { + sql = 'BIGINT'; + } else if(arguments.options.limit IS 'BIG UNSIGNED') { + sql = 'BIGINT UNSIGNED'; + } else if(arguments.options.limit IS 'UNSIGNED') { + sql = 'INT UNSIGNED'; + } else if(arguments.options.limit IS 'MEDIUM UNSIGNED') { + sql = 'MEDIUMINT UNSIGNED'; + } else if(arguments.options.limit IS 'MEDIUM') { + sql = 'MEDIUMINT'; + } else if(arguments.options.limit IS 'SMALL UNSIGNED') { + sql = 'SMALLINT UNSIGNED'; + } else if(arguments.options.limit IS 'SMALL') { + sql = 'SMALLINT'; + } else if(arguments.options.limit IS 'TINY UNSIGNED') { + sql = 'TINYINT UNSIGNED'; + } else if(arguments.options.limit IS 'TINY') { + sql = 'TINYINT'; + } else if(isNumeric(arguments.options.limit)){ + sql = 'INT(#arguments.options.limit#)'; + } + } else if(listFindNoCase( 'CHAR,STRING,TEXT', arguments.type ) AND structKeyExists(arguments.options,'encoding') AND len( arguments.options.encoding ) ) { + if( arguments.options.encoding IS "unicode" ) { + arguments.options.encoding = "utf8"; + } + sql = sql & ' CHARACTER SET #arguments.options.encoding#';, + } + + + + \ No newline at end of file diff --git a/adapters/Oracle.cfc b/adapters/Oracle.cfc index 63ab2bd..3e9f3e7 100755 --- a/adapters/Oracle.cfc +++ b/adapters/Oracle.cfc @@ -13,14 +13,24 @@ + + + + + + + + + + @@ -99,19 +109,19 @@ announce("Dropped sequence #arguments.name#_seq"); - + - + - + @@ -123,7 +133,7 @@ - + diff --git a/adapters/PostgreSQL.cfc b/adapters/PostgreSQL.cfc index b47707e..9ed5d30 100755 --- a/adapters/PostgreSQL.cfc +++ b/adapters/PostgreSQL.cfc @@ -9,9 +9,11 @@ + + @@ -29,7 +31,14 @@ - + + + + + + + + @@ -60,7 +69,7 @@ - + diff --git a/adapters/SQLite.cfc b/adapters/SQLite.cfc index 290bcb5..9c2989b 100755 --- a/adapters/SQLite.cfc +++ b/adapters/SQLite.cfc @@ -9,9 +9,11 @@ + + diff --git a/basefunctions.cfm b/basefunctions.cfm index 91d88e3..737db10 100755 --- a/basefunctions.cfm +++ b/basefunctions.cfm @@ -75,10 +75,9 @@ - - - + loc = {}; + loc.columns = $dbinfo(type="columns",pattern=argumengs.columnName,table=arguments.tableName,datasource=application.wheels.dataSourceName,username=application.wheels.dataSourceUserName,password=application.wheels.dataSourcePassword); loc.columnDefinition = ""; loc.iEnd = loc.columns.RecordCount; for (loc.i=1; loc.i <= loc.iEnd; loc.i++) { @@ -107,4 +106,4 @@ } - + \ No newline at end of file diff --git a/dbmigrate.cfc b/dbmigrate.cfc index a341c5d..d2c3803 100644 --- a/dbmigrate.cfc +++ b/dbmigrate.cfc @@ -100,7 +100,7 @@ - + @@ -109,8 +109,8 @@ - - + + @@ -121,6 +121,7 @@ + @@ -149,10 +150,18 @@ var loc = {}; - arguments.returnVariable = "loc.returnValue"; - arguments.component = arguments.path & "." & arguments.fileName; - StructDelete(arguments, "path"); - StructDelete(arguments, "fileName"); + loc.returnValue = ""; + if( listFind( "1.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.1,1.1.3,1.1.4,1.1.5,1.1.6,1.1.7,1.1.8", application.wheels.version ) ) { + arguments.returnVariable = "loc.returnValue"; + arguments.component = arguments.path & "." & arguments.fileName; + StructDelete(arguments, "path"); + StructDelete(arguments, "fileName"); + } else { // 1.1.9 fix + loc.returnVariable = "loc.returnValue"; + loc.method = arguments.method; + loc.component = ListChangeDelims(arguments.path, ".", "/") & "." & ListChangeDelims(arguments.fileName, ".", "/"); + loc.argumentCollection = arguments; + } @@ -162,6 +171,8 @@ + + @@ -181,6 +192,7 @@ + diff --git a/index.cfm b/index.cfm index f6b3282..91d5c72 100644 --- a/index.cfm +++ b/index.cfm @@ -1,7 +1,7 @@ - + @@ -11,7 +11,8 @@ - + + @@ -113,12 +114,16 @@ -
+
+ + +
+
-
+
diff --git a/templates/change-column.cfc b/templates/change-column.cfc index a7e7692..d304d69 100644 --- a/templates/change-column.cfc +++ b/templates/change-column.cfc @@ -20,12 +20,12 @@ - changeColumn(table='tableName', columnType='', columnName='columnName', default='', null=true); + changeColumn(table='[tableName]', columnType='', columnName='columnName', default='', null=true); - changeColumn(table='tableName',columnName='columnName'); + changeColumn(table='[tableName]',columnName='columnName'); \ No newline at end of file diff --git a/templates/change-table.cfc b/templates/change-table.cfc index 481a55c..411577a 100644 --- a/templates/change-table.cfc +++ b/templates/change-table.cfc @@ -13,14 +13,14 @@ - t = changeTable('tableName'); + t = changeTable('[tableName]'); t.change(); - removeColumn(table='tableName',columnName='columnName'); + removeColumn(table='[tableName]',columnName='columnName'); \ No newline at end of file diff --git a/templates/create-column.cfc b/templates/create-column.cfc index 06cb614..0a4168a 100644 --- a/templates/create-column.cfc +++ b/templates/create-column.cfc @@ -19,12 +19,12 @@ - addColumn(table='tableName', columnType='', columnName='columnName', default='', null=true); + addColumn(table='[tableName]', columnType='', columnName='columnName', default='', null=true); - removeColumn(table='tableName',columnName='columnName'); + removeColumn(table='[tableName]',columnName='columnName'); \ No newline at end of file diff --git a/templates/create-index.cfc b/templates/create-index.cfc index 8ce0f92..116da38 100644 --- a/templates/create-index.cfc +++ b/templates/create-index.cfc @@ -14,12 +14,12 @@ - addIndex(table='tableName',columnNames='columnName',unique=true); + addIndex(table='[tableName]',columnNames='columnName',unique=true); - removeIndex(table='tableName', indexName=''); + removeIndex(table='[tableName]', indexName=''); \ No newline at end of file diff --git a/templates/create-record.cfc b/templates/create-record.cfc index 4486592..eee63f2 100644 --- a/templates/create-record.cfc +++ b/templates/create-record.cfc @@ -12,12 +12,12 @@ - addRecord(table='tableName',field=''); + addRecord(table='[tableName]',field=''); - removeRecord(table='tableName',where=''); + removeRecord(table='[tableName]',where=''); \ No newline at end of file diff --git a/templates/create-table.cfc b/templates/create-table.cfc index d0e9c15..6af1238 100644 --- a/templates/create-table.cfc +++ b/templates/create-table.cfc @@ -21,7 +21,7 @@ - t = createTable(name='tableName'); + t = createTable(name='[tableName]'); t.timestamps(); t.create(); @@ -29,7 +29,7 @@ - dropTable('tableName'); + dropTable('[tableName]'); \ No newline at end of file diff --git a/templates/remove-column.cfc b/templates/remove-column.cfc index 1f665a4..bd494f0 100644 --- a/templates/remove-column.cfc +++ b/templates/remove-column.cfc @@ -13,12 +13,12 @@ - removeColumn(table='tableName',columnName='columnName'); + removeColumn(table='[tableName]',columnName='columnName'); - addColumn(table='tableName', columnType='', columnName='columnName', default='', null=true); + addColumn(table='[tableName]', columnType='', columnName='columnName', default='', null=true); \ No newline at end of file diff --git a/templates/remove-index.cfc b/templates/remove-index.cfc index 6915fb2..6557ed1 100644 --- a/templates/remove-index.cfc +++ b/templates/remove-index.cfc @@ -12,12 +12,12 @@ - removeIndex(table='tableName', indexName=''); + removeIndex(table='[tableName]', indexName=''); - addIndex(table='tableName',columnNames='columnName',unique=true); + addIndex(table='[tableName]',columnNames='columnName',unique=true); \ No newline at end of file diff --git a/templates/remove-record.cfc b/templates/remove-record.cfc index f00659c..57c882c 100644 --- a/templates/remove-record.cfc +++ b/templates/remove-record.cfc @@ -12,12 +12,12 @@ - removeRecord(table='tableName',where=''); + removeRecord(table='[tableName]',where=''); - addRecord(table='tableName',field=''); + addRecord(table='[tableName]',field=''); \ No newline at end of file diff --git a/templates/remove-table.cfc b/templates/remove-table.cfc index 484ef2a..76660bb 100644 --- a/templates/remove-table.cfc +++ b/templates/remove-table.cfc @@ -11,12 +11,12 @@ - dropTable(name='tableName'); + dropTable(name='[tableName]'); - t = createTable(name='tableName'); + t = createTable(name='[tableName]'); t.timestamps(); t.create(); diff --git a/templates/rename-column.cfc b/templates/rename-column.cfc index 4a105fa..e9f5185 100644 --- a/templates/rename-column.cfc +++ b/templates/rename-column.cfc @@ -13,12 +13,12 @@ - renameColumn(table='tableName', columnName='columnName', newColumnName='newColumnName'); + renameColumn(table='[tableName]', columnName='columnName', newColumnName='newColumnName'); - renameColumn(table='tableName', columnName='columnName', newColumnName='newColumnName'); + renameColumn(table='[tableName]', columnName='columnName', newColumnName='newColumnName'); \ No newline at end of file diff --git a/templates/update-record.cfc b/templates/update-record.cfc index 6b2eee2..07405d0 100644 --- a/templates/update-record.cfc +++ b/templates/update-record.cfc @@ -13,12 +13,12 @@ - updateRecord(table='tableName',where=''); + updateRecord(table='[tableName]',where=''); - updateRecord(table='tableName',where=''); + updateRecord(table='[tableName]',where=''); \ No newline at end of file diff --git a/tests/20130328131405_identity_insert.cfc b/tests/20130328131405_identity_insert.cfc new file mode 100644 index 0000000..7738a47 --- /dev/null +++ b/tests/20130328131405_identity_insert.cfc @@ -0,0 +1,15 @@ + + + + t = createTable(name='ident_insert',id=false); + t.primaryKey(name="pk",type="integer",autoIncrement=true); + t.change(true); + addRecord(table='ident_insert',pk='10'); + + + + + dropTable(name='ident_insert'); + + + diff --git a/tests/20130328140935_new_mssql_types.cfc b/tests/20130328140935_new_mssql_types.cfc new file mode 100644 index 0000000..99ab881 --- /dev/null +++ b/tests/20130328140935_new_mssql_types.cfc @@ -0,0 +1,23 @@ + + + + t = createTable(name='mssql_types'); + t.tinyInteger("test_tinyint"); + t.smallInteger("test_smallint"); + t.integer("test_int"); + t.bigInteger("test_bigint"); + t.date(columnNames="test_date"); + t.datetime(columnNames="test_datetime"); + t.datetime(columnNames="test_smalldatetime",limit="small"); + t.money(columnNames="test_money"); + t.money(columnNames="test_smallmoney",limit="small"); + t.create(); + addRecord(table='mssql_types',test_tinyint=1,test_int=2,test_bigint=3,test_date=now(),test_datetime=now(),test_smalldatetime=now(),test_money=4.56,test_smallmoney=7.89 ); + + + + + dropTable(name='mssql_types'); + + + diff --git a/tests/20130328140940_new_mysql_types.cfc b/tests/20130328140940_new_mysql_types.cfc new file mode 100644 index 0000000..9cbbffc --- /dev/null +++ b/tests/20130328140940_new_mysql_types.cfc @@ -0,0 +1,37 @@ + + + + t = createTable(name='mysql_types'); + t.tinyInteger("test_tinyint1"); + t.tinyInteger("test_tinyint2", "unsigned"); + t.integer("test_tinyint3", "tiny unsigned"); + t.smallInteger("test_smallint1"); + t.smallInteger("test_smallint2", "unsigned"); + t.integer("test_smallint3", "small unsigned"); + t.mediumInteger("test_mediumint1"); + t.mediumInteger("test_mediumint2", "unsigned"); + t.integer("test_mediumint3", "medium unsigned"); + t.integer("test_int1"); + t.integer("test_int2", "unsigned"); + t.integer("test_int3", "int"); + t.integer("test_int4", "int unsigned"); + t.bigInteger("test_bigint1"); + t.bigInteger("test_bigint2", "unsigned"); + t.integer("test_bigint3", "big unsigned"); + t.create(); + addRecord(table='mysql_types' + ,test_tinyint1=1,test_tinyint2=2,test_tinyint3=3 + ,test_smallint1=1,test_smallint2=2,test_smallint3=3 + ,test_mediumint1=1,test_mediumint2=2,test_mediumint3=3 + ,test_int1=1,test_int2=2,test_int2=2,test_int3=3,test_int4=4 + ,test_bigint1=1,test_bigint2=2,test_bigint3=3 + + ); + + + + + dropTable(name='mysql_types'); + + + diff --git a/tests/20130401140940_new_strings.cfc b/tests/20130401140940_new_strings.cfc new file mode 100644 index 0000000..8613633 --- /dev/null +++ b/tests/20130401140940_new_strings.cfc @@ -0,0 +1,28 @@ + + + + t = createTable(name='string_types'); + t.char("char_none"); + t.char(columnNames="char_ascii",encoding="ascii"); + t.char(columnNames="char_unicode",encoding="unicode"); + t.column(columnName="char_column",columnType="string",encoding="utf8"); + + t.string("varchar_none"); + t.string(columnNames="varchar_ascii",encoding="ascii"); + t.string(columnNames="varchar_unicode",encoding="unicode"); + t.column(columnName="varchar_column",columnType="string",encoding="utf8"); + + t.text("text_none"); + t.text(columnNames="text_ascii",encoding="ascii"); + t.text(columnNames="text_unicode",encoding="unicode"); + t.column(columnName="text_column",columnType="string",encoding="utf8"); + + t.create(); + + + + + dropTable(name='string_types'); + + + diff --git a/tests/20130402140940_mysql_bit.cfc b/tests/20130402140940_mysql_bit.cfc new file mode 100644 index 0000000..e8d7ba5 --- /dev/null +++ b/tests/20130402140940_mysql_bit.cfc @@ -0,0 +1,17 @@ + + + + t = createTable(name='mysql_bit'); + t.boolean("foo"); + t.create(); + + addRecord(table='mysql_bit',foo=true); + addRecord(table='mysql_bit',foo=false); + + + + + dropTable(name='mysql_bit'); + + + diff --git a/tests/20130402141040_test_timestamps.cfc b/tests/20130402141040_test_timestamps.cfc new file mode 100644 index 0000000..e19928c --- /dev/null +++ b/tests/20130402141040_test_timestamps.cfc @@ -0,0 +1,19 @@ + + + + t = createTable(name='test_timestamps'); + t.string("label"); + t.timestamps(); + t.create(); + + addRecord(table='test_timestamps',label="Foo"); + addRecord(table='test_timestamps',label="Bar"); + updateRecord(table='test_timestamps',where="label='Bar'",label="Bar2"); + + + + + dropTable(name='test_timestamps'); + + + diff --git a/tests/20130402141043_test_insert_update_null_values.cfc b/tests/20130402141043_test_insert_update_null_values.cfc new file mode 100644 index 0000000..bb6ba6a --- /dev/null +++ b/tests/20130402141043_test_insert_update_null_values.cfc @@ -0,0 +1,19 @@ + + + + t = createTable(name='test_null'); + t.string("label",50,"",false,"unicode"); + t.string("email",50,"null",true,"unicode"); + t.create(); + + addRecord(table="test_null",label="Foo",email="foo@foo.com"); + addRecord(table="test_null",label="Bar"); + addRecord(table="test_null",label="Snork",email="NULL"); + + + + + dropTable('test_null'); + + +