I ran into an issue and wanted to see if it can be cleared up.
Quick ORM is implemented with SQL Server as the grammar.
I have a model file with a column that is setup like so:
property name="columnXYZ" sqltype="CF_SQL_CHAR";
In the database the columnXYZ is defined as a datatype UNIQUEIDENTIFIER. In the ACF docs the equivalent datatype choice are: cf_sql_char for SQL Server datatypes of char, nchar, uniqueidentifier.
However, I attempt insert a row into the table, the error returned is: “conversion from char to uniqueindentifier failed”
I tried setting the property sqltype for the column in model file to CF_SQL_VARCHAR and CF_SQL_IDSTAMP and the issue was still the same. The error stated it was unable to convert.
I removed the property for that column in the model file and the insert completed without issue.
Can you comment if this is a bug or if I’m not using the correct syntax?
Here’s my function in the service file that returns the array of structs I want to insert into the database:
function getRegTypeProd(id){
try{
var query = db.getQuickBuilder().getQb().where('id', id).setReturnFormat( 'array').get(options = { datasource:"prod" });
if(isNull(query)){
return [];
}
return query;
}
catch (any e) {
helpers.exceptionHandlerHelper::throwException(message = e.message);
}
}
Here’s my insert function in the service file:
The “fields” argument is an array of structs from the function above.
function insertFromProdToDev(fields = []){
if(arrayIsEmpty(fields)){
return fields;
}
for(field in fields){
structDelete(field, "regTypeId");
}
try{
var result = db.getQuickBuilder().getQb().insert(values = fields, options = { datasource:"test" });
return result;
}catch (any e) {
helpers.exceptionHandlerHelper::throwException(message = e.message);
}
}
Any explanation/assistance would be very much appreciated.