[Test Framework] MySQL error when navigating to "Define"

[Test Framework] MySQL error when navigating to "Define"

  
Forge Component
(15)
Published on 26 Mar by Indigo Leap
15 votes
Published on 26 Mar by Indigo Leap

Hi,

I just installed TestFramework and logged in. Now I try to navigate to "Define" -section and all I get is an Internal error. In the service center I see the following error:


Error in advanced query GetTestSuites in Preparation in Setup_0_List in TestSetupFlow in TestFramework (SELECT {TestSuite}.*,      (       select count (1)          from {TestCase}          where {TestCase}.[TestSuiteId] = {TestSuite}.[Id]      ) NumberTestCases,      (       select count (1)          from {TestCase}          where {TestCase}.[TestSuiteId] = {TestSuite}.[Id]          and {TestCase}.[IsQuarantine] = 1      ) NumberQuarantinedTestCases,      (       select count (1)          from {TestCase}              inner join {TestStep} on {TestStep}.[TestCaseId] = {TestCase}.[Id]          where {TestCase}.[TestSuiteId] = {TestSuite}.[Id]      ) NumberTestSteps,      {TestScheduleStatus}.*  from {TestSuite}  left join {TestSchedule} on {TestSchedule}.[TestSuiteId] = {TestSuite}.[Id] and ({TestSchedule}.[Status] = @TestScheduleStatusExecution  or {TestSchedule}.[Status] = @TestScheduleStatusNew )  left join {TestScheduleStatus} on {TestSchedule}.[Status] = {TestScheduleStatus}.[Id]   where (@IsActive = '' or {TestSuite}.[IsActive] = @IsActive)    and {TestSuite}.[Name] like '%' + @Sear ...): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+ '' + '%'  order by  `outsystems`.`OSUSR_044_TestSuite2`.`Name`) result' at line 1


Platform version 10.0.604.0

MySQL version 5.6.34-log

I made the following change in our environment in the GetTestSuites advanced query:

Modified this: 

  and {TestSuite}.[Name] like '%' + @Search + '%'

to this: 

  and {TestSuite}.[Name] like concat('%',@Search,'%')


This resulted in a different error:

Error in advanced query GetTestSuites in Preparation in Setup_0_List in TestSetupFlow in TestFramework (SELECT {TestSuite}.*,      (       select count(1)          from {TestCase}          where {TestCase}.[TestSuiteId] = {TestSuite}.[Id]      ) NumberTestCases,      (       select count(1)          from {TestCase}          where {TestCase}.[TestSuiteId] = {TestSuite}.[Id]          and {TestCase}.[IsQuarantine] = 1      ) NumberQuarantinedTestCases,      (       select count(1)          from {TestCase}              inner join {TestStep} on {TestStep}.[TestCaseId] = {TestCase}.[Id]          where {TestCase}.[TestSuiteId] = {TestSuite}.[Id]      ) NumberTestSteps,      {TestScheduleStatus}.*  from {TestSuite}  left join {TestSchedule} on {TestSchedule}.[TestSuiteId] = {TestSuite}.[Id] and ({TestSchedule}.[Status] = @TestScheduleStatusExecution  or {TestSchedule}.[Status] = @TestScheduleStatusNew )  left join {TestScheduleStatus} on {TestSchedule}.[Status] = {TestScheduleStatus}.[Id]   where (@IsActive = '' or {TestSuite}.[IsActive] = @IsActive)    and {TestSuite}.[Name] like concat('%',@Se ...): Duplicate column name 'Id'


Any ideas? I extracted the SQL and I can run it manually with no errors.

Seems that it was a problem with MySQL and was fixed with the following aliases:

Modified this: 

NumberTestSteps,
    {TestScheduleStatus}.*

to this:

NumberTestSteps,
    {TestScheduleStatus}.[Id] scheduleStatusId,{TestScheduleStatus}.[Label] scheduleStatusLabel,{TestScheduleStatus}.[Order] scheduleStatusOrder


Great, thanks for sharing! :-)