fix: address review findings on SQL query block PR

- Remove unnecessary pool_pre_ping/pool_recycle (engine disposed per-query)
- Fix _extract_keyword_tokens docstring to match implementation
- Move DATABASE enum entry to alphabetical position in ProviderName
- Add database entry to frontend providerIcons map
- Revert no-op string-literal extraction in API key modals
- Revert unused _provider param in getCredentialTypeLabel
This commit is contained in:
Zamil Majdy
2026-03-27 01:08:25 +07:00
parent 5b8daf5d4c
commit b655b30aeb
7 changed files with 19 additions and 37 deletions

View File

@@ -153,10 +153,11 @@ def _sanitize_error(
def _extract_keyword_tokens(parsed: sqlparse.sql.Statement) -> list[str]:
"""Extract top-level keyword tokens from a parsed SQL statement.
"""Extract keyword tokens from a parsed SQL statement.
Walks the token tree and collects Keyword and DML tokens, skipping
tokens that are inside string literals, identifiers, or parenthesized groups.
Uses sqlparse token type classification to collect Keyword/DML/DDL/DCL
tokens. String literals and identifiers have different token types, so
they are naturally excluded from the result.
"""
keywords: list[str] = []
for token in parsed.flatten():
@@ -421,8 +422,6 @@ class SQLQueryBlock(Block):
engine = create_engine(
connection_string,
connect_args=connect_args,
pool_pre_ping=True,
pool_recycle=300,
)
try:
with engine.connect() as conn:

View File

@@ -15,6 +15,7 @@ class ProviderName(str, Enum):
ANTHROPIC = "anthropic"
APOLLO = "apollo"
COMPASS = "compass"
DATABASE = "database"
DISCORD = "discord"
D_ID = "d_id"
E2B = "e2b"
@@ -40,7 +41,6 @@ class ProviderName(str, Enum):
OPENWEATHERMAP = "openweathermap"
OPEN_ROUTER = "open_router"
PINECONE = "pinecone"
DATABASE = "database"
REDDIT = "reddit"
REPLICATE = "replicate"
REVID = "revid"

View File

@@ -41,15 +41,9 @@ export function APIKeyCredentialsModal({
return null;
}
const dialogTitle = `Add new API key for ${providerName ?? ""}`;
const secretLabel = "API Key";
const namePlaceholder = "Enter a name for this API Key...";
const secretPlaceholder = "Enter API Key...";
const submitLabel = "Add API Key";
return (
<Dialog
title={dialogTitle}
title={`Add new API key for ${providerName ?? ""}`}
controlled={{
isOpen: open,
set: (isOpen) => {
@@ -79,7 +73,7 @@ export function APIKeyCredentialsModal({
id="title"
label="Name"
type="text"
placeholder={namePlaceholder}
placeholder="Enter a name for this API Key..."
{...field}
/>
)}
@@ -91,9 +85,9 @@ export function APIKeyCredentialsModal({
<>
<Input
id="apiKey"
label={secretLabel}
label="API Key"
type="password"
placeholder={secretPlaceholder}
placeholder="Enter API Key..."
hint={
schema.credentials_scopes ? (
<FormDescription>
@@ -151,7 +145,7 @@ export function APIKeyCredentialsModal({
loading={isSubmitting}
disabled={isSubmitting}
>
{submitLabel}
Add API Key
</Button>
</form>
</Form>

View File

@@ -123,7 +123,7 @@ export function CredentialRow({
</Text>
{isRealCredentialType && (
<span className="shrink-0 rounded bg-zinc-100 px-1.5 py-0.5 text-[0.625rem] font-medium leading-tight text-zinc-500">
{getCredentialTypeLabel(credType, provider)}
{getCredentialTypeLabel(credType)}
</span>
)}
</div>

View File

@@ -76,7 +76,7 @@ export function CredentialTypeSelector({
className="inline-flex items-center gap-1.5"
>
<Icon size={16} />
{getCredentialTypeLabel(type, provider)}
{getCredentialTypeLabel(type)}
</TabsLineTrigger>
);
})}
@@ -181,11 +181,6 @@ function APIKeyTabContent({
onSubmit,
} = useAPIKeyCredentialsModal({ schema, siblingInputs, onCredentialsCreate });
const secretLabel = "API Key";
const namePlaceholder = "Enter a name for this API Key...";
const secretPlaceholder = "Enter API Key...";
const submitLabel = "Add API Key";
if (!supportsApiKey && !isLoading) {
return null;
}
@@ -220,7 +215,7 @@ function APIKeyTabContent({
id="title"
label="Name"
type="text"
placeholder={namePlaceholder}
placeholder="Enter a name for this API Key..."
{...field}
/>
)}
@@ -231,9 +226,9 @@ function APIKeyTabContent({
render={({ field }) => (
<Input
id="apiKey"
label={secretLabel}
label="API Key"
type="password"
placeholder={secretPlaceholder}
placeholder="Enter API Key..."
hint={
schema.credentials_scopes ? (
<FormDescription>
@@ -273,7 +268,7 @@ function APIKeyTabContent({
loading={isSubmitting}
disabled={isSubmitting}
>
{submitLabel}
Add API Key
</Button>
</form>
</Form>

View File

@@ -91,11 +91,7 @@ export function CredentialsSelect({
{credentials.map((credential) => (
<option key={credential.id} value={credential.id}>
{getCredentialDisplayName(credential, displayName)} (
{getCredentialTypeLabel(
credential.type as CredentialsType,
provider,
)}
)
{getCredentialTypeLabel(credential.type as CredentialsType)})
</option>
))}
</select>

View File

@@ -18,6 +18,7 @@ export const providerIcons: Partial<
aiml_api: fallbackIcon,
anthropic: fallbackIcon,
apollo: fallbackIcon,
database: fallbackIcon,
e2b: fallbackIcon,
github: FaGithub,
google: FaGoogle,
@@ -104,10 +105,7 @@ const CREDENTIAL_TYPE_LABELS: Record<CredentialsType, string> = {
host_scoped: "Headers",
};
export function getCredentialTypeLabel(
type: CredentialsType,
_provider?: string,
): string {
export function getCredentialTypeLabel(type: CredentialsType): string {
return CREDENTIAL_TYPE_LABELS[type] ?? type;
}