DataflareApp / Dataflare

Simple, easy-to-use database manager
https://dataflare.app
149 stars 2 forks source link

[BUG] MS SQL Token error: 'Invalid object name 'information_schema.schemata'.' #35

Closed kodaicoder closed 10 months ago

kodaicoder commented 11 months ago

Describe the bug

On testing connection is successful image

image

but after press connect button I got error Token error: 'Invalid object name 'information_schema.schemata'.' on server SERVER_NAME executing on line 2 (code: 208, state: 1, class: 16);

image

btw if I connecting with SSMS to remote server is still working

Platform and Database

Windows 11 
version 23H2
OS Build 22635.2915

Microsoft SQL Server Standard Edition (64-bit)
Version 13.0.1601 RTM
wyhaya commented 11 months ago

@kodaicoder Thanks.

Dataflare gets the schema and table through this SQL, what is certain is that the problem comes from this piece of SQL, maybe a compatibility issue, I'll look into it.

SELECT
    c.schema_name,
    t.table_name
FROM
    information_schema.schemata as c
    LEFT JOIN information_schema.tables as t ON
        t.TABLE_TYPE = 'BASE TABLE' AND
        t.table_schema = c.schema_name
ORDER BY c.schema_name, t.table_name;
kodaicoder commented 10 months ago

I has trying change the code you mention into all upper case like this

SELECT
    c.SCHEMA_NAME,
    t.TABLE_NAME
FROM
    INFORMATION_SCHEMA.SCHEMATA as c
    LEFT JOIN INFORMATION_SCHEMA.TABLES as t ON
        t.TABLE_TYPE = 'BASE TABLE' AND
        t.TABLE_SCHEMA = c.SCHEMA_NAME
ORDER BY c.SCHEMA_NAME, t.TABLE_NAME;

and it working good BTW I don't know if it will affected and cause error on any other MSSQL version or other SQL tools

wqweto commented 10 months ago

I have the same problem on a SQL Server host with case-sensitive collation.

INFORMATION_SCHEMA views (and columns) are all UPPER-CASE named by design as described in every RDBMS documentation and not surprisingly writing these queries in lower-case can lead to compatibility problems.

wyhaya commented 10 months ago

@kodaicoder @wqweto We have just released version 0.6, and this error has been fixed. Can you please try again?

wqweto commented 10 months ago

It does work ok now!

Btw, on browsing tables the arrow in the cells for following foreign key is a nice touch :-))