Skip to content

Conversation

DavideD
Copy link
Member

@DavideD DavideD commented Jun 8, 2021

Down to 100 test failures

@gavinking
Copy link
Member

Excellent.

@DavideD
Copy link
Member Author

DavideD commented Jun 8, 2021

@tsegismont I'm now having issues with null.
If we created this table:

 create table Basic (
       id int not null,
        dessimal numeric(19,2),
        inteja numeric(19,2),
        string varchar(255),
        version int,
        primary key (id)
    )

and then try to insert a null dessimal, this happens:

Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: io.vertx.mssqlclient.MSSQLException: {number=515, state=2, severity=16, message='Cannot insert the value NULL into column 'dessimal', table 'master.dbo.Basic'; column does not allow nulls. INSERT fails.', serverName='55a982ccb425', lineNumber=1}

Any idea?

@gavinking
Copy link
Member

@DavideD override Dialect.getNullColumnString() to return " null" as a temporary workaround.

@tsegismont
Copy link
Contributor

@DavideD I had a discussion about this with @gavinking in #744

The issue is tracked upstream by eclipse-vertx/vertx-sql-client#963

@DavideD
Copy link
Member Author

DavideD commented Jun 8, 2021

@DavideD override Dialect.getNullColumnString() to return " null" as a temporary workaround.

Thanks all! That worked!
We are now down to 12 test failed on my machine

I've also enabled the build on CI for this branch so that we can can see it the build.

I will continue tomorrow.

@DavideD
Copy link
Member Author

DavideD commented Jun 8, 2021

I've also enabled the build on CI for this branch so that we can can see it the build.

Nevermind... there is an issue with testcontainer, probably the JDBC driver is missing. I will check tomorrow

@gavinking
Copy link
Member

We are now down to 12 test failed on my machine

Excellent. At that rate we could essentially go ahead and disable the failing tests and ship it.

@DavideD
Copy link
Member Author

DavideD commented Jun 8, 2021

@blafond Maybe we can exploit the different time zones and see if you can fix some of the tests while I'm off?

Tescontainers nedds it to check the container
@DavideD DavideD force-pushed the mssql-server-test-fixes branch from 5a40cd0 to a1f87f8 Compare June 9, 2021 09:51
@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

Test containers works now.

@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

@tsegismont How do I get the generated id when a column is of type identity?
Example:

    create table EntityWithIdentity (
       id bigint identity not null,
        name varchar(255) null,
        position int null,
        primary key (id)
    )

JDBC returns it in the metadata after an insert but Vert.x returns an empty result instead. Do I need to do a second query?

@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

@tsegismont I think something is not quite right with datetime2 types:

    create table Basic (
       id int not null,
        alocalDT datetime2 null,
        primary key (id)
    )

With the vert.x client, if I try to run an insert query with the value 2021-06-09T14:26:34.243, what gets saved instead is 9 Jun 2021, 14:30:37.

@tsegismont
Copy link
Contributor

JDBC returns it in the metadata after an insert but Vert.x returns an empty result instead. Do I need to do a second query?

You can use SCOPE_IDENTITY() in a follow-up query.

I haven't tried OUTPUT clause, can you try? If that works, can you file an issue for documentation upstream?

The Pg client has a doc section about retrieving data using RETURNING clause.

@tsegismont
Copy link
Contributor

With the vert.x client, if I try to run an insert query with the value 2021-06-09T14:26:34.243, what gets saved instead is 9 Jun 2021, 14:30:37.

Can you please file a complete reproducer? We have tests for datetime2 (using various precisions/scales), but we may have missed something.

@tsegismont
Copy link
Contributor

@DavideD @gavinking the null column string workaround is no longer needed with 4.1.1-SNAPSHOT

eclipse-vertx/vertx-sql-client#963

@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

The Pg client has a doc section about retrieving data using RETURNING clause.

Yes, we already use it for Postgres

@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

OUTPUT doesn't work. I've tried to insert using this query:

insert into EntityWithIdentity (name, position) values (@P1, @P2) OUTPUT INSERTED.id

and it gives me:

javax.persistence.PersistenceException: org.hibernate.HibernateException: io.vertx.mssqlclient.MSSQLException: {number=102, state=1, severity=15, message='Incorrect syntax near 'OUTPUT'.', serverName='40629818ac55', lineNumber=1, additional=[io.vertx.mssqlclient.MSSQLException: {number=8180, state=1, severity=16, message='Statement(s) could not be prepared.', serverName='40629818ac55', lineNumber=1}]}
java.util.concurrent.CompletionException: javax.persistence.PersistenceException: org.hibernate.HibernateException: io.vertx.mssqlclient.MSSQLException: {number=102, state=1, severity=15, message='Incorrect syntax near 'OUTPUT'.', serverName='40629818ac55', lineNumber=1, additional=[io.vertx.mssqlclient.MSSQLException: {number=8180, state=1, severity=16, message='Statement(s) could not be prepared.', serverName='40629818ac55', lineNumber=1}]}

@tsegismont
Copy link
Contributor

The OUTPUT clause must come before VALUES. Can you try:

insert into EntityWithIdentity (name, position) OUTPUT INSERTED.id values (@P1, @P2)

@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

Nice one! That seems to work

@DavideD DavideD force-pushed the mssql-server-test-fixes branch from 31c4a59 to b71ee9f Compare June 9, 2021 15:43
@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

@tsegismont About datetime2, see eclipse-vertx/vertx-sql-client#977

@DavideD
Copy link
Member Author

DavideD commented Jun 9, 2021

Down to 8 tests failing but there are only 3 types of errors remaining:

Cheers

@blafond
Copy link
Member

blafond commented Jun 9, 2021

  1. I was able to create temp table with #BooksJS in DbVisualizer and add a row using same create and insert SQL statements as is generated in our tests.
  2. I assume the first sql create table #BookJS (id int not null) probably doesn't work nor throw an exception, so when insert into ... is called it can't find the temp table and throws an exception: Invalid object name '#BookJS'.
  3. Cloned and searched the vertx-sql-client repo. There is temp table support for MYSQL client, but can't find any reference to tests for temp tables in any of the other clients including vertx-mssql-client

I found this issue that @Gavin King logged last year, but found a work around for Db2.

So vertx development hasn't gotten around to fully supporting temp tables for all dbs. So for now I'd suggest disabling these tests for mssql.

@tsegismont
Copy link
Contributor

An issue with UUID types I haven't check yet

@DavideD guid type is not supported yet, see eclipse-vertx/vertx-sql-client#608 (comment)

@blafond about temporary tables: we've added this to HR and it fixed some tests

@Override
public String generateIdTableName(String baseName) {
return (dialect instanceof SQLServerDialect ? "#" : "ht_") + baseName;
}

So I'm surprised you found temporary tables cannot be created with the Reactive MS SQL Client. Of course we may have missed something. In this case please file an issue upstream with a reproducer.

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

@DavideD guid type is not supported yet, see eclipse-vertx/vertx-sql-client#608 (comment)

Yes, but we store them as bytes. Anyway, the issue is that the converter we are using expects a byte[16] but when we read it back is byte[14] because it's not padded to a binary(255) when saved on the db.

Working on it.

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

So I'm surprised you found temporary tables cannot be created with the Reactive MS SQL Client. Of course we may have missed something. In this case please file an issue upstream with a reproducer.

Yes, I don't think that's the issue. We create and select temporary tables several times without problems before reaching the error. It's probably something specific that we are doing with the temporary table in those tests that are failing that it's causing the exception.

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

I was able to create temp table with #BooksJS in DbVisualizer and add a row using same create and insert SQL statements as is generated in our tests.

That uses the JDBC driver. Have you tried to run the same queries as native queries with Hibernate Reactive?

@tsegismont
Copy link
Contributor

Yes, but we store them as bytes. Anyway, the issue is that the converter we are using expects a byte[16] but when we read it back is byte[14] because it's not padded to a binary(255) when saved on the db.

Yeah, binary vs varbinary

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

Yeah, binary vs varbinary

Well... no... that column on the database is binary(255):

    create table Basic (
       id int not null,
        uuid binary(255) null,
        primary key (id)
    )

I think it's the fact that we convert it using a Buffer.buffer(byte[]). Could it be?

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

Yeah, binary vs varbinary

Ah... I understand what you mean now

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

@tsegismont Is there a snapshot with this included? eclipse-vertx/vertx-sql-client#963

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

@tsegismont Is there a snapshot with this included? eclipse-vertx/vertx-sql-client#963

Never mind, I've just installed it locally.

I've spent some time working on the UUID issue. What's happening is that when we insert the UUID converted to a byte[16], the value in the database is not padded to binary(255).

The column in the database is defined as binary(255) null.

Surprisingly, everything works if I remove [the change about making the columns null]
(8950cd9) and the column on the database is binary(255).

Any idea of what could cause this behaviour?

Note that I've tried to recreate a test for the Vert.x Client but everything seems to work fine with it (with or without the null).
And the error seems related to how the schema is created but I couldn't find any difference between the way the tables have been created.

Anyway... If I use the latest snapshot without the special dialect for Sql Server, it works.
I guess we can just wait for he next release.

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

Anyway... If I use the latest snapshot without the special dialect for Sql Server, it works.

It also works when I use the special dialect... well, whatever...

@tsegismont
Copy link
Contributor

@DavideD

Is there a snapshot with this included? eclipse-vertx/vertx-sql-client#963

It seems we have a persistent DB2 test failure which prevents the snapshots from being deployed, will look into this, thanks for the heads-up.

Any idea of what could cause this behaviour?

Perhaps in HR codebase there's an equality test to SqlServerDialect instead of using instanceof?

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

Perhaps in HR codebase there's an equality test to SqlServerDialect instead of using instanceof?

Maybe... but I don't think so.

@DavideD
Copy link
Member Author

DavideD commented Jun 10, 2021

I think @blafond was right.
@tsegismont, I've tried this test: eclipse-vertx/vertx-sql-client#979

But it's very possible I did something wrong.

@DavideD DavideD force-pushed the mssql-server-test-fixes branch from 57e020c to 6fed967 Compare June 11, 2021 10:45
@DavideD
Copy link
Member Author

DavideD commented Jun 14, 2021

It seems that now we have a version that passes all the tests (using the latest Vert.x Snapshot).

I still have to clean it up and refactor some changes but we should be close.

Thank you all!

@gavinking
Copy link
Member

Awesome, that's really great news!!

@tsegismont
Copy link
Contributor

tsegismont commented Jun 14, 2021 via email

@DavideD
Copy link
Member Author

DavideD commented Jun 15, 2021

Thanks @tsegismont. I will have a look at it shortly

@DavideD
Copy link
Member Author

DavideD commented Jun 17, 2021

@tsegismont batching seems to pass the tests fine. Thanks

Closing this pr and sending a new one in a bit

@DavideD DavideD closed this Jun 17, 2021
@tsegismont
Copy link
Contributor

tsegismont commented Jun 17, 2021 via email

@DavideD DavideD deleted the mssql-server-test-fixes branch July 7, 2021 14:35
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

Successfully merging this pull request may close these issues.

4 participants