Comparing version 2.0.4 to 2.0.5
{ | ||
"name": "foxhound", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "A Database Query generation library.", | ||
@@ -5,0 +5,0 @@ "main": "source/FoxHound.js", |
@@ -35,8 +35,88 @@ /** | ||
{ | ||
if (pParameters.scope && pParameters.scope.indexOf('`') >= 0) | ||
return ' '+pParameters.scope+''; | ||
else | ||
return ' `'+pParameters.scope+'`'; | ||
// Every Foxhound query has a table name; this puts it on here even if there are no columns | ||
// Which occurs when you generate a query like SELECT COUNT(*) FROM SomeTable; | ||
if (!pParameters.query.hasOwnProperty('parameterTypes')) | ||
{ | ||
pParameters.query.parameterTypes = {}; | ||
} | ||
return ' '+pParameters.scope; | ||
}; | ||
var generateMSSQLParameterTypeEntry = function(pParameters, pColumnParameterName, pColumn) | ||
{ | ||
// Lazily create the parameterTypes object if it doesn't exist | ||
if (!pParameters.query.hasOwnProperty('parameterTypes')) | ||
{ | ||
pParameters.query.parameterTypes = {}; | ||
} | ||
// Find the column parameter type for our prepared statement | ||
let tmpColumnParameterTypeString = 'VarChar'; | ||
if (typeof(pColumn) == 'object') | ||
{ | ||
// See if it has a type, set the type string | ||
tmpColumnParameterTypeString = pColumn.Type; | ||
} | ||
else if (typeof(pColumn) == 'string') | ||
{ | ||
var tmpSchema = Array.isArray(pParameters.query.schema) ? pParameters.query.schema : []; | ||
for (let i = 0; i < tmpSchema.length; i++) | ||
{ | ||
if (tmpSchema[i].Column == pColumn) | ||
{ | ||
tmpColumnParameterTypeString = tmpSchema[i].Type; | ||
break; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
_Fable.log.warn(`Meadow MSSQL query attempted to add a parameter type but no valid column schema entry object or column name was passed; parameter name ${pColumnParameterName}.`); | ||
} | ||
if ((tmpColumnParameterTypeString == null) || (tmpColumnParameterTypeString == undefined)) | ||
{ | ||
return false; | ||
} | ||
switch (tmpColumnParameterTypeString) | ||
{ | ||
case 'AutoIdentity': | ||
case 'CreateIDUser': | ||
case 'UpdateIDUser': | ||
case 'DeleteIDUser': | ||
case 'Integer': | ||
pParameters.query.parameterTypes[pColumnParameterName] = 'Int'; | ||
break; | ||
case 'Deleted': | ||
case 'Boolean': | ||
pParameters.query.parameterTypes[pColumnParameterName] = 'TinyInt'; | ||
break; | ||
case 'Decimal': | ||
pParameters.query.parameterTypes[pColumnParameterName] = 'Decimal'; | ||
break; | ||
case 'String': | ||
case 'AutoGUID': | ||
pParameters.query.parameterTypes[pColumnParameterName] = 'Char'; | ||
break; | ||
case 'CreateDate': | ||
case 'UpdateDate': | ||
case 'DeleteDate': | ||
case 'DateTime': | ||
pParameters.query.parameterTypes[pColumnParameterName] = 'DateTime'; | ||
break; | ||
default: | ||
// TODO: This might should throw? It would mean a new type was added to stricture we don't know about. | ||
pParameters.query.parameterTypes[pColumnParameterName] = tmpColumnParameterTypeString; | ||
return false; | ||
} | ||
return true; | ||
} | ||
/** | ||
@@ -103,9 +183,2 @@ * Generate a field list from the array of dataElements | ||
const SURROUNDING_QUOTES_AND_WHITESPACE_REGEX = /^[` ]+|[` ]+$/g; | ||
const cleanseQuoting = (str) => | ||
{ | ||
return str.replace(SURROUNDING_QUOTES_AND_WHITESPACE_REGEX, ''); | ||
}; | ||
/** | ||
@@ -116,20 +189,3 @@ * Ensure a field name is properly escaped. | ||
{ | ||
let pFieldNames = pFieldName.split('.'); | ||
if (pFieldNames.length > 1) | ||
{ | ||
const cleansedFieldName = cleanseQuoting(pFieldNames[1]); | ||
if (cleansedFieldName === '*') | ||
{ | ||
// do not put * as `*` | ||
return "`" + cleanseQuoting(pFieldNames[0]) + "`.*"; | ||
} | ||
return "`" + cleanseQuoting(pFieldNames[0]) + "`.`" + cleansedFieldName + "`"; | ||
} | ||
const cleansedFieldName = cleanseQuoting(pFieldNames[0]); | ||
if (cleansedFieldName === '*') | ||
{ | ||
// do not put * as `*` | ||
return '*'; | ||
} | ||
return "`" + cleanseQuoting(pFieldNames[0]) + "`"; | ||
return pFieldName; | ||
} | ||
@@ -237,4 +293,6 @@ | ||
// Add the column name, operator and parameter name to the list of where value parenthetical | ||
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' ( :'+tmpColumnParameter+' )'; | ||
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' ( @'+tmpColumnParameter+' )'; | ||
pParameters.query.parameters[tmpColumnParameter] = tmpFilter[i].Value; | ||
// Find the column in the schema | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpFilter[i].Parameter) | ||
} | ||
@@ -255,4 +313,5 @@ else if (tmpFilter[i].Operator === 'IS NULL') | ||
// Add the column name, operator and parameter name to the list of where value parenthetical | ||
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' :'+tmpColumnParameter; | ||
tmpWhere += ' '+tmpFilter[i].Column+' '+tmpFilter[i].Operator+' @'+tmpColumnParameter; | ||
pParameters.query.parameters[tmpColumnParameter] = tmpFilter[i].Value; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpFilter[i].Parameter) | ||
} | ||
@@ -313,10 +372,14 @@ } | ||
var tmpLimit = ' LIMIT'; | ||
var tmpLimit = ' OFFSET '; | ||
// If there is a begin record, we'll pass that in as well. | ||
if (pParameters.begin !== false) | ||
{ | ||
tmpLimit += ' ' + pParameters.begin + ','; | ||
tmpLimit += pParameters.begin; | ||
} | ||
else | ||
{ | ||
tmpLimit += '0'; | ||
} | ||
// Cap is required for a limit clause. | ||
tmpLimit += ' ' + pParameters.cap; | ||
tmpLimit += ` ROWS FETCH NEXT ${pParameters.cap} ROWS ONLY`; | ||
@@ -429,12 +492,14 @@ return tmpLimit; | ||
var tmpColumnParameter = tmpColumn+'_'+tmpCurrentColumn; | ||
tmpUpdate += ' '+tmpColumn+' = :'+tmpColumnParameter; | ||
tmpUpdate += ' '+tmpColumn+' = @'+tmpColumnParameter; | ||
// Set the query parameter | ||
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpColumn) | ||
break; | ||
default: | ||
var tmpColumnDefaultParameter = tmpColumn+'_'+tmpCurrentColumn; | ||
tmpUpdate += ' '+tmpColumn+' = :'+tmpColumnDefaultParameter; | ||
tmpUpdate += ' '+tmpColumn+' = @'+tmpColumnDefaultParameter; | ||
// Set the query parameter | ||
pParameters.query.parameters[tmpColumnDefaultParameter] = tmpRecords[0][tmpColumn]; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnDefaultParameter, tmpSchemaEntry) | ||
break; | ||
@@ -503,5 +568,6 @@ } | ||
var tmpColumnParameter = tmpSchemaEntry.Column+'_'+tmpCurrentColumn; | ||
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = :'+tmpColumnParameter; | ||
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = @'+tmpColumnParameter; | ||
// Set the query parameter | ||
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry) | ||
break; | ||
@@ -571,4 +637,5 @@ default: | ||
var tmpColumnParameter = tmpSchemaEntry.Column+'_'+tmpCurrentColumn; | ||
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = :'+tmpColumnParameter; | ||
tmpUpdateSql = ' '+tmpSchemaEntry.Column+' = @'+tmpColumnParameter; | ||
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry) | ||
break; | ||
@@ -658,5 +725,6 @@ default: | ||
var tmpColumnParameter = tmpColumn+'_'+tmpCurrentColumn; | ||
tmpCreateSet += ' :'+tmpColumnParameter; | ||
tmpCreateSet += ' @'+tmpColumnParameter; | ||
// Set the query parameter | ||
pParameters.query.parameters[tmpColumnParameter] = tmpRecords[0][tmpColumn]; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry) | ||
}; | ||
@@ -694,5 +762,6 @@ | ||
tmpColumnParameter = tmpColumn+'_'+tmpCurrentColumn; | ||
tmpCreateSet += ' :'+tmpColumnParameter; | ||
tmpCreateSet += ' @'+tmpColumnParameter; | ||
// Set the query parameter | ||
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.UUID; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry) | ||
} | ||
@@ -725,5 +794,6 @@ break; | ||
tmpColumnParameter = tmpColumn+'_'+tmpCurrentColumn; | ||
tmpCreateSet += ' :'+tmpColumnParameter; | ||
tmpCreateSet += ' @'+tmpColumnParameter; | ||
// Set the query parameter | ||
pParameters.query.parameters[tmpColumnParameter] = pParameters.query.IDUser; | ||
generateMSSQLParameterTypeEntry(pParameters, tmpColumnParameter, tmpSchemaEntry) | ||
} | ||
@@ -944,3 +1014,3 @@ break; | ||
return `SELECT COUNT(${tmpOptDistinct}${tmpFieldList || '*'}) AS RowCount FROM${tmpTableName}${tmpJoin}${tmpWhere};`; | ||
return `SELECT COUNT(${tmpOptDistinct}${tmpFieldList || '*'}) AS Row_Count FROM${tmpTableName}${tmpJoin}${tmpWhere};`; | ||
}; | ||
@@ -947,0 +1017,0 @@ |
@@ -27,3 +27,5 @@ /** | ||
{ Column: "DeletingIDUser", Type:"DeleteIDUser" }, | ||
{ Column: "DeleteDate", Type:"DeleteDate" } | ||
{ Column: "DeleteDate", Type:"DeleteDate" }, | ||
{ Column: "Name", Type:"String" }, | ||
{ Column: "Age", Type:"Integer" } | ||
]); | ||
@@ -93,3 +95,3 @@ | ||
Expect(tmpQuery.query.body) | ||
.to.equal("INSERT INTO `Animal` ( IDAnimal, Name, Age) VALUES ( :IDAnimal_0, :Name_1, :Age_2);"); | ||
.to.equal("INSERT INTO Animal ( IDAnimal, Name, Age) VALUES ( @IDAnimal_0, @Name_1, @Age_2);"); | ||
} | ||
@@ -125,3 +127,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Animal`.* FROM `Animal` ORDER BY Cost DESC;'); | ||
.to.equal('SELECT Animal.* FROM Animal ORDER BY Cost DESC;'); | ||
} | ||
@@ -142,3 +144,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT DISTINCT `Animal`.* FROM `Animal` ORDER BY Cost DESC;'); | ||
.to.equal('SELECT DISTINCT Animal.* FROM Animal ORDER BY Cost DESC;'); | ||
} | ||
@@ -165,4 +167,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE Age = :Age_w0 ORDER BY Age, Cost LIMIT 0, 10;'); | ||
} | ||
.to.equal('SELECT Name, Age, Cost FROM Animal WHERE Age = @Age_w0 ORDER BY Age, Cost OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); } | ||
); | ||
@@ -188,4 +189,3 @@ test | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT *, `Name`, `Age`, `Cost`, `Animal`.* FROM `Animal` WHERE Age = :Age_w0 ORDER BY Age, Cost LIMIT 0, 10;'); | ||
} | ||
.to.equal('SELECT *, Name, Age, Cost, Animal.* FROM Animal WHERE Age = @Age_w0 ORDER BY Age, Cost OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); } | ||
); | ||
@@ -209,3 +209,3 @@ test | ||
.addFilter('IDOffice', [10, 11, 15, 18, 22], 'IN'); | ||
tmpQuery.setLogLevel(3).addSort('Age'); | ||
tmpQuery.setLogLevel(0).addSort('Age'); | ||
// Build the query | ||
@@ -216,3 +216,3 @@ tmpQuery.buildReadQuery(); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE Age = :Age_w0 AND ( Color = :Color_w2 OR Color = :Color_w3 ) AND Description IS NOT NULL AND IDOffice IN ( :IDOffice_w6 ) ORDER BY Age LIMIT 100;'); | ||
.to.equal('SELECT Name, Age, Cost FROM Animal WHERE Age = @Age_w0 AND ( Color = @Color_w2 OR Color = @Color_w3 ) AND Description IS NOT NULL AND IDOffice IN ( @IDOffice_w6 ) ORDER BY Age OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;'); | ||
} | ||
@@ -239,4 +239,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT Name, Age * 5, Cost FROM `Animal` WHERE Age = :Age_w0 LIMIT 0, 10;'); | ||
} | ||
.to.equal('SELECT Name, Age * 5, Cost FROM Animal WHERE Age = @Age_w0 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); } | ||
); | ||
@@ -263,4 +262,3 @@ test | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT Name, Age * 5, Cost FROM `Animal` WHERE Age = :Age_w0 LIMIT 0, 10;'); | ||
} | ||
.to.equal('SELECT Name, Age * 5, Cost FROM Animal WHERE Age = @Age_w0 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); } | ||
); | ||
@@ -322,3 +320,3 @@ test | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal` WHERE Age = :Age_w0;'); | ||
.to.equal('SELECT COUNT(*) AS RowCount FROM Animal WHERE Age = @Age_w0;'); | ||
} | ||
@@ -342,3 +340,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal` WHERE Age = :Age_w0;'); | ||
.to.equal('SELECT COUNT(*) AS RowCount FROM Animal WHERE Age = @Age_w0;'); | ||
} | ||
@@ -362,3 +360,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET Age = :Age_0, Color = :Color_1 WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('UPDATE Animal SET Age = @Age_0, Color = @Color_1 WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -397,3 +395,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('DELETE FROM `Animal` WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('DELETE FROM Animal WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -415,3 +413,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal`;'); | ||
.to.equal('SELECT COUNT(*) AS Row_Count FROM Animal;'); | ||
} | ||
@@ -435,3 +433,4 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT COUNT(DISTINCT `Animal`.`IDAnimal`) AS RowCount FROM `Animal` WHERE `Animal`.Deleted = :Deleted_w0;'); | ||
// RowCount is a reserved word for MSSQL so we need to change it to Row_Count | ||
.to.equal('SELECT COUNT(DISTINCT Animal.IDAnimal) AS Row_Count FROM Animal WHERE Animal.Deleted = @Deleted_w0;'); | ||
} | ||
@@ -454,3 +453,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT COUNT(*) AS RowCount FROM `Animal`;'); | ||
.to.equal('SELECT COUNT(*) AS Row_Count FROM Animal;'); | ||
} | ||
@@ -466,3 +465,3 @@ ); | ||
.setScope('Animal') | ||
.setDataElements(['Name', 'Age', 'Cost']); | ||
.setDataElements(['Name']); | ||
tmpQuery.setDistinct(true); | ||
@@ -475,3 +474,3 @@ | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT COUNT(DISTINCT `Name`, `Age`, `Cost`) AS RowCount FROM `Animal`;'); | ||
.to.equal('SELECT COUNT(DISTINCT Name) AS Row_Count FROM Animal;'); | ||
} | ||
@@ -516,3 +515,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal("INSERT INTO `Animal` ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( NULL, :GUIDAnimal_1, NOW(3), :CreatingIDUser_3, NOW(3), :UpdatingIDUser_5, :Deleted_6, :Name_7, :Age_8);"); | ||
.to.equal("INSERT INTO Animal ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( NULL, @GUIDAnimal_1, NOW(3), @CreatingIDUser_3, NOW(3), @UpdatingIDUser_5, @Deleted_6, @Name_7, @Age_8);"); | ||
} | ||
@@ -549,3 +548,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal("INSERT INTO `Animal` ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( NULL, :GUIDAnimal_1, NOW(3), :CreatingIDUser_3, NOW(3), :UpdatingIDUser_5, :Deleted_6, :Name_7, :Age_8);"); | ||
.to.equal("INSERT INTO Animal ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, Name, Age) VALUES ( NULL, @GUIDAnimal_1, NOW(3), @CreatingIDUser_3, NOW(3), @UpdatingIDUser_5, @Deleted_6, @Name_7, @Age_8);"); | ||
} | ||
@@ -586,3 +585,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal("INSERT INTO `Animal` ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, DeletingIDUser, DeleteDate, Name, Age) VALUES ( :IDAnimal_0, :GUIDAnimal_1, :CreateDate_2, :CreatingIDUser_3, :UpdateDate_4, :UpdatingIDUser_5, :Deleted_6, :DeletingIDUser_7, :DeleteDate_8, :Name_9, :Age_10);"); | ||
.to.equal("INSERT INTO Animal ( IDAnimal, GUIDAnimal, CreateDate, CreatingIDUser, UpdateDate, UpdatingIDUser, Deleted, DeletingIDUser, DeleteDate, Name, Age) VALUES ( @IDAnimal_0, @GUIDAnimal_1, @CreateDate_2, @CreatingIDUser_3, @UpdateDate_4, @UpdatingIDUser_5, @Deleted_6, @DeletingIDUser_7, @DeleteDate_8, @Name_9, @Age_10);"); | ||
} | ||
@@ -608,3 +607,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE `Animal`.Deleted = :Deleted_w0 LIMIT 100;'); | ||
.to.equal('SELECT Name, Age, Cost FROM Animal WHERE Animal.Deleted = @Deleted_w0 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;'); | ||
} | ||
@@ -631,3 +630,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT DISTINCT `Name`, `Age`, `Cost` FROM `Animal` WHERE `Animal`.Deleted = :Deleted_w0 LIMIT 100;'); | ||
.to.equal('SELECT DISTINCT Name, Age, Cost FROM Animal WHERE Animal.Deleted = @Deleted_w0 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;'); | ||
} | ||
@@ -661,3 +660,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` WHERE Age = :Age_w0 AND ( Color = :Color_w2 OR Color = :Color_w3 ) AND Description IS NOT NULL AND IDOffice IN ( :IDOffice_w6 ) AND Deleted = :Deleted_w7 LIMIT 100;'); | ||
.to.equal('SELECT Name, Age, Cost FROM Animal WHERE Age = @Age_w0 AND ( Color = @Color_w2 OR Color = @Color_w3 ) AND Description IS NOT NULL AND IDOffice IN ( @IDOffice_w6 ) AND Deleted = @Deleted_w7 OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;'); | ||
} | ||
@@ -684,3 +683,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` LIMIT 100;'); | ||
.to.equal('SELECT Name, Age, Cost FROM Animal OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;'); | ||
} | ||
@@ -706,3 +705,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET UpdateDate = NOW(3), Deleted = 1, DeletingIDUser = :DeletingIDUser_2, DeleteDate = NOW(3) WHERE IDAnimal = :IDAnimal_w0 AND `Animal`.Deleted = :Deleted_w1;'); | ||
.to.equal('UPDATE Animal SET UpdateDate = NOW(3), Deleted = 1, DeletingIDUser = @DeletingIDUser_2, DeleteDate = NOW(3) WHERE IDAnimal = @IDAnimal_w0 AND Animal.Deleted = @Deleted_w1;'); | ||
} | ||
@@ -735,3 +734,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET GUIDAnimal = :GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = :UpdatingIDUser_2, Name = :Name_3, Age = :Age_4 WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = @UpdatingIDUser_2, Name = @Name_3, Age = @Age_4 WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -766,3 +765,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET GUIDAnimal = :GUIDAnimal_0, Name = :Name_1, Age = :Age_2 WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, Name = @Name_1, Age = @Age_2 WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -789,3 +788,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('DELETE FROM `Animal` WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('DELETE FROM Animal WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -810,3 +809,3 @@ ); | ||
UpdatingIDUser:false, | ||
Deleted:false, | ||
Deleted:0, | ||
DeletingIDUser:false, | ||
@@ -823,3 +822,3 @@ DeleteDate:false, | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET GUIDAnimal = :GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = :UpdatingIDUser_2, Deleted = :Deleted_3, Name = :Name_4, Age = :Age_5 WHERE IDAnimal = :IDAnimal_w0 AND Deleted = :Deleted_w1;'); | ||
.to.equal('UPDATE Animal SET GUIDAnimal = @GUIDAnimal_0, UpdateDate = NOW(3), UpdatingIDUser = @UpdatingIDUser_2, Deleted = @Deleted_3, Name = @Name_4, Age = @Age_5 WHERE IDAnimal = @IDAnimal_w0 AND Deleted = @Deleted_w1;'); | ||
} | ||
@@ -846,3 +845,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET UpdateDate = NOW(3), Deleted = 1, DeletingIDUser = :DeletingIDUser_2, DeleteDate = NOW(3) WHERE IDAnimal = :IDAnimal_w0 AND `Animal`.Deleted = :Deleted_w1;'); | ||
.to.equal('UPDATE Animal SET UpdateDate = NOW(3), Deleted = 1, DeletingIDUser = @DeletingIDUser_2, DeleteDate = NOW(3) WHERE IDAnimal = @IDAnimal_w0 AND Animal.Deleted = @Deleted_w1;'); | ||
} | ||
@@ -870,3 +869,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('DELETE FROM `Animal` WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('DELETE FROM Animal WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -891,3 +890,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('UPDATE `Animal` SET UpdateDate = NOW(3), UpdatingIDUser = :UpdatingIDUser_1, Deleted = 0 WHERE IDAnimal = :IDAnimal_w0;'); | ||
.to.equal('UPDATE Animal SET UpdateDate = NOW(3), UpdatingIDUser = @UpdatingIDUser_1, Deleted = 0 WHERE IDAnimal = @IDAnimal_w0;'); | ||
} | ||
@@ -940,4 +939,3 @@ ); | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Name`, `Age`, `Cost` FROM `Animal` INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = :Age_w0 ORDER BY Age LIMIT 0, 10;'); | ||
} | ||
.to.equal('SELECT Name, Age, Cost FROM Animal INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = @Age_w0 ORDER BY Age OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); } | ||
); | ||
@@ -965,4 +963,3 @@ test | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT DISTINCT `Name`, `Age`, `Cost` FROM `Animal` INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = :Age_w0 ORDER BY Age LIMIT 0, 10;'); | ||
} | ||
.to.equal('SELECT DISTINCT Name, Age, Cost FROM Animal INNER JOIN Test ON Test.IDAnimal = Animal.IDAnimal WHERE Age = @Age_w0 ORDER BY Age OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;'); } | ||
); | ||
@@ -984,3 +981,3 @@ test | ||
Expect(tmpQuery.query.body) | ||
.to.equal('SELECT `Animal`.* FROM `Animal`;'); //bad join is ignored, warn log is generated | ||
.to.equal('SELECT Animal.* FROM Animal;'); //bad join is ignored, warn log is generated | ||
} | ||
@@ -987,0 +984,0 @@ ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
665763
11121