fix(contrib/drivers/pgsql): ensure fields queries are scoped to the specified schema#4491
fix(contrib/drivers/pgsql): ensure fields queries are scoped to the specified schema#4491qinyuguang wants to merge 1 commit intogogf:masterfrom
Conversation
|
This bug has a direct impact on our database generation tools, specifically when using When Consequently, when this generated dao is used for gdb |
|
@qinyuguang Hello, the CI failed, you might also update the source codes of the CLI. |
5b4796c to
99c75f8
Compare
|
I see. The "schema" in the parameters is not the actual schema in PostgreSQL. I'll replace it with "namespace" to make the distinction. |
|
和这个pr有没有关联?#4375 |
对是这个问题,用regclass很方便,我关掉这个PR |
This PR addresses an issue where database metadata queries, specifically those retrieving table and column information using PostgreSQL catalog views (
pg_attribute,pg_class, etc.), were not correctly scoped by schema.Problem:
When multiple schemas contain tables with the same name (e.g.,
schema1.some_tableandpublic.some_table), the previous query would return metadata for all tables, leading to inaccurate or duplicate results.Solution:
The query logic has been updated to explicitly join with
pg_namespaceand filter results based on the schema name (nspname).pg_classwithpg_namespaceviac.relnamespace = n.oid.WHEREclause condition:n.nspname = 'public'(or the target schema name).information_schema.columnsis also filtered byic.table_schema = n.nspnamefor accurate data retrieval (e.g.,default_value,length).This ensures that the metadata query correctly retrieves information only for the table within the intended schema.