@@ -27,6 +27,23 @@ export function createCatalogDatabaseAndTableCandidates(
2727 const qualificationLevel = lastToken . split ( '.' ) . length - 1
2828
2929 const qualifiedEntities = tables . flatMap ( ( table ) => {
30+ const results : Identifier [ ] = [ ]
31+
32+ // When user types without dots (qualificationLevel === 0), always include
33+ // a table name suggestion. This allows typing "act" to match "actor" even
34+ // if the table has a database (e.g., "squeal.actor").
35+ if ( qualificationLevel === 0 ) {
36+ const tableIdentifier = new Identifier (
37+ lastToken ,
38+ table . tableName ,
39+ '' ,
40+ ICONS . TABLE ,
41+ onFromClause ? 'FROM' : 'OTHERS'
42+ )
43+ results . push ( tableIdentifier )
44+ }
45+
46+ // Also add qualified suggestions (catalog/database) based on qualification level
3047 let qualificationNeeded = 0
3148 if ( table . catalog ) {
3249 qualificationNeeded ++
@@ -37,14 +54,18 @@ export function createCatalogDatabaseAndTableCandidates(
3754 const qualificationLevelNeeded = qualificationNeeded - qualificationLevel
3855 switch ( qualificationLevelNeeded ) {
3956 case 0 : {
40- const tableIdentifier = new Identifier (
41- lastToken ,
42- getFullyQualifiedTableName ( table ) ,
43- '' ,
44- ICONS . TABLE ,
45- onFromClause ? 'FROM' : 'OTHERS'
46- )
47- return [ tableIdentifier ]
57+ // Only add fully qualified name if we haven't already added just the table name
58+ if ( qualificationLevel > 0 ) {
59+ const tableIdentifier = new Identifier (
60+ lastToken ,
61+ getFullyQualifiedTableName ( table ) ,
62+ '' ,
63+ ICONS . TABLE ,
64+ onFromClause ? 'FROM' : 'OTHERS'
65+ )
66+ results . push ( tableIdentifier )
67+ }
68+ break
4869 }
4970 case 1 : {
5071 const qualifiedDatabaseName =
@@ -60,7 +81,7 @@ export function createCatalogDatabaseAndTableCandidates(
6081 ICONS . DATABASE ,
6182 onFromClause ? 'FROM' : 'OTHERS'
6283 )
63- return [ databaseIdentifier ]
84+ results . push ( databaseIdentifier )
6485 }
6586 break
6687 }
@@ -73,11 +94,11 @@ export function createCatalogDatabaseAndTableCandidates(
7394 ICONS . CATALOG ,
7495 onFromClause ? 'FROM' : 'OTHERS'
7596 )
76- return [ catalogIdentifier ]
97+ results . push ( catalogIdentifier )
7798 }
7899 break
79100 }
80- return [ ]
101+ return results
81102 } )
82103
83104 return qualifiedEntities
0 commit comments