Skip to content

Commit

Permalink
Fixes MySQL attempts to insert nulls for blank strings cfwheels#680
Browse files Browse the repository at this point in the history
  • Loading branch information
andybellenie committed Nov 25, 2016
1 parent f23b3c3 commit eadf8f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wheels/model/create.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
local.sql2 = [];
for (local.key in variables.wheels.class.properties)
{
if (StructKeyExists(this, local.key))
// only include this property if it has a value, or the column is not nullable and has no default set
if (StructKeyExists(this, local.key) && (Len(this[local.key]) or (!variables.wheels.class.properties[local.key].nullable && !Len(variables.wheels.class.properties[local.key].columndefault))))
{
ArrayAppend(local.sql, variables.wheels.class.properties[local.key].column);
ArrayAppend(local.sql, ",");
Expand Down
1 change: 1 addition & 0 deletions wheels/model/initialization.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
variables.wheels.class.properties[loc.property].type = variables.wheels.class.adapter.$getType(loc.type, loc.columns["decimal_digits"][loc.i]);
variables.wheels.class.properties[loc.property].column = loc.columns["column_name"][loc.i];
variables.wheels.class.properties[loc.property].scale = loc.columns["decimal_digits"][loc.i];
variables.wheels.class.properties[loc.property].columndefault = loc.columns["column_default_value"][loc.i];
// get a boolean value for whether this column can be set to null or not
// if we don't get a boolean back we try to translate y/n to proper boolean values in cfml (yes/no)
Expand Down

0 comments on commit eadf8f1

Please sign in to comment.