SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-438
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Brad L. Miller
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Incorrect sql in SqlServerDialect.sqlTableExists() method

Created: 24/Jul/07 05:45 PM   Updated: 26/Jul/07 08:07 AM
Component/s: Compass::Core
Affects Version/s: 1.2 M2
Fix Version/s: 1.2 M3

Environment: running on windows xp with ms sqlserver 2005 jdbc drivers


 Description  « Hide
The SqlServerDialog.sqlTableExists method uses the following sql:

sb.append("select table_name from INFORMATION_SCHEMA.Tables where lower(table_name) = ?");

which give following exception:
org.apache.lucene.store.jdbc.JdbcStoreException: Failed to execute sql [select table_name from INFORMATION_SCHEMA.Tables where lower(table_name) = ?]; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'INFORMATION_SCHEMA.Tables'

Instead, use upper-case 'TABLES' instead of 'Tables':
sb.append("select table_name from INFORMATION_SCHEMA.TABLES where lower(table_name) = ?");

Running this from interactive sql query ui worked; have not tested with SqlServerDialect itself.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 25/Jul/07 04:32 AM
Strange, as it worked before. I have committed the change, can you please verify this with 1.2 M3 SNAPSHOT?

Brad L. Miller added a comment - 26/Jul/07 07:07 AM
Turns out our DB admin had set up SqlServer to be case-sensitive, which is not the default (so the existing query probably works for most installations, just not those that have case-sensitivity turned on). However, should still change the query to use 'TABLES' so that it works regardless of whether SqlServer case-sensitivity is turned on.

Brad L. Miller added a comment - 26/Jul/07 08:07 AM
Verified that the new query now works in 1.2 M3 SNAPSHOT - Thanks!