View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
19072Bug reports_ Unknownpublic2023-09-18 09:10
Reporterdcastro Assigned ToDenisChenu  
PrioritylowSeveritycrash 
Status closedResolutionfixed 
Product Version6.2.x 
Summary19072: CDbException [Microsoft][ODBC Driver 18 for SQL Server]COUNT field incorrect or syntax error. Select Count
Description

I have upgraded the platform from 3.22 to 6.2.1 and now i´m getting an error CDbException when i try to execute this query:

"...
CDbCommand falló al ejecutar la sentencia SQL: SQLSTATE[07002]: [Microsoft][ODBC Driver 18 for SQL Server]COUNT field incorrect or syntax error. The SQL statement executed was: SELECT COUNT(DISTINCT [t].[sid]) FROM [dbo].[lime_surveys] [t] LEFT JOIN lime_surveys_groups parentGroup1 ON = = [dbo].[lime_surveys_languagesettings] [correct_relation_defaultlanguage] ON ([correct_relation_defaultlanguage].[surveyls_language]=[t].[language]) AND ([correct_relation_defaultlanguage].[surveyls_survey_id]=[t].[sid]) LEFT OUTER JOIN [dbo].[lime_users] [owner] ON ([t].[owner_id]=[owner].[uid]) LEFT OUTER JOIN [dbo].[lime_surveys_groups] [surveygroup] ON ([t].[gsid]=[surveygroup].[gsid]) WHERE (:gsid OR :gsid OR :gsid OR :gsid OR :gsid). Bound with :gsid=8
..."
I have tried with other versions of limesurvey and microsoft driver but the result is the same. I have only seen the error in "Select count" statements.

Steps To Reproduce

This error occurs when I make a statement with filter in the survey menu

TagsNo tags attached.
Bug heat10
Complete LimeSurvey version number (& build)6.2.6
I will donate to the project if issue is resolvedNo
BrowserGoogle Chrome
Database type & versionSqlServer 2016
Server OS (if known)
Webserver software & version (if known)
PHP Version8.0.29

Users monitoring this issue

There are no users monitoring this issue.

Activities

ollehar

ollehar

2023-09-07 13:21

administrator   ~76894

We don't really have the resources to debug and fix SQL Server issues, but feel free to apply a pull request with the solution.

DenisChenu

DenisChenu

2023-09-07 16:24

developer   ~76900

What is the DB version in the database when this issue happen ?

DenisChenu

DenisChenu

2023-09-07 16:24

developer   ~76901

WHERE (:gsid OR :gsid OR :gsid OR :gsid OR :gsid). ?

dcastro

dcastro

2023-09-08 08:11

reporter   ~76912

The DBVersion is 614.

Sorry the "where" is not correct, the correct one is:

WHERE (t.gsid=:gsid OR parentGroup2.gsid=:gsid OR parentGroup3.gsid=:gsid OR parentGroup4.gsid=:gsid OR parentGroup5.gsid=:gsid). Bound with :gsid=8

DenisChenu

DenisChenu

2023-09-08 08:54

developer   ~76913

OK : then surely on other SQL version : MS SQL didn't accept one param for multiple value.

dcastro

dcastro

2023-09-08 10:25

reporter   ~76914

But if I run the same request with the ms sql client on the machine, the result is correct.

/opt/mssql-tools18/bin/sqlcmd -S xxxxxxx -U xxxxxxx -P xxxxxx -C -q "SELECT COUNT(DISTINCT [t].[sid]) FROM [dbo].[lime_surveys] [t] LEFT JOIN lime_surveys_groups parentGroup1 ON t.gsid = parentGroup1.gsid LEFT JOIN lime_surveys_groups parentGroup2 ON parentGroup1.parent_id = parentGroup2.gsid LEFT JOIN lime_surveys_groups parentGroup3 ON parentGroup2.parent_id = parentGroup3.gsid LEFT JOIN lime_surveys_groups parentGroup4 ON parentGroup3.parent_id = parentGroup4.gsid LEFT JOIN lime_surveys_groups parentGroup5 ON parentGroup4.parent_id = parentGroup5.gsid LEFT OUTER JOIN [dbo].[lime_surveys_languagesettings] [correct_relation_defaultlanguage] ON ([correct_relation_defaultlanguage].[surveyls_language]=[t].[language]) AND ([correct_relation_defaultlanguage].[surveyls_survey_id]=[t].[sid]) LEFT OUTER JOIN [dbo].[lime_users] [owner] ON ([t].[owner_id]=[owner].[uid]) LEFT OUTER JOIN [dbo].[lime_surveys_groups] [surveygroup] ON ([t].[gsid]=[surveygroup].[gsid]) WHERE (t.gsid=8 OR parentGroup2.gsid=8 OR parentGroup3.gsid=8 OR parentGroup4.gsid=8 OR parentGroup5.gsid=8)"


     41

(1 rows affected)

DenisChenu

DenisChenu

2023-09-08 10:44

developer   ~76915

Yes, but MSSQL didn't accept column1=:value and column2=:value, Bound with :value=8

Need column1=:value1 and column2=:value2, Bound with :value1=8, :value2=8

About

The DBVersion is 614.

This is in version.php; i mean the current DBVersion set in database : lime_settings_global
It's to find where the issue happen on https://github.com/LimeSurvey/LimeSurvey/tree/master/application/helpers/update/updates

dcastro

dcastro

2023-09-08 14:29

reporter   ~76920

The version is 614 attached image with this

DBVersion_limesurvey.jpg (57,892 bytes)   
DBVersion_limesurvey.jpg (57,892 bytes)   
DenisChenu

DenisChenu

2023-09-08 16:11

developer   ~76924

The version is 614 attached image with this

But then : update done until end ?

Then

I have upgraded the platform from 3.22 to 6.2.1 and now i´m getting an error CDbException when i try to execute this query:

What action ? All action ?
If yes : please activate debug mode : manual.limesurvey.org/Debug_mode

and send the HTML produced here.

DenisChenu

DenisChenu

2023-09-08 16:13

developer   ~76925

Got it :)
I propose an untested fix …
You have to test yourself

DenisChenu

DenisChenu

2023-09-08 16:22

developer   ~76926

https://github.com/LimeSurvey/LimeSurvey/pull/3431

DenisChenu

DenisChenu

2023-09-08 16:23

developer   ~76927

@dcastro : please apply the patch and test

dcastro

dcastro

2023-09-11 08:45

reporter   ~76935

I have applied the patch and now everything works. Will this patch be incorporated into the code of the next version?

Thanks.

tibor.pacalat

tibor.pacalat

2023-09-14 15:55

administrator   ~77046

Hi @dcastro, thank you for confirming the fix. Yes, it will be a part of the next version.

DenisChenu

DenisChenu

2023-09-14 16:15

developer   ~77047

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

LimeBot

LimeBot

2023-09-18 09:10

administrator   ~77086

Fixed in Release 6.2.7+230918

Related Changesets

LimeSurvey: master ea588db9

2023-09-14 15:53:56

DenisChenu


Committer: GitHub Details Diff
Fixed issue 19072: CDbException with Microsoft SQL Server (#3431)

Dev: MSSQL didn't allow one param for multiple value
Dev: create 5 different params

Co-authored-by: Denis Chenu <shnoulle@localhost.localdomain>
Affected Issues
19072
mod - application/models/Survey.php Diff File

Issue History

Date Modified Username Field Change
2023-09-07 12:10 dcastro New Issue
2023-09-07 12:39 ollehar Priority none => low
2023-09-07 13:21 ollehar Note Added: 76894
2023-09-07 13:21 ollehar Bug heat 0 => 2
2023-09-07 16:24 DenisChenu Note Added: 76900
2023-09-07 16:24 DenisChenu Bug heat 2 => 4
2023-09-07 16:24 DenisChenu Note Added: 76901
2023-09-08 08:11 dcastro Note Added: 76912
2023-09-08 08:11 dcastro Bug heat 4 => 6
2023-09-08 08:54 DenisChenu Note Added: 76913
2023-09-08 10:25 dcastro Note Added: 76914
2023-09-08 10:44 DenisChenu Note Added: 76915
2023-09-08 14:29 dcastro Note Added: 76920
2023-09-08 14:29 dcastro File Added: DBVersion_limesurvey.jpg
2023-09-08 16:11 DenisChenu Note Added: 76924
2023-09-08 16:13 DenisChenu Assigned To => DenisChenu
2023-09-08 16:13 DenisChenu Status new => assigned
2023-09-08 16:13 DenisChenu Note Added: 76925
2023-09-08 16:22 DenisChenu Assigned To DenisChenu => gabrieljenik
2023-09-08 16:22 DenisChenu Status assigned => ready for code review
2023-09-08 16:22 DenisChenu Note Added: 76926
2023-09-08 16:23 DenisChenu Note Added: 76927
2023-09-11 08:45 dcastro Note Added: 76935
2023-09-14 14:09 gabrieljenik Assigned To gabrieljenik => DenisChenu
2023-09-14 14:09 gabrieljenik Status ready for code review => ready for testing
2023-09-14 15:12 DenisChenu Assigned To DenisChenu => tibor.pacalat
2023-09-14 15:12 DenisChenu Status ready for testing => ready for merge
2023-09-14 15:54 tibor.pacalat Status ready for merge => resolved
2023-09-14 15:54 tibor.pacalat Resolution open => fixed
2023-09-14 15:55 tibor.pacalat Note Added: 77046
2023-09-14 15:55 tibor.pacalat Bug heat 6 => 8
2023-09-14 16:15 DenisChenu Changeset attached => LimeSurvey master ea588db9
2023-09-14 16:15 DenisChenu Note Added: 77047
2023-09-14 16:15 DenisChenu Assigned To tibor.pacalat => DenisChenu
2023-09-18 09:10 LimeBot Note Added: 77086
2023-09-18 09:10 LimeBot Status resolved => closed
2023-09-18 09:10 LimeBot Bug heat 8 => 10