 	<cfargument name="name" type="string" required="true">
 	<cfargument name="path" type="string" required="true">
 	<cfscript>
-		var loc = {};
 		variables.wheels = {};
 		variables.wheels.errors = [];
 		variables.wheels.class = {};

			variables.wheels.class.adapter = $assignAdapter();

			// get columns for the table
			loc.columns = variables.wheels.class.adapter.$getColumns(tableName());

			loc.processedColumns = "";
			loc.iEnd = loc.columns.recordCount;
			for (loc.i=1; loc.i <= loc.iEnd; loc.i++) {
				// set up properties and column mapping
				if (!ListFind(loc.processedColumns, loc.columns["column_name"][loc.i])) {
					// default the column to map to a property with the same name
					loc.property = loc.columns["column_name"][loc.i];
					for (loc.key in variables.wheels.class.mapping) {
						if (StructKeyExists(variables.wheels.class.mapping[loc.key], "type") && variables.wheels.class.mapping[loc.key].type == "column" && variables.wheels.class.mapping[loc.key].value == loc.property) {
							// developer has chosen to map this column to a property with a different name so set that here
							loc.property = loc.key;
							break;
						}
					}
					loc.type = SpanExcluding(loc.columns["type_name"][loc.i], "( ");

					// set the info we need for each property
					variables.wheels.class.properties[loc.property] = {};
					variables.wheels.class.properties[loc.property].dataType = loc.type;
					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)
					variables.wheels.class.properties[loc.property].nullable = Trim(loc.columns["is_nullable"][loc.i]);
					if (!IsBoolean(variables.wheels.class.properties[loc.property].nullable)) {
						variables.wheels.class.properties[loc.property].nullable = ReplaceList(variables.wheels.class.properties[loc.property].nullable, "N,Y", "No,Yes");
					}

					variables.wheels.class.properties[loc.property].size = loc.columns["column_size"][loc.i];

					// If property is id, then make it all-caps "ID."
					if (loc.property == "id") {
						variables.wheels.class.properties[loc.property].label = "ID";
					// If property ends with id, then drop it off. (For example, "userid" becomes "User.")
					} else if (Right(loc.property, 2) == "id") {
						variables.wheels.class.properties[loc.property].label = humanize(Left(loc.property, Len(loc.property) - 2));
					// Otherwise, humanize it.
					} else {
						variables.wheels.class.properties[loc.property].label = humanize(loc.property);
					}

					variables.wheels.class.properties[loc.property].validationtype = variables.wheels.class.adapter.$getValidationType(variables.wheels.class.properties[loc.property].type);
					if (StructKeyExists(variables.wheels.class.mapping, loc.property)) {
						if (StructKeyExists(variables.wheels.class.mapping[loc.property], "label")) {
							variables.wheels.class.properties[loc.property].label = variables.wheels.class.mapping[loc.property].label;
						}
						if (StructKeyExists(variables.wheels.class.mapping[loc.property], "defaultValue")) {
							variables.wheels.class.properties[loc.property].defaultValue = variables.wheels.class.mapping[loc.property].defaultValue;
						}
					}
					if (loc.columns["is_primarykey"][loc.i]) {
						setPrimaryKey(loc.property);
					}
					if (variables.wheels.class.automaticValidations && !ListFindNoCase("#application.wheels.timeStampOnCreateProperty#,#application.wheels.timeStampOnUpdateProperty#,#application.wheels.softDeleteProperty#", loc.property)) {
						loc.defaultValidationsAllowBlank = variables.wheels.class.properties[loc.property].nullable;

						// primary keys should be allowed to be blank
						if (ListFindNoCase(primaryKeys(), loc.property)) {
							loc.defaultValidationsAllowBlank = true;
						}
						if (!ListFindNoCase(primaryKeys(), loc.property) && !variables.wheels.class.properties[loc.property].nullable && !$validationExists(property=loc.property, validation="validatesPresenceOf")) {
							if (Len(loc.columns["column_default_value"][loc.i])) {
								validatesPresenceOf(properties=loc.property, when="onUpdate");
							} else {
								validatesPresenceOf(properties=loc.property);
							}
						}

						// always allow blank if a database default or validatesPresenceOf() has been set
						if (Len(loc.columns["column_default_value"][loc.i]) || $validationExists(property=loc.property, validation="validatesPresenceOf")) {
							loc.defaultValidationsAllowBlank = true;
						}

						// set length validations if the developer has not
						if (variables.wheels.class.properties[loc.property].validationtype == "string" && !$validationExists(property=loc.property, validation="validatesLengthOf")) {
							validatesLengthOf(properties=loc.property, allowBlank=loc.defaultValidationsAllowBlank, maximum=variables.wheels.class.properties[loc.property].size);
						}

						// set numericality validations if the developer has not
						if (ListFindNoCase("integer,float", variables.wheels.class.properties[loc.property].validationtype) && !$validationExists(property=loc.property, validation="validatesNumericalityOf")) {
							validatesNumericalityOf(properties=loc.property, allowBlank=loc.defaultValidationsAllowBlank, onlyInteger=(variables.wheels.class.properties[loc.property].validationtype == "integer"));
						}

						// set date validations if the developer has not (checks both dates or times as per the IsDate() function)
						if (variables.wheels.class.properties[loc.property].validationtype == "datetime" && !$validationExists(property=loc.property, validation="validatesFormatOf")) {
							validatesFormatOf(properties=loc.property, allowBlank=loc.defaultValidationsAllowBlank, type="date");
						}
					}
					variables.wheels.class.propertyList = ListAppend(variables.wheels.class.propertyList, loc.property);
					variables.wheels.class.columnList = ListAppend(variables.wheels.class.columnList, variables.wheels.class.properties[loc.property].column);
					loc.processedColumns = ListAppend(loc.processedColumns, loc.columns["column_name"][loc.i]);
				}
			}


		}

		// add calculated properties
		for (local.key in variables.wheels.class.mapping) {
			if (StructKeyExists(variables.wheels.class.mapping[local.key], "type") && variables.wheels.class.mapping[local.key].type != "column") {
				variables.wheels.class.calculatedPropertyList = ListAppend(variables.wheels.class.calculatedPropertyList, local.key);
				variables.wheels.class.calculatedProperties[local.key] = {};
				variables.wheels.class.calculatedProperties[local.key][variables.wheels.class.mapping[local.key].type] = variables.wheels.class.mapping[local.key].value;
				variables.wheels.class.calculatedProperties[local.key].select = variables.wheels.class.mapping[local.key].select;
				variables.wheels.class.calculatedProperties[local.key].dataType = variables.wheels.class.mapping[local.key].dataType;
			}
		}

