Page 1 of 1

Identifier case issue

Posted: Mon 29 Dec 2014 02:27
by sebeto
Hi,

I use SQL Complete on case sensitive databases. As the column aliases become column titles in our software interface, I have to deal daily with queries such as:

Code: Select all

select sc.NAME as [Name]
	,sc.[DESCRIPTION] as [Description]
	,sc.DATATYPE as [Data Type]
	,sc.SCUNITS as [Units]
from SAMPLECODE as sc
order by sc.NAME
The problem is that when I run code formatting on this with the identifier case set to "As in the database", it becomes:

Code: Select all

select sc.Name as [Name]
	,sc.[Description] as [Description]
	,sc.DATATYPE as [Data Type]
	,sc.SCUNITS as [Units]
from SAMPLECODE as sc
order by sc.Name
The query then fails as it should be sc.NAME. Even without the aliasing of columns, SQL Complete gets confused if another table in the database has the same column name in a different case. You can view the issue with this kind of query:

Code: Select all

select sc.NAME
	,sc.[DESCRIPTION]
	,sc.DATATYPE
	,sc.SCUNITS
from SAMPLECODE as sc
	join (
	values ('A name')
	) as vals (name)
	on vals.name = sc.NAME
order by sc.NAME
which gets formatted as:

Code: Select all

select sc.name
	,sc.[DESCRIPTION]
	,sc.DATATYPE
	,sc.SCUNITS
from SAMPLECODE as sc
	join (
	values ('A name')
	) as vals (name)
		on vals.name = sc.name
order by sc.name
It has become quite an issue lately as I need to run queries on databases with different cases for the column names, so I can't use SQL formatting on these queries. Am I doing something wrong?

My setup is as follows, "Identifier Case" is set to "As in the database":
Image

Re: Identifier case issue

Posted: Tue 30 Dec 2014 11:06
by alexa
We will fix this issue in one of the next product builds and will notify you once it's available for downloading.

Re: Identifier case issue

Posted: Wed 31 Dec 2014 02:02
by sebeto
Thank you Alexa, and have a very happy new year!

Re: Identifier case issue

Posted: Wed 31 Dec 2014 13:56
by alexa
A Happy New Year to you too! Please let us know if any questions arise.

Re: Identifier case issue

Posted: Tue 17 Feb 2015 13:18
by alexa
After taking a closer look into this issue, it follows that dbForge searches the original definition by the first match of the name. We recommend you to use the aliases differring from the column names.

In fact, we could change such a behavior and make dbForge to search first in a database and only then in a script, however, it will cause the alternative scenario when aliases will be switching to the column case.