forked from duckdb/duckdb-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattach_comments.test
More file actions
49 lines (37 loc) · 1.38 KB
/
Copy pathattach_comments.test
File metadata and controls
49 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# name: test/sql/storage/attach_comments.test
# description: Test that Postgres table and column comments propagate through DuckDB metadata
# group: [storage]
# group [storage]
require postgres_scanner
require-env POSTGRES_TEST_DATABASE_AVAILABLE
# Attach the Postgres database
statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES);
# Clean up from any previous runs
statement ok
CALL postgres_execute('s', 'DROP TABLE IF EXISTS comment_test');
# Create the test table in Postgres
statement ok
CALL postgres_execute('s', 'CREATE TABLE comment_test (name TEXT, value INTEGER)');
# Set table comment via Postgres
statement ok
CALL postgres_execute('s', $$COMMENT ON TABLE comment_test IS 'this is a table comment'$$);
# Set column comment via Postgres
statement ok
CALL postgres_execute('s', $$COMMENT ON COLUMN comment_test.name IS 'this is a column comment'$$);
# Clear DuckDB's metadata cache so fresh comments are loaded
statement ok
CALL pg_clear_cache();
# Verify the table comment appears in duckdb_tables()
query I
SELECT comment FROM duckdb_tables() WHERE table_name = 'comment_test';
----
this is a table comment
# Verify the column comment appears in duckdb_columns()
query I
SELECT comment FROM duckdb_columns() WHERE table_name = 'comment_test' AND column_name = 'name';
----
this is a column comment
# Cleanup
statement ok
CALL postgres_execute('s', 'DROP TABLE comment_test');