# \[BUG-14268\] Comment in query causes "index is out of range" error

**URL:** <https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009>\
**Category:** Ignition\
**Tags:** namedqueries\
**Created:** [June 21, 2019, 2:22pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009 "2019-06-21T14:22:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 2:22pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/1 "2019-06-21T14:22:22Z")

</div>

I was trying to comment out a line in a query to try something different, and found that commenting this line causes an "index is out of range" error. Here is the query that causes the error:

```sql
--SELECT TOP(:limit*(SELECT COUNT(DISTINCT(stop_history.first_fault_path)) FROM stop_history))
SELECT TOP(:limit)
	stops.first_fault_path	AS path,
	stops.first_fault AS fault,
	COUNT(*) AS count
FROM stop_history AS stops
WHERE stops.downtime_start BETWEEN :startDate and :endDate
		AND (stops.first_fault NOT IN {hiddenFaults})
GROUP BY	stops.first_fault_path,
			stops.first_fault
ORDER BY	count DESC

```

No matter where the commented line is in the query, the error occurs.

The exact error I see is:

> com.microsoft.sqlserver.jdbc.SQLServerException: The index 4 is out of range.

I tried reproducing this error in SQL Server Management Studio and it wasn't reproducible there.

Removing the commented line fixes the issue.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 2:31pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/2 "2019-06-21T14:31:10Z")

</div>

What version of the SQLServer JDBC Driver do you have installed? You might try upgrading that and seeing if it changes anything.

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 2:46pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/3 "2019-06-21T14:46:11Z")

</div>

It appears it’s version 4.2, if I’m reading things properly.

I’m trying to upgrade it but each time I’m getting “Field ‘Classname’ must be unique” in the Database Drivers & Settings setting for the Microsoft SQLServer JDBC Driver driver.

I’m following the instructions in the docs to upgrade, is there something I’m missing?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 2:48pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/4 "2019-06-21T14:48:48Z")

</div>

You’re just editing the existing entry and seeing it when saving?

What version of Ignition is this?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 2:49pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/5 "2019-06-21T14:49:27Z")

</div>

Yes.

I’m running one of the nightlies. Sorry if I should’ve put this in the Ignition 8 category.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 2:51pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/6 "2019-06-21T14:51:17Z")

</div>

Hmm. Let me ask around… might be a bug 😕

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [June 21, 2019, 3:08pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/7 "2019-06-21T15:08:04Z")

</div>

Are you supplying the same name for the driver at this point as you supplied for the older version?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 3:09pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/8 "2019-06-21T15:09:07Z")

</div>

Yes, I’m just uploading a new JAR file for the upgraded driver.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 3:09pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/9 "2019-06-21T15:09:32Z")

</div>

Can you send us a gateway backup?

---

<div class="post-metadata">

**Author:** ![mcarritt1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mcarritt1/32/4262_2.png) [@mcarritt1](https://forum.inductiveautomation.com/u/mcarritt1)\
**Post date:** [June 21, 2019, 3:12pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/10 "2019-06-21T15:12:54Z")

</div>

I think you need a space after the two hyphens in the comment. so “-- Select…”

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 3:14pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/11 "2019-06-21T15:14:57Z")

</div>

> [@Kevin.Herron](#):
>
> Can you send us a gateway backup?

The file is too large for the forum, so I hosted it on my Google Drive for the time being. (removed)

> [@mcarritt1](#):
>
> I think you need a space after the two hyphens in the comment. so “-- Select…”

That didn't fix the issue.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 3:16pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/12 "2019-06-21T15:16:55Z")

</div>

Ok, I downloaded it and removed the link.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 3:20pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/13 "2019-06-21T15:20:07Z")

</div>

Alright… your internal DB has duplicate entries for the SQLServer JDBC Driver and for Postgres JDBC Driver.

There’s a unique constraint on the classname column now (always?) so when you try to save it’s failing…

Not sure how you got into this state. Do you see multiple entries on the driver page in the gateway?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 3:22pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/14 "2019-06-21T15:22:12Z")

</div>

This is what my drivers page shows:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/5df6f81c22f7fee2f9cfb071d1c8522d0e2e1153.png)

I’m not sure either. For context, my organization is testing out Ignition and actively trying it out for new projects, and this gateway was set up a few months before I started working here. I backed up that one and created a local copy, and haven’t changed any settings regarding database drivers since I started using it.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 3:22pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/15 "2019-06-21T15:22:44Z")

</div>

Delete one of each of the extra driver entries and try editing again after that…

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 3:25pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/16 "2019-06-21T15:25:47Z")

</div>

I deleted all but “Microsoft SQLServer JDBC Driver” and was able to upgrade with a new .jar.

I tried upgrading the Driver to version 7.2 and the query error issue with the comment persists.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 21, 2019, 3:27pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/17 "2019-06-21T15:27:29Z")

</div>

> [@md.szyman](#):
>
> I tried upgrading the Driver to version 7.2 and the query error issue with the comment persists.

Well that was a lot of work for nothing! I'll just make a bug ticket for this because I really don't know if it should work or whether Ignition or the JDBC Driver is responsible.

Where are you defining and running this query?

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 3:28pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/18 "2019-06-21T15:28:25Z")

</div>

> [@Kevin.Herron](#):
>
> Well that was a lot of work for nothing! I’ll just make a bug ticket for this because I really don’t know if it should work or whether Ignition or the JDBC Driver is responsible.

Haha, oh well, it happens!

> [@Kevin.Herron](#):
>
> Where are you defining and running this query?

In a Named Query, right now I'm running it via the Testing tab and the error also happens in property bindings that call the query.

---

<div class="post-metadata">

**Author:** ![md.szyman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/md.szyman/32/9240_2.png) [@md.szyman](https://forum.inductiveautomation.com/u/md.szyman)\
**Post date:** [June 21, 2019, 4:38pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/19 "2019-06-21T16:38:31Z")

</div>

I think I found out what causes the bug EXACTLY. It seems to be having a parameter in a comment.

Value type parameters in comments cause the error, QueryString parameters do not. Having a string that looks like a parameter but isn’t declared as one in a comment does not cause the error.

---

<div class="post-metadata">

**Author:** ![jsorlie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jsorlie/32/3645_2.png) [@jsorlie](https://forum.inductiveautomation.com/u/jsorlie)\
**Post date:** [August 7, 2019, 11:20pm UTC](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009/20 "2019-08-07T23:20:27Z")

</div>

re: seems to be having a parameter in a comment.

I’ve noticed this in NamedQuery’s myself. Oracle driver seems to be particularly fussy.

[Next page](https://forum.inductiveautomation.com/t/bug-14268-comment-in-query-causes-index-is-out-of-range-error/26009.md?page=2)
