Menu

#1505 Copy as SQL INSERT-VALUES, table name should be qualified with schema in PostgreSQL

SQuirreL
closed-fixed
nobody
Postgresql (3)
medium
2022-06-28
2022-06-23
Yurx
No

Presently "Copy as SQL INSERT-VALUES statement" (ran on selection in table content tab) produces a non-runnable SQL if application table schema is not listed in search_path.

Most application I know do not put their tables into public schema; it is a widely agreed to be a poor design choice. They create their own, often multiple, schemes. Also most applications to not require patching search_path in the server config to include their schemes in it in order to use the application.

While "Copy as SQL INSERT-VALUES statement" feature is still helpful, it requires manual adjustment and if a developer is not careful (I know this is a bogus argument) may result in rogue inserted rows.

Conceptually it is never wrong to use qualified table names, however for some databases (specifically PostgreSQL) using non-qualified table names almost always produces non-runnable SQL when the table is not in public or pg_catalog schema.

The same applies to some other "Copy as SQL" actions used on the table content tab.

Discussion

  • Gerd Wagner

    Gerd Wagner - 2022-06-28
    1. Make sure schema qualifying is configured to meet your needs. See menu File --> Global Preferences --> tab SQL Scripts
    2. The PostgreSQL JDBC drivers I tried do not provide correct schema information in an SQL's ResultSetMetaData. This can be seen at the Meta data tab of an SQL result. If wasn't for this driver problem schema qualifying would already work with the current version.
    3. An improved/fixed version of schema qualifying can in snapshot-20220628_2240 that was just released, see https://sourceforge.net/projects/squirrel-sql/files/3-snapshots/snapshot-20220628_2240/
      This snapshot should fix the problem for you.
     
  • Gerd Wagner

    Gerd Wagner - 2022-06-28
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB