Menu

#33 Rp

2.1.4
closed
nobody
None
1
2016-02-16
2016-02-10
adam brin
No

(v2.1.2) Database.getTable(String table) will throw an exception if the table is a linked table. We'd like to avoid the exception, but Database.isLinkedTable(Table table) requires the table. We don't see a method for iterating over the tables. It'd be useful for the (a) API to allow either for an easy way to get a table so we can as isLinked() or (b) for isLinked() to allow for a String.

Discussion

  • adam brin

    adam brin - 2016-02-10

    note you can get Tables from the Database.iterator() method. It'd still be nice (though minor) to be able to lookup linked tables via string.

     
  • James Ahlborn

    James Ahlborn - 2016-02-11

    it's not entirely clear to me what you are trying to do. are you trying to read tables, but getting exceptions because the linked database isn't available?

    if you want to just work with non-linked tables, you can use the advanced iterable support. e.g. to iterate over all non-linked, non-system tables:

    for(Table t : db.newIterable().setIncludeLinkedTables(false)) {
      // ... handle table here...
    }
    

    you can get linked tables via String. Database.getTable(String) works for a linked table as long as the linked database is available.

     

    Last edit: James Ahlborn 2016-02-11
  • adam brin

    adam brin - 2016-02-11

    Hi James,
    Thanks for the suggestion. What I'm trying to do is for a set of tables find out which of them are linked tables and which ones aren't without getting an Exception. I didn't know about the .newIterable(). I guess my confusion (and hence the ticket) is that given a "tableName" there's no way to simply find out if it's linked without the potential of throwing an exception. This is all beacuse I don't have access to the linked table (which is fine for our use-cases, we just need to know that they are linked).

    thanks,

     
    • James Ahlborn

      James Ahlborn - 2016-02-11

      and the newIterable approach doesn't work for you (simply looking at non-linked tables)? how are you getting the table name in the first place?

       
  • adam brin

    adam brin - 2016-02-11

    newIterable did work for us. We're getting tableNames via "getDatabase().getTableNames()." We're using older code that goes back to v1 APIs, so, it may also be worth my going back and looking at a better implementation in general. But, the goal is to warn the user that there are linked tables, which requires the sets of non-linked and linked tables.

    P.s. I'm quite happy if you want to close this as "won't fix." thanks.

     

    Last edit: adam brin 2016-02-11
    • James Ahlborn

      James Ahlborn - 2016-02-11

      i'm contemplating a method which could just give you some table info given a name (e.g. the type of table, maybe some other info).

       
  • adam brin

    adam brin - 2016-02-11

    I could see the benefit in that. Thanks for your help & thoughts.

     
  • James Ahlborn

    James Ahlborn - 2016-02-11

    Ticket moved from /p/jackcess/bugs/135/

     
  • James Ahlborn

    James Ahlborn - 2016-02-16
    • Group: Unassigned --> Unnassigned
     
  • James Ahlborn

    James Ahlborn - 2016-02-16

    Added Database.getTableMetaData(String name) which can retrieve basic meta data about a Table without attempting to open it.

    Fixed in trunk, will be in the 2.1.4 release.

     
  • James Ahlborn

    James Ahlborn - 2016-02-16
    • summary: Database Table API inconsistency causing exceptions --> Rp
    • status: open --> closed
    • Group: Unnassigned --> 2.1.4
     

Log in to post a comment.

MongoDB Logo MongoDB