View Issue Details

This bug affects 4 person(s).
 36
IDProjectCategoryView StatusLast Update
17522Bug reports_ Unknownpublic2021-09-06 10:59
Reporternooblag Assigned Toollehar  
PrioritynormalSeveritycrash 
Status closedResolutionfixed 
Product Version5.x 
Summary17522: CDbCommand failed to execute the SQL statement: SQLSTATE[42803]
Description

I'm getting this error whenever I try to Export Results of a survey:

500: Internal Server Error
CDbCommand failed to execute the SQL statement: SQLSTATE[42803]: Grouping error: 7 ERROR: column "lime_survey_873476.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 5: ORDER BY "lime_survey_873476"."id" ASC
^

I've done the Data consistency check and Data redundancy check in Lime Survey admin and still this occurs.

System configuration:

LimeSurvey version 5.1.3
LimeSurvey build github
Operating system Linux 4.15.0-153-generic x86_64
PHP version 7.4.22
Web server software nginx/1.18.0
Web server info HTTP/1.1
Database driver pgsql
Database driver version 10.17 (Ubuntu 10.17-0ubuntu0.18.04.1)
Database server info PID: 36791; Client Encoding: UTF8; Is Superuser: off; Session Authorization: limesurvey; Date Style: ISO, MDY
Database server version10.18 (Ubuntu 10.18-0ubuntu0.18.04.1)
Steps To Reproduce

Go to Export data from a survey

TagsNo tags attached.
Attached Files
Bug heat36
Complete LimeSurvey version number (& build)5.1.3, github build
I will donate to the project if issue is resolvedYes
BrowserFirefox 91.0
Database type & versionPostgres 10.17
Server OS (if known)Ubuntu 18.04.5 LTS
Webserver software & version (if known)nginx 1.18.0
PHP VersionPHP 7.4.22

Relationships

has duplicate 17523 closedgalads error in SQL exporting answers 

Users monitoring this issue

zufolo441

Activities

ollehar

ollehar

2021-08-18 15:22

administrator   ~66052

Can you enable debug = 2 in application/config/config.php and try again, please? Paste the complete error message here.

nooblag

nooblag

2021-08-18 18:27

reporter   ~66057

Last edited: 2021-09-01 16:33


CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42803]: Grouping error: 7 ERROR: column "lime_survey_873476.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 5: ORDER BY "lime_survey_873476"."id" ASC
^. The SQL statement executed was: SELECT count(*)
FROM "lime_survey_873476"
LEFT JOIN "lime_survey_873476_timings" "survey_timings" ON lime_survey_873476.id = survey_timings.id
WHERE lime_survey_873476.id >= :min AND lime_survey_873476.id <= :max
ORDER BY "lime_survey_873476"."id" ASC

/var/www/LimeSurvey/framework/db/CDbCommand.php(543)

531         {
532             if($this->_connection->enableProfiling)
533                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
534 
535             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
536             $message=$e->getMessage();
537             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
538                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
539 
540             if(YII_DEBUG)
541                 $message.='. The SQL statement executed was: '.$this->getText().$par;
542 
543             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
544                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
545         }
546     }
547 
548     /**
549      * Builds a SQL SELECT statement from the given query specification.
550      * @param array $query the query specification in name-value pairs. The following
551      * query options are supported: {@link select}, {@link distinct}, {@link from},
552      * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
553      * {@link limit}, {@link offset} and {@link union}.
554      * @throws CDbException if "from" key is not present in given query parameter
555      * @return string the SQL statement

Stack Trace
#0  
+
 /var/www/LimeSurvey/framework/db/CDbCommand.php(433): CDbCommand->queryInternal()
#1  
–
 /var/www/LimeSurvey/application/helpers/admin/exportresults_helper.php(109): CDbCommand->queryScalar()

104         $survey = $surveyDao->loadSurveyById($iSurveyId, $sLanguageCode, $oOptions);
105         $writer->init($survey, $sLanguageCode, $oOptions);
106 
107         $countResponsesCommand = $surveyDao->loadSurveyResults($survey, $oOptions->responseMinRecord, $oOptions->responseMaxRecord, $sFilter, $oOptions->responseCompletionState, $oOptions->selectedColumns, $oOptions->aResponses);
108         $countResponsesCommand->select('count(*)');
109         $reponsesCount = $countResponsesCommand->queryScalar();
110         $maxRows = 100;
111         $maxPages = ceil($reponsesCount / $maxRows);
112         for ($i = 0; $i < $maxPages; $i++) {
113             $offset = $i * $maxRows;
114             $responsesQuery = $surveyDao->loadSurveyResults($survey, $oOptions->responseMinRecord, $oOptions->responseMaxRecord, $sFilter, $oOptions->responseCompletionState, $oOptions->selectedColumns, $oOptions->aResponses);

#2  
–
 /var/www/LimeSurvey/application/controllers/admin/export.php(340): ExportSurveyResultsService->exportResponses()

335         } else {
336             $sFilter = '';
337         }
338 
339         viewHelper::disableHtmlLogging();
340         $resultsService->exportResponses($iSurveyID, $explang, $sExportType, $options, $sFilter);
341 
342         Yii::app()->end();
343     }
344 
345     /*

#3  
 unknown(0): export->exportresults()
#4  
+
 /var/www/LimeSurvey/framework/web/actions/CAction.php(115): ReflectionMethod->invokeArgs()
#5  
–
 /var/www/LimeSurvey/application/core/Survey_Common_Action.php(86): CAction->runWithParamsInternal()

81             $oMethod = new ReflectionMethod($this, $sDefault);
82         }
83 
84         // We're all good to go, let's execute it
85         // runWithParamsInternal would automatically get the parameters of the method and populate them as required with the params
86         return parent::runWithParamsInternal($this, $oMethod, $params);
87     }
88 
89     /**
90      * Some functions have different parameters, which are just an alias of the
91      * usual parameters we're getting in the url. This function just populates

#6  
+
 /var/www/LimeSurvey/framework/web/CController.php(308): Survey_Common_Action->runWithParams()
#7  
+
 /var/www/LimeSurvey/framework/web/CController.php(286): CController->runAction()
#8  
+
 /var/www/LimeSurvey/framework/web/CController.php(265): CController->runActionWithFilters()
#9  
+
 /var/www/LimeSurvey/application/controllers/AdminController.php(202): CController->run()
#10     
+
 /var/www/LimeSurvey/framework/web/CWebApplication.php(282): AdminController->run()
#11     
+
 /var/www/LimeSurvey/framework/web/CWebApplication.php(141): CWebApplication->runController()
#12     
+
 /var/www/LimeSurvey/framework/base/CApplication.php(185): CWebApplication->processRequest()
#13     
+
 /var/www/LimeSurvey/index.php(192): CApplication->run()
2021-08-19 02:25:59 nginx/1.18.0 Yii Framework/1.1.24-dev
ollehar

ollehar

2021-08-18 18:52

administrator   ~66060

Last edited: 2021-09-01 16:33

@p_teichmann Probably same issue, ORDER BY needs to be removed.

zufolo441

zufolo441

2021-08-31 08:20

reporter   ~66202

Last edited: 2021-09-01 16:33

Hi, are there news about this bug? thanks!

ollehar

ollehar

2021-08-31 11:14

administrator   ~66234

Last edited: 2021-09-01 16:33

I will add it to our current sprint. Thank you for the reminder.

ollehar

ollehar

2021-09-01 16:32

administrator   ~66264

Last edited: 2021-09-01 16:33

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=32626

ollehar

ollehar

2021-09-01 16:32

administrator   ~66265

Last edited: 2021-09-01 16:33

Can you try to apply this patch, please? https://github.com/LimeSurvey/LimeSurvey/commit/c27613ffd5ee51d8fe6303c209ceb523fdc22573

nooblag

nooblag

2021-09-01 16:45

reporter   ~66267

That appears to have fixed it for me. Thanks!

zufolo441

zufolo441

2021-09-01 17:59

reporter   ~66270

Yes, for me too it worked, thanks!

YannCr

YannCr

2021-09-06 07:02

reporter   ~66328

Hello,
Will this bug be fixed in 5.1.6? If so, when will it be released?
Thanks in advance!

ollehar

ollehar

2021-09-06 10:28

administrator   ~66338

We release a bug fix release every Monday. So within an hour or so from this message.

YannCr

YannCr

2021-09-06 10:31

reporter   ~66339

Thanks for the info!

Related Changesets

LimeSurvey: master c27613ff

2021-09-01 16:32:12

ollehar

Details Diff
Fixed issue 17522: SQL error when exporting responses Affected Issues
17522
mod - application/helpers/admin/exportresults_helper.php Diff File

Issue History

Date Modified Username Field Change
2021-08-18 14:55 nooblag New Issue
2021-08-18 14:55 nooblag File Added: Screenshot 2021-08-18 at 09-59-14.png
2021-08-18 14:55 nooblag File Added: Screenshot 2021-08-18 at 09-59-50.png
2021-08-18 15:22 ollehar Note Added: 66052
2021-08-18 15:22 ollehar Bug heat 0 => 2
2021-08-18 15:23 ollehar Assigned To => ollehar
2021-08-18 15:23 ollehar Status new => feedback
2021-08-18 15:23 ollehar Severity minor => crash
2021-08-18 15:23 ollehar Description Updated
2021-08-18 15:23 ollehar Priority none => normal
2021-08-18 16:50 galads Relationship added has duplicate 17523
2021-08-18 16:50 galads Issue Monitored: zufolo441
2021-08-18 16:50 galads Bug heat 2 => 14
2021-08-18 18:27 nooblag Note Added: 66057
2021-08-18 18:27 nooblag File Added: Screenshot 2021-08-19 at 02-26-49 CDbException.png
2021-08-18 18:27 nooblag Status feedback => assigned
2021-08-18 18:52 ollehar Note Added: 66060
2021-08-31 08:20 guest Bug heat 14 => 20
2021-08-31 08:20 zufolo441 Note Added: 66202
2021-08-31 08:20 zufolo441 Bug heat 20 => 22
2021-08-31 08:29 c_schmitz Bug heat 22 => 28
2021-08-31 09:07 guest Bug heat 28 => 34
2021-08-31 10:34 p_teichmann Sync to Zoho Project => |Yes|
2021-08-31 11:11 ollehar Sync to Zoho Project Yes => |Yes|
2021-08-31 11:12 ollehar Sync to Zoho Project Yes =>
2021-08-31 11:12 ollehar Sync to Zoho Project => |Yes|
2021-08-31 11:14 ollehar Note Added: 66234
2021-08-31 12:19 c_schmitz Sync to Zoho Project Yes =>
2021-08-31 12:19 c_schmitz Sync to Zoho Project => |Yes|
2021-09-01 16:32 ollehar Changeset attached => LimeSurvey master c27613ff
2021-09-01 16:32 ollehar Note Added: 66264
2021-09-01 16:32 ollehar Resolution open => fixed
2021-09-01 16:32 ollehar Note Added: 66265
2021-09-01 16:33 ollehar Status assigned => ready for testing
2021-09-01 16:45 nooblag Note Added: 66267
2021-09-01 16:50 ollehar Status ready for testing => resolved
2021-09-01 17:59 zufolo441 Note Added: 66270
2021-09-06 07:02 YannCr Note Added: 66328
2021-09-06 07:02 YannCr Bug heat 34 => 36
2021-09-06 10:28 ollehar Note Added: 66338
2021-09-06 10:31 YannCr Note Added: 66339
2021-09-06 10:59 c_schmitz Status resolved => closed