Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incontinency whit Postgres Schemas with double qutes #1680

Open
exitxhu opened this issue May 7, 2024 · 0 comments
Open

Incontinency whit Postgres Schemas with double qutes #1680

exitxhu opened this issue May 7, 2024 · 0 comments

Comments

@exitxhu
Copy link
Contributor

exitxhu commented May 7, 2024

hi
I have some schemas " like this : "some"
and I cannot rename them

the problem is it won't get the column names so the Create query for destination (in my case click house) won't generate correctly

see the body of these two API calls, first one is captured when calls from the panel(removed extra fields as they are not necessary):

{
"peerName": "pg",
"schemaName": "some",
"tableName": "ssmm"
}
it will return an empty list of columns

but this body that I recreate manually fetches the columns perfectly:

{
"peerName": "pg",
"schemaName": ""some"",
"tableName": "ssmm"
}

I looked around and in "api/peers/schemas" (file) catches Schemas with this table:
pg_namespace which does not preserve the double quotations!
but when selecting columns table pg_class is used which double quotation is preserved so the condition
relnamespace::regnamespace::text ='some' won't work.
I may suggest the fix to add this join to the GetColumns script and change the condition likewise so the problem will be solved.
SELECT
attname AS column_name,
format_type(atttypid, atttypmod) AS data_type,
CASE
WHEN attnum = ANY(conkey) THEN true
ELSE false
END AS is_primary_key
FROM
pg_attribute
JOIN
pg_class ON pg_attribute.attrelid = pg_class.oid
JOIN
pg_namespace on pg_class.relnamespace = pg_namespace.oid
LEFT JOIN
pg_constraint ON pg_attribute.attrelid = pg_constraint.conrelid
AND pg_attribute.attnum = ANY(pg_constraint.conkey)
WHERE
pg_namespace.nspname = $1
AND
relname = $2
AND pg_attribute.attnum > 0
AND NOT attisdropped
ORDER BY
attnum

this way the output of GetSchemas could be directly used as GetColumns input.
I consider change the GetSchemas script to get schemas from pg_class but this way empty schemas won't show up and I did not know a better place to see them.

iskakaushik pushed a commit that referenced this issue May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant