Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Sergei Kalashnikov <ztarvos@gmail.com>
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH] jdbc: fix primary keys meta retrieval
Date: Mon, 1 Oct 2018 16:04:27 +0300	[thread overview]
Message-ID: <20181001130427.zlugbqlg3madlo7r@tkn_work_nb> (raw)
In-Reply-To: <1537954408-3275-1-git-send-email-ztarvos@gmail.com>

Hi!

Sorry for the late response.

From [1]:

> Retrieves a description of the given table's primary key columns. They are ordered by COLUMN_NAME.

That is strange, but that is. Maybe we should also check the standard.

[1]: https://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getPrimaryKeys(java.lang.String,%20java.lang.String,%20java.lang.String)

Tests are ok for me.

Maybe we also should set some defined behaviour for the case when
'catalog' and 'schema' are given for getPrimaryKeys. I think we should
ignore them and return nulls in TABLE_CAT and TABLE_SCHEM. I think we
should have corresponding test case.

More comment are inline.

WBR, Alexander Turenko.

On Wed, Sep 26, 2018 at 12:33:28PM +0300, Sergei Kalashnikov wrote:
> Fixed parsing primary keys metadata response.
> Updated integration tests.
> 
> Closes #41
> ---
> https://github.com/tarantool/tarantool-java/issues/41
> https://github.com/ztarvos/tarantool-java/commits/gh-41-fix-jdbc-pk-meta
> 
>  .../org/tarantool/jdbc/SQLDatabaseMetadata.java    |  8 +++---
>  .../java/org/tarantool/jdbc/AbstractJdbcIT.java    | 11 ++++----
>  .../org/tarantool/jdbc/JdbcDatabaseMetaDataIT.java | 32 ++++++++++++++++++++--
>  3 files changed, 40 insertions(+), 11 deletions(-)
> 
> diff --git a/src/main/java/org/tarantool/jdbc/SQLDatabaseMetadata.java b/src/main/java/org/tarantool/jdbc/SQLDatabaseMetadata.java
> index e43bcdc..790bbe7 100644
> --- a/src/main/java/org/tarantool/jdbc/SQLDatabaseMetadata.java
> +++ b/src/main/java/org/tarantool/jdbc/SQLDatabaseMetadata.java
> @@ -774,12 +774,12 @@ public class SQLDatabaseMetadata implements DatabaseMetaData {
>              List<Map<String, Object>> fields = (List<Map<String, Object>>) space.get(FORMAT_IDX);
>              List<List<Object>> indexes = (List<List<Object>>) connection.connection.select(_VINDEX, 0, Arrays.asList(space.get(SPACE_ID_IDX), 0), 0, 1, 0);
>              List<Object> primaryKey = indexes.get(0);
> -            List<List<Object>> parts = (List<List<Object>>) primaryKey.get(INDEX_FORMAT_IDX);
> +            List<Map<String, Object>> parts = (List<Map<String, Object>>) primaryKey.get(INDEX_FORMAT_IDX);

I think we should check the type to give a proper error message in the
case when a user give 'native' tarantool space in parameters.
Corresponding test case should be added.

Don't sure how it will be wrapped in Java, I just about the following:

6th field of _vspace tuple for a 'native' space:

[[0, 'unsigned'], [1, 'unsigned']]

(Don't sure whether it is list or map in the binary protocol; likely
map.)

6th field of _vspace tuple for a sql space:

[{'sort_order': 'asc', 'type': 'scalar', 'field': 0,
    'nullable_action': 'abort', 'is_nullable': false}]

What would going on if a user give us 'native' space name?

>              for (int i = 0; i < parts.size(); i++) {
> -                List<Object> part = parts.get(i);
> -                int ordinal = ((Number) part.get(0)).intValue();
> +                Map<String, Object> part = parts.get(i);
> +                int ordinal = ((Number) part.get("field")).intValue();
>                  String column = (String) fields.get(ordinal).get("name");

Just note: it is not mandatory to space format fields to have a name,
but SQL spaces have them. Maybe a comment needed here.

> -                rows.add(Arrays.asList(table, column, i + 1, "primary", primaryKey.get(NAME_IDX)));
> +                rows.add(Arrays.asList(table, column, i + 1, primaryKey.get(NAME_IDX)));
>              }
>          }
>          return new SQLNullResultSet((JDBCBridge.mock(

  reply	other threads:[~2018-10-01 13:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26  9:33 [tarantool-patches] " Sergei Kalashnikov
2018-10-01 13:04 ` Alexander Turenko [this message]
2018-10-02 17:09   ` [tarantool-patches] " Sergei Kalashnikov
2018-10-09  9:21   ` Sergei Kalashnikov
2018-10-09 15:40     ` Alexander Turenko
2018-10-10  8:14       ` Sergei Kalashnikov
2018-10-10 10:19         ` Alexander Turenko
2018-10-10 11:09           ` Sergei Kalashnikov
2018-10-10 12:50             ` Alexander Turenko
2018-10-10 13:19               ` Sergei Kalashnikov
2018-10-10 13:40                 ` Alexander Turenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181001130427.zlugbqlg3madlo7r@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=ztarvos@gmail.com \
    --subject='[tarantool-patches] Re: [PATCH] jdbc: fix primary keys meta retrieval' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox