θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const DEFAULT_CONFIG = {
host: null,
port: null,
database: null,
schema: null,
encrypt: false,
};

Expand Down Expand Up @@ -269,6 +270,23 @@ export default function NewSQLConnection({
/>
</div>

{engine === "postgresql" && (
<div className="flex flex-col">
<label className="block mb-2 text-sm font-medium text-white">
Schema (optional)
</label>
<input
type="text"
name="schema"
className="border-none bg-theme-settings-input-bg w-full text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="public (default schema if not specified)"
required={false}
autoComplete="off"
spellCheck={false}
/>
</div>
)}

{engine === "sql-server" && (
<div className="flex items-center justify-between">
<label className="relative inline-flex items-center cursor-pointer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ class PostgresSQLConnector {
constructor(
config = {
connectionString: null,
schema: null,
}
) {
this.connectionString = config.connectionString;
this.schema = config.schema || "public";
this._client = new pgSql.Client({
connectionString: this.connectionString,
});
Expand Down Expand Up @@ -54,10 +56,10 @@ class PostgresSQLConnector {
}

getTablesSql() {
return `SELECT * FROM pg_catalog.pg_tables WHERE schemaname = 'public'`;
return `SELECT * FROM pg_catalog.pg_tables WHERE schemaname = '${this.schema}'`;
}
getTableSchemaSql(table_name) {
return ` select column_name, data_type, character_maximum_length, column_default, is_nullable from INFORMATION_SCHEMA.COLUMNS where table_name = '${table_name}'`;
return ` select column_name, data_type, character_maximum_length, column_default, is_nullable from INFORMATION_SCHEMA.COLUMNS where table_name = '${table_name}' AND table_schema = '${this.schema}'`;
}
}

Expand Down