Skip to content

Commit

Permalink
#337 fixed default values SQL on Oracle and PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
x993693 authored and x993693 committed Aug 19, 2014
1 parent 4194552 commit 5a3ee4b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions wheels/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Bug Fixes
* Fixed bug with static caching on Adobe ColdFusion 9 - #332 [Charley Contreras]
* Allow for format auto-detection when HTTP ACCEPT contains multiple values - #297 [Raul Riera, Singgih Cahyono]
* Fixed so that sendEmail() can use the "remove" attribute to delete attachments - #339 [Simon Allard]
* Fixed default values SQL on Oracle and PostgreSQL - #337 [Singgih Cahyono]

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion wheels/model/adapters/Oracle.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<cfcomponent extends="Base" output="false">

<cffunction name="$defaultValues" returntype="string" access="public" output="false">
<cfreturn " VALUES(default)">
<cfargument name="$primaryKey" type="string" required="true" hint="the table primaryKey">
<cfreturn "(#arguments.$primaryKey#) VALUES(DEFAULT)">
</cffunction>

<cffunction name="$generatedKey" returntype="string" access="public" output="false">
Expand Down
4 changes: 2 additions & 2 deletions wheels/model/crud.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,8 @@
else
{
// no properties were set on the object so we insert a record with only default values to the database
ArrayAppend(loc.sql, "INSERT INTO #tableName()#" & variables.wheels.class.adapter.$defaultValues());
loc.primaryKeys = "";
loc.primaryKeys = primaryKey(0);
ArrayAppend(loc.sql, "INSERT INTO #tableName()#" & variables.wheels.class.adapter.$defaultValues($primaryKey=loc.primaryKeys));
}
// run the insert sql statement and set the primary key value on the object (if one was returned from the database)
Expand Down
4 changes: 2 additions & 2 deletions wheels/tests/model/crud/create.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
</cfif>
</cffunction>

<!--- <cffunction name="test_saving_a_new_model_without_properties_should_not_throw_errors">
<cffunction name="test_saving_a_new_model_without_properties_should_not_throw_errors">
<cftransaction action="begin">
<cfset loc.model = model("tag").new()>
<cfset loc.str = raised('loc.model.save(reload=true)')>
<cfset assert('loc.str eq ""')>
<cftransaction action="rollback"/>
</cftransaction>
</cffunction> --->
</cffunction>

</cfcomponent>

0 comments on commit 5a3ee4b

Please sign in to comment.