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

Please add PostgreSQL enum support #26

Open
wangyuehong opened this issue Nov 10, 2023 · 1 comment
Open

Please add PostgreSQL enum support #26

wangyuehong opened this issue Nov 10, 2023 · 1 comment

Comments

@wangyuehong
Copy link

sql to create enum in pg database.

CREATE TYPE aenum AS ENUM ('a', 'b', 'c');

aenum should be shown in object tree under TYPE.

@gerdwagner
Copy link
Member

gerdwagner commented Nov 18, 2023

This is a problem of the JDBC driver: Though Connection.getMetaData().getTableTypes() returns the table type "TYPE" it doesn't return enums from Connection.getMetaData().getTables(...). The test program below illustrates the problem.
Please consult your JDBC driver or database vendor about the issue.

public class PgTypeTest
{
   public static void main(String[] args) throws ClassNotFoundException, SQLException
   {
      Class.forName("org.postgresql.Driver");

      Connection con = DriverManager.getConnection("<yourDbUrl>", "yourUser", "yourPassword");

      ResultSet tableTypes = con.getMetaData().getTableTypes();

      System.out.println("Available table types:");
      while (tableTypes.next())
      {
         System.out.println(tableTypes.getString("TABLE_TYPE"));
      }

      //ResultSet types = con.getMetaData().getTables(null, null, null, null);
      ResultSet types = con.getMetaData().getTables(null, null, null, new String[]{"TYPE"});

      System.out.println("Available types:");
      while (types.next())
      {
         // Will not get here because types is empty
         System.out.println(types.getString("TABLE_NAME"));
      }
   }
}

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

2 participants