Thanks to visit codestin.com
Credit goes to github.com

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
43 changes: 29 additions & 14 deletions src/common/adbc/adbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,19 +1398,34 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
),
constraints AS (
SELECT
table_catalog,
table_schema,
database_name AS table_catalog,
schema_name AS table_schema,
table_name,
LIST(
{
constraint_name: constraint_name,
constraint_type: constraint_type,
constraint_column_names: []::VARCHAR[],
constraint_column_usage: []::STRUCT(fk_catalog VARCHAR, fk_db_schema VARCHAR, fk_table VARCHAR, fk_column_name VARCHAR)[],
}
) table_constraints
FROM information_schema.table_constraints
GROUP BY table_catalog, table_schema, table_name
LIST({
constraint_name: constraint_name,
constraint_type: constraint_type,
constraint_column_names: constraint_column_names,
constraint_column_usage: list_transform(
referenced_column_names,
lambda name: {
fk_catalog: database_name,
fk_db_schema: schema_name,
fk_table: referenced_table,
fk_column_name: name,
}
)
}) table_constraints
FROM duckdb_constraints()
WHERE
constraint_type NOT IN ('NOT NULL') AND
list_has_any(
constraint_column_names,
list_filter(
constraint_column_names,
lambda name: name LIKE '%s'
)
)
Comment on lines +1421 to +1427
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify this if list_contains() accepts a lambda too.

GROUP BY database_name, schema_name, table_name
),
tables AS (
SELECT
Expand Down Expand Up @@ -1454,8 +1469,8 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
WHERE catalog_name LIKE '%s'
GROUP BY catalog_name
)",
column_name_filter, table_name_filter, table_type_condition,
db_schema_filter, catalog_filter);
column_name_filter, column_name_filter, table_name_filter,
table_type_condition, db_schema_filter, catalog_filter);
break;
default:
SetError(error, "Invalid value of Depth");
Expand Down
Loading
Loading