-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improvement: better sql completions #3930
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
313452e
to
cf917ac
Compare
|
||
export const ItemSubtext: React.FC<{ content: string }> = ({ content }) => { | ||
return ( | ||
<span className="text-xs text-black bg-gray-200 rounded px-1"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bg-gray-200
won't support dark mode, and i think it could be slightly lighter
maybe bg-[var(--slate-8] text-[var(--slate-9]
?
@@ -361,6 +378,8 @@ const SchemaItem: React.FC<{ | |||
<span className={cn(isSelected && isExpanded && "font-semibold")}> | |||
{schema.name} | |||
</span> | |||
{/* Do we want this? They could change the default by executing USE schema.. */} | |||
{isDefaultSchema && <ItemSubtext content="default" />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can remove for now? we can look if other SQL apps do this:
e.g. jetbrains or dbbeaver, if you can drum up screenshots (but don't need to spend too much time)
tables[table.name] = columns; | ||
|
||
if (isDefaultDb) { | ||
const schemaMap = (mapping[schema.name] ?? {}) as Record< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can put the typecheck on the LHS const schemaMap: Record<string, string[]>;
. this might be safer than casting
database_name: Optional[str] = None | ||
dialect_queries = { | ||
"postgresql": "SELECT current_database()", | ||
"mssql": "SELECT DB_NAME()", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess sql alchemy or the inspect class doesn't have native support for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's true, the inspector is schema oriented. Supporting multi-database inspection is a little bit tricky, even though you can execute queries from another db
cacheConfig = { | ||
dialect: guessDialect(connection), | ||
schema: combinedSchema, | ||
schema: mapping, | ||
defaultSchema: connection.default_schema ?? undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you verify that the table from the default schema does get bubbled up? im not sure if this include the db.schema
, but that might be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap it does! Will attach a screenshot/vid
📝 Summary
Follow up from #3898 , add the shortest and correct completions to AI & sql completions panel.

Adds default schema & db introspection + update API.
🔍 Description of Changes
schema_name.table_name
, for diff databases, usedb_name.schema_name.table_name
Maybe:
📋 Checklist
📜 Reviewers
@akshayka OR @mscolnick